
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
@stellarwp/mcp-api-fetch
Advanced tools
@stellarwp/mcp-api-fetch)A Node.js compatible implementation of WordPress's @wordpress/api-fetch with built-in middleware for MCP server environments.
This package provides a drop-in replacement for @wordpress/api-fetch that works seamlessly in Node.js environments while maintaining full API compatibility. It's specifically designed for MCP servers that need to interact with WordPress REST APIs, with automatic authentication and URL handling.
@wordpress/api-fetch# Install the package
bun add @stellarwp/mcp-api-fetch
# Or with npm
npm install @stellarwp/mcp-api-fetch
This package works with the Node Config package for environment variable management. Create a .env file in your project root:
WP_REST_URL=https://your-site.com/wp-json/wp/v2/
WP_USERNAME=your_username
WP_APP_PASSWORD=your_application_password
💡 Local Development Tip: When developing on a local environment where SSL certificates wouldn't validate (e.g., localhost with self-signed certs), you can set
NODE_TLS_REJECT_UNAUTHORIZED=0in your environment variables. Note: This should only be used in development environments, never in production.
import apiFetch from '@stellarwp/mcp-api-fetch';
// Simple GET request
const posts = await apiFetch({ path: '/wp/v2/posts' });
The package provides a middleware-based architecture that extends the standard @wordpress/api-fetch functionality:
The authentication approach depends on your deployment environment:
When running as a Node.js-based MCP server, the package automatically adds WordPress authentication using WordPress Application Passwords:
// Middleware automatically adds these headers:
// Authorization: Basic base64(username:password)
// Uses WP_USERNAME and WP_APP_PASSWORD environment variables
When the package is used in a browser environment, it integrates with WordPress's built-in authentication system. The package must be bundled with your project's webpack configuration to include the @wordpress/api-fetch version provided by WordPress, which automatically handles authentication using the current user's WordPress session.
Handles WordPress URL construction and normalization:
WP_REST_URL to all relative paths@wordpress/api-fetch to be provided by WordPresswp-api-fetch to be enqueued by WordPressWhen using this package in a browser environment:
// In your WordPress theme or plugin
wp_enqueue_script('wp-api-fetch');
wp_enqueue_script('mcp-api-fetch', 'path/to/browser.js', ['wp-api-fetch']);
You can extend the functionality by adding custom middleware:
import { use } from '@stellarwp/mcp-api-fetch';
// Custom middleware for logging
use(async (options, next) => {
console.log('Request:', options);
const response = await next(options);
console.log('Response:', response);
return response;
});
The package provides different builds for different environments:
index.js - Full middleware support with custom fetch implementationbrowser.js - WordPress integration with external @wordpress/api-fetch dependencyindex.d.ts - TypeScript definitionsFAQs
A compatible interface with @wordpress/api-fetch
The npm package @stellarwp/mcp-api-fetch receives a total of 9 weekly downloads. As such, @stellarwp/mcp-api-fetch popularity was classified as not popular.
We found that @stellarwp/mcp-api-fetch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.