6× menos código
SDK Oficial (TypeScript)
import { Server } from "@modelcontextprotocol/sdk/...";
import { StdioServerTransport } from "...";
import { ListToolsRequestSchema, CallToolRequestSchema } from "...";
const server = new Server({ name: "math" }, { capabilities: { tools: {} } });
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [{ name: "sumar", description: "Suma dos números",
inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } }, required: ["a","b"] }
}]
}));
server.setRequestHandler(CallToolRequestSchema, async (req) => {
const { a, b } = req.params.arguments as { a: number; b: number };
return { content: [{ type: "text", text: String(a + b) }] };
});
const transport = new StdioServerTransport();
await server.connect(transport);
FastMCP (Python)
from fastmcp import FastMCP
mcp = FastMCP("math")
@mcp.tool
def sumar(a: int, b: int) -> int:
"""Suma dos números"""
return a + b
if __name__ == "__main__":
mcp.run()
list_tools handler manual → Auto-generated
JSON Schema manual → Type hints automáticos
call_tool dispatcher → Eliminado
TextContent wrapping → Return Python puro