How to Build Your Own MCP Server in 10 Minutes
Any function you can write in TypeScript or Python can become an MCP tool — meaning any API, internal system, or custom logic you have can be exposed to Claude or Cursor in minutes. This guide walks through building a minimal but functional MCP server using the official TypeScript SDK.
get_weather — that takes a city name and returns mock weather data. You can replace the mock logic with any real API call after the tutorial.Prerequisites
- Node.js 18 or later
- Basic TypeScript familiarity
- Claude Desktop or Cursor installed (to test the server)
- 5–10 minutes
Create the project
Create a new folder and initialise a Node.js project with the MCP SDK:
mkdir my-mcp-server && cd my-mcp-server npm init -y npm install @modelcontextprotocol/sdk zod npm install -D typescript @types/node tsx npx tsc --init
Write the server
Create src/index.ts with the following code:
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
import { z } from 'zod'
// Create the MCP server
const server = new McpServer({
name: 'weather-server',
version: '1.0.0',
})
// Register a tool
server.tool(
'get_weather',
'Get the current weather for a city',
{
city: z.string().describe('The city name, e.g. "London"'),
},
async ({ city }) => {
// Replace this with a real API call
const mockTemp = Math.floor(Math.random() * 30) + 5
return {
content: [
{
type: 'text',
text: `Weather in ${city}: ${mockTemp}°C, partly cloudy.`,
},
],
}
}
)
// Start the server using stdio transport
const transport = new StdioServerTransport()
await server.connect(transport)Test the server
You can test the server in isolation using the MCP Inspector tool:
npx @modelcontextprotocol/inspector npx tsx src/index.ts
This opens a browser-based UI where you can call get_weather directly and inspect the response before connecting to Claude.
Register with Claude Desktop
Add your server to Claude Desktop's config file:
{
"mcpServers": {
"weather": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/my-mcp-server/src/index.ts"]
}
}
}Restart Claude Desktop. You can now ask "What is the weather in Tokyo?" and Claude will call your get_weather tool.
Next steps
- Replace the mock weather logic with a real API call (e.g. OpenWeatherMap) to make the tool genuinely useful.
- Add more tools to the same server — one server can expose as many tools as you like.
- Add MCP resources to expose read-only data sources (like config files or database records) that Claude can inspect without calling a function.
- Publish your server to npm and submit it to MCPCMD so other developers can use it.
Built something useful?
Submit your MCP server to the MCPCMD directory so other developers can discover it.
Submit Your MCP Server