@yansirplus/mcp-wp
v1.0.4
Published
A simple MCP server for WordPress
Readme
MCP Currency Converter
A Model Context Protocol (MCP) server that
Installation
# Using npm
npm install @yansirplus/mcp-wp
# Using yarn
yarn add @yansirplus/mcp-wp
# Using bun
bun install @yansirplus/mcp-wpUsing as a CLI Tool
After installation, you can run the MCP server directly from the command line:
# If installed globally
mcp-wp
# If installed locally
npx @yansirplus/mcp-wpThis will start the MCP server in stdio mode, allowing you to connect to it with MCP clients.
Using as a dependency
// Import the server
import { server } from "@yansirplus/mcp-wp";
// Connect to your own transport
import { YourTransport } from "./your-transport.js";
const transport = new YourTransport();
await server.connect(transport);
// Or use programmatically
const toolResponse = await server.callTool("usd-to-cny", { amount: 100 });
console.log(toolResponse);
// Just use the conversion function
import { convertUsdToCny } from "@yansirplus/mcp-wp";
console.log(convertUsdToCny(100)); // 730Building
bun run buildRunning
Stdio Mode (Command Line)
bun startHTTP Server Mode
This mode exposes the MCP server over HTTP with Server-Sent Events (SSE):
bun run start:httpThe server will run on port 3000 by default. You can set a different port using the PORT environment variable:
PORT=8080 bun run start:httpEndpoints:
- SSE Connection:
GET /sse - Message Endpoint:
POST /messages?sessionId=<your-session-id>
Usage
This MCP server provides a single tool:
usd-to-cny
Converts a USD amount to CNY using a fixed exchange rate of 7.3.
Parameters:
amount: A positive number representing the USD amount to convert
Example Response:
100 USD = 730.00 CNY (rate: 7.3)Testing with MCP Inspector
You can test this server using the MCP Inspector. Run the server and then connect the inspector to it.
Testing Stdio Mode
- Start the server:
bun start - Open the MCP Inspector
- Select the server type (localhost stdio)
- Connect to the server
- Use the "Call Tool" tab to test the usd-to-cny tool
Testing HTTP Mode
- Start the HTTP server:
bun run start:http - Open the MCP Inspector
- Select the server type (HTTP with SSE)
- Set the SSE URL to
http://localhost:3000/sse - Set the Message URL to
http://localhost:3000/messages - Connect to the server
- Use the "Call Tool" tab to test the usd-to-cny tool
License
MIT
