Learn how to configure MCP in Cursor using Claude Desktop by following these step-by-step instructions. This guide will cover everything from project setup to deployment and verification.
prerequisites
- Claude Desktop application: Download and install the app from the official source.
- Code editor: Install Cursor or another JavaScript-friendly editor like VS Code.
- Node.js and TypeScript: Ensure Node.js (preferably LTS) and TypeScript are installed on your system.
- Verify installations using
node --versionandtsc --versioncommands.
- Verify installations using
Creating the MCP Server Project
To get started, set up the project structure and ensure the necessary Node.js environment is ready.
steps
Create a project directory:
bashmkdir my-mcp-server cd my-mcp-serverInitialize the project:
bashnpm init -yInstall required dependencies:
bashnpm install typescript @openai/ai npm-run-all
Setting Up Server Files
With the initial setup complete, structure your project and configure essential files.
steps
Create the project structure:
bashmkdir src touch src/index.tsConfigure
package.json: Openpackage.jsonin your editor and update it with the following:json{ "name": "my-mcp-server", "version": "1.0.0", "type": "module", "scripts": { "build": "tsc" }, "files": ["build"] }Add a TypeScript configuration: Create a
tsconfig.jsonfile in the project’s root directory:json{ "compilerOptions": { "target": "ES2020", "module": "ES2020", "outDir": "build", "rootDir": "src", "strict": true, "esModuleInterop": true, "moduleResolution": "node" }, "include": ["src"] }
Coding Your MCP Server
Here, you will write the server logic to define tools and capabilities.
steps
Set up
index.tsinsrc: Write the following code to define your server:typescriptimport { createServer } from "@openai/ai"; const server = createServer({ name: "WeatherMCPServer", capabilities: { tools: { getWeather: { description: "Fetch current weather for a location", parameters: { location: { type: "string" } }, action: async (params) => { // Dummy weather data return { temperature: "72°F", location: params.location }; }, }, }, }, }); server.listen().then(() => { console.log("MCP server is running."); });Add helper functions: If your tools require API calls or other logic, you may write functions within this file.
Finalize the server: Ensure all code logic for your MCP tools, resources, and server metadata is implemented.
Building and Deploying the Server
Compile the TypeScript source and configure Claude Desktop.
steps
Build the server:
bashnpm run buildCopy the file path for deployment: Locate the generated
build/index.jsfile and copy its absolute file path.Configure Claude Desktop:
- Open Claude Desktop and go to Settings.
- Enable Developer Mode.
- Edit the
claude_desktop_config.jsonfile in the configuration interface. - Replace the
mcp_server_pathfield with the absolute path to yourindex.js.
Restart Claude Desktop: Close and reopen Claude Desktop to apply the changes.
Verify the integration:
- Open a chat in Claude Desktop.
- Test your added MCP tools by querying them interactively in the chat interface.
FAQ
How do I fix errors in the Claude MCP integration?
Verify the mcp_server_path in the Claude configuration file and ensure the server tool keys in your code match exactly with the MCP JSON.
Can I run multiple MCP servers in Claude Desktop?
Yes, use unique tool names and different server paths for each MCP instance. Update the mcp_server_path for the desired server.
Why is my MCP server not responding to requests in Claude Desktop?
Ensure the server is running, the build process is complete, and the correct path to index.js is configured in Claude Desktop. Restart the app to apply changes.
Official reference: Claude documentation.