What you'll build
Your own MCP (Model Context Protocol) server that gives custom tools to Claude Desktop.
Imagine Claude being able to check the weather, save notes, or access your database. MCP is the standard for extending Claude's capabilities. Your server exposes "tools" that Claude can call during a conversation.
When finished, you'll have an MCP server in TypeScript that works with Claude Desktop. You can add any tool: external APIs, databases, file system, whatever you need.
The prompt to start
Create an MCP server in TypeScript that:
- Has a "weather" tool that receives city
- Has a "notes" tool to save/read notes
- Uses the official MCP SDK
- Works with Claude Desktop
What the AI will create
// src/index.ts
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
ListToolsRequestSchema,
CallToolRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
const server = new Server(
{ name: "my-mcp-server", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
// Simple database for notes
const notes: Record<string, string> = {};
// Define available tools
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: "weather",
description: "Gets the weather for a city",
inputSchema: {
type: "object",
properties: {
city: { type: "string", description: "City name" }
},
required: ["city"]
}
},
{
name: "save_note",
description: "Saves a note",
inputSchema: {
type: "object",
properties: {
title: { type: "string" },
content: { type: "string" }
},
required: ["title", "content"]
}
},
{
name: "read_notes",
description: "Reads all saved notes",
inputSchema: { type: "object", properties: {} }
}
]
}));
// Implement tools
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
switch (name) {
case "weather": {
// Simulate weather API
const city = args?.city as string;
const temp = Math.floor(Math.random() * 30) + 5;
return {
content: [{
type: "text",
text: `Weather in ${city}: ${temp}ยฐC, partly cloudy`
}]
};
}
case "save_note": {
const { title, content } = args as { title: string; content: string };
notes[title] = content;
return {
content: [{ type: "text", text: `Note "${title}" saved` }]
};
}
case "read_notes": {
const list = Object.entries(notes)
.map(([t, c]) => `- ${t}: ${c}`)
.join("\n");
return {
content: [{ type: "text", text: list || "No notes" }]
};
}
default:
throw new Error(`Unknown tool: ${name}`);
}
});
// Start server
const transport = new StdioServerTransport();
server.connect(transport);
console.error("MCP server started");
Configure Claude Desktop
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["/path/to/dist/index.js"]
}
}
}