MCP Config & Server Scaffolds
Copy-paste starters for connecting Claude to tools via MCP. Trim to what you need.
.mcp.json — declare servers (project-shared)
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "${DATABASE_URL}"]
}
}
}
:::warning Keep secrets out of the file
Reference env vars (${GITHUB_TOKEN}) — don't hard-code tokens in a committed file.
:::
Minimal stdio server (TypeScript)
A tiny server exposing one tool. Adapt the handler to your data.
import { McpServer } from "@modelcontextprotocol/server";
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
import { z } from "zod";
const server = new McpServer({ name: "echo", version: "1.0.0" });
server.registerTool(
"echo",
{
description: "Echo back the provided text",
inputSchema: z.object({ text: z.string().describe("Text to echo back") }),
},
async ({ text }) => ({ content: [{ type: "text", text: `You said: ${text}` }] }),
);
await server.connect(new StdioServerTransport());
:::note SDK package rename (MCP TS SDK v2)
@modelcontextprotocol/sdk was split into @modelcontextprotocol/server and @modelcontextprotocol/client in v2. The v1 package still receives bug fixes; new projects should use v2.
:::
Minimal stdio server (Python)
from mcp.server import MCPServer
mcp = MCPServer("echo")
@mcp.tool()
def echo(text: str) -> str:
"""Echo the text back."""
return f"You said: {text}"
if __name__ == "__main__":
mcp.run(transport="stdio")
Before you ship a server
- Least privilege — only the data/actions it needs (Securing Agents).
- Validate inputs; return errors as results, don't crash.
- Review third-party servers before connecting (Reviewing Third-Party Code).