npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wp-mcp-server

v0.0.4

Published

Wordpress MCP Server

Readme

WordPress MCP Server

A Node.js server that connects to your WordPress site and exposes functionality via the Model Context Protocol (MCP).

Table of Contents


Introduction

This project showcases how to build a Model Context Protocol (MCP) server that interacts with a WordPress website. It leverages:

The server listens for incoming requests through STDIO transport, executes the requested tools (endpoints), and returns results in JSON format.


Installation

  1. Clone this repository (or copy the relevant files into your own project):

    git clone https://github.com/yourorg/wordpress-mcp-server.git
    cd wordpress-mcp-server
  2. Install Dependencies:

    npm install

    This will install:

    • @modelcontextprotocol/sdk
    • zod
    • any other dependencies defined in the package.json.

Usage

  1. Set Environment Variables:

    • WP_URL – The URL of your WordPress site (e.g., https://example.com/wp-json or https://example.com depending on your setup).
    • WP_USERNAME – The WordPress username.
    • WP_PASSWORD – The corresponding password or application password.

    Example:

    export WP_URL="https://your-wordpress.com"
    export WP_USERNAME="admin"
    export WP_PASSWORD="admin_password"
  2. Run the Server:

    npm start

    or

    node index.js

    (Depending on how you have set up your entry point in package.json.)

    You should see console output indicating that the server has started.

    Starting server...
    Server started!
  3. Connect to the MCP Server:

    • The server uses the StdIOServerTransport by default. Typically, the MCP orchestrator (or any MCP-compatible client) will handle communication via STDIO.
    • Refer to the Model Context Protocol documentation for instructions on how to link this server with your MCP client or orchestrator.

Configuration

Aside from the environment variables, you can fine-tune the following aspects in the code (index.js or server.js):

  • Server Name and Description: You can modify the parameters passed to the McpServer constructor:
    const server = new McpServer({
        name: "Wordpress Plugin",
        description: "A plugin for Wordpress",
        version: "1.0.0"
    });
  • Tool Names and Descriptions: Each “tool” (endpoint) includes a name, description, and input schema defined with zod.
  • Default Values (e.g., post status, default pagination, etc.) in the buildPostInput / buildCategoryInput helper functions.

Available Tools (Endpoints)

Below are the tools exposed by this MCP server. They can be called via the MCP client, orchestrator, or any code that interacts with the MCP over STDIO.

1. fetch_posts

Name: fetch_posts
Description: Fetch posts from a WordPress blog.

  • Parameters:
    • page (number, optional) – The page number to retrieve.
    • perPage (number, optional) – The number of posts per page.

Returns
A JSON list of posts with their title, excerpt, content, slug, and date.

2. fetch_categories

Name: fetch_categories
Description: Fetches all categories from the WordPress blog.

  • Parameters: None
  • Returns
    A JSON list of categories with their corresponding information (ID, name, slug, etc.).

3. fetch_media

Name: fetch_media
Description: Fetches all media items from the WordPress site.

  • Parameters: None
  • Returns
    A JSON list of media items with relevant information (e.g., title, source URL, etc.).

4. create_post

Name: create_post
Description: Creates a new post in WordPress.

  • Parameters:

    • title (string) – Title of the post.
    • content (string) – Content/body of the post.
    • categories (array of numbers, optional) – Array of WordPress category IDs.
    • tags (array of numbers, optional) – Array of WordPress tag IDs.
    • slug (string, optional) – Custom slug for the post.
    • status (enum, optional) – Post status (publish, draft, or pending). Defaults to draft.
  • Returns
    A JSON object containing information about the newly created post (e.g., ID, link, status, etc.).

5. create_category

Name: create_category
Description: Creates a category in WordPress.

  • Parameters:

    • name (string) – Name of the new category.
    • description (string) – Description of the category.
    • slug (string, optional) – Custom slug for the category.
    • parent (number, optional) – Parent category ID.
  • Returns
    A JSON object containing information about the newly created category.


Error Handling

Each tool wraps the WordPressService calls in a try/catch block. In case of an error:

  • The code logs the error to the console.
  • Responds with a JSON content object containing "Error <action>...".
  • Sets isError to true when relevant so the client/orchestrator can detect and handle errors accordingly.

Example error response:

{
  "content": [
    {
      "type": "text",
      "text": "Error creating post"
    }
  ],
  "isError": true
}

Contributing

  1. Fork this repository.
  2. Create a new branch with your feature or bug fix.
  3. Commit your changes, including tests (if applicable).
  4. Open a Pull Request describing your modifications.

All contributions are welcome! Please ensure your changes align with the Model Context Protocol TypeScript SDK best practices.