1. Set up your project
mkdir cursor-mcp
cd cursor-mcp
npm init -y
npm pkg set type=module
2. Install dependencies
npm install @modelcontextprotocol/sdk
3. Create index.js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({
name: "Hello World",
version: "1.0.0"
});
server.tool("add",
{ a: z.number(), b: z.number() },
async ({ a, b }) => ({
content: [{ type: "text", text: String(a + b) }]
})
);
const transport = new StdioServerTransport();
await server.connect(transport);
4. Add to Cursor
Go to Settings, MCP, and add new MCP server.
The command is node /absolute/path/to/your/index.js
. For example node /Users/andyrewlee/mcp-server/index.js
.
5. Trigger your MCP by asking Cursor to add 24 and 81
In Agent mode prompt 8 + 24
and watch the add
tool in your MCP get triggered.
Top comments (7)
github.com/andyrewlee/hello-world-...
"cursor-mcp": {
"command": "node",
"args": [
"/Users/liyongyong/10-yingmi_application/mcp/cursor-mcp/index.js"
]
}
hello I configed above code in my cursor, but the

I donnot know where has problems
what happens if you run that in your terminal?
my cursor version is 0.47.8
For me, its throwing this error
does it show you what values were passed in for a and b values? another way to debug would be to run
npx @modelcontextprotocol/inspector@latest
and see if you have the same error.Are you in Composer and in Agent mode?