Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
This skill guides you through creating production-quality MCP (Model Context Protocol) servers. MCP servers enable AI assistants to interact with external services through well-designed tools, resources, and prompts.
fastmcp package@modelcontextprotocol/sdkfrom fastmcp import FastMCP
mcp = FastMCP("my-service")
@mcp.tool()
def get_data(query: str, limit: int = 10) -> str:
"""Fetch data from the service.
Args:
query: Search query string
limit: Maximum number of results (default: 10)
"""
# Implementation here
return results
if __name__ == "__main__":
mcp.run()
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: "my-service",
version: "1.0.0",
});
server.tool(
"get-data",
"Fetch data from the service",
{
query: z.string().describe("Search query string"),
limit: z.number().default(10).describe("Max results"),
},
async ({ query, limit }) => {
// Implementation here
return { content: [{ type: "text", text: JSON.stringify(results) }] };
}
);
const transport = new StdioServerTransport();
await server.connect(transport);
get-users, create-issue, search-docs)Use run_command to test MCP servers:
# Python
python -m fastmcp dev my_server.py
# Node/TypeScript
npx tsx my_server.ts
Verify tools work correctly by testing with various inputs and edge cases.