Production Case Study: Building an Internal MCP Adapter
Whenever public community registries omit proprietary internal endpoints or domain calculators, shipping a focused in-house MCP server gives engineers clean leverage in under an hour. Our walkthrough distills lessons from packaging domain integrations alongside Korean Law MCP and MCP for Unity.
SDK Stack Comparison
| SDK Choice | Validation Library | Best Fit Scenario |
|---|---|---|
| @modelcontextprotocol/sdk Node | Zod inputSchema | Next.js monorepos, REST wrappers, Vercel deployments |
| Python FastMCP | Pydantic type hints | Data pipelines, ML scripts, local Unity WebSocket hubs |
Minimal TypeScript stdio Server Blueprint
Using TypeScript ensures end-to-end schema typing between JSON arguments validated by Zod and backend calls:
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: "internal-release-notes",
version: "1.0.0",
});
server.registerTool(
"get_deploy_status",
{
description: "Fetch current release build tag by environment",
inputSchema: { env: z.enum(["staging", "production"]) },
},
async ({ env }) => ({
content: [{ type: "text", text: "Deploy active for " + env }],
})
);
const transport = new StdioServerTransport();
await server.connect(transport);Three Pitfalls We Caught During Testing
- Polluting stdout with console.log: In stdio transport, standard output carries raw JSON-RPC frames exclusively. A single stray log statement breaks Claude or Cursor initialization instantly. Always emit diagnostics to console.error so logs land cleanly on stderr.
- Oversized Raw Payload Dumps: Returning raw 50KB REST JSON blobs floods context windows and triggers truncation. Trim responses strictly to identifiers, timestamps, and actionable status codes—mirroring strategies covered in our Token Bloat Reduction Guide.
- Missing Actionable Error Hints: Return clear recovery guidance inside isError responses so autonomous loops self-correct parameter typos immediately instead of guessing blindly.
Verify every new custom server interactively with npx @modelcontextprotocol/inspector before adding it to your Claude MCP Setup or registering it for review inside MCP Atlas.