DEV Community

Andrew Lee
Andrew Lee

Posted on β€’ Edited on

19 1

Build and use your own MCP in Cursor in 5 minutes

1. Set up your project

mkdir cursor-mcp
cd cursor-mcp
npm init -y
npm pkg set type=module
Enter fullscreen mode Exit fullscreen mode

2. Install dependencies

npm install @modelcontextprotocol/sdk
Enter fullscreen mode Exit fullscreen mode

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);

Enter fullscreen mode Exit fullscreen mode

4. Add to Cursor

Go to Settings, MCP, and add new MCP server.

Image description

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.

Image description

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo πŸ“Šβœ¨

Top comments (4)

Collapse
 
andyrewlee profile image
Andrew Lee β€’
Collapse
 
danishlyy profile image
danishlyy β€’

"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
Image description
I donnot know where has problems

Collapse
 
andyrewlee profile image
Andrew Lee β€’

what happens if you run that in your terminal?

Collapse
 
danishlyy profile image
danishlyy β€’

my cursor version is 0.47.8

Image of DataStax

AI Agents Made Easy with Langflow

Connect models, vector stores, memory and other AI building blocks with the click of a button to build and deploy AI-powered agents.

Get started for free

πŸ‘‹ Kindness is contagious

If you found this post useful, please drop a ❀️ or leave a kind comment!

Okay