mcp-server-patterns

Implement MCP servers with the Node/TypeScript SDK using tools, resources, prompts, and transports.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/inuishan/PET --skill mcp-server-patterns-inuishan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mcp-server-patterns
Source: https://github.com/inuishan/PET/tree/main/.codex/skills/mcp-server-patterns
Command: npx skills add https://github.com/inuishan/PET --skill mcp-server-patterns-inuishan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @modelcontextprotocol/sdk, zod.

What problem does it solve? Building a Model Context Protocol server requires navigating an evolving SDK API, choosing between stdio and Streamable HTTP transports, and correctly registering tools, resources, and prompts—mistakes here cause registration and connection failures that are hard to debug. ## Core Features & Use Cases - Server scaffolding guidance: Set up an MCP server with @modelcontextprotocol/sdk and Zod, with schema-first input validation for every tool. - Transport selection: Choose stdio for local clients like Claude Desktop or Streamable HTTP for remote clients like Cursor, keeping server logic transport-independent. - Registration patterns: Register tools, resources, and prompts correctly across SDK versions (tool() vs registerTool()), verifying signatures against official docs or Context7. - Use Case: You are adding a new search tool to an internal MCP server used by Claude Desktop. Use this Skill to define the Zod input schema, register the tool with the correct SDK method, and connect over stdio. ## Quick Start Use the mcp-server-patterns skill to scaffold a new MCP server in TypeScript with one Zod-validated tool and a stdio transport.

Frequently Asked Questions about mcp-server-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an MCP server in TypeScript?▼

Install @modelcontextprotocol/sdk and zod, create an McpServer instance with a name and version, then register tools and resources using the API your SDK version provides. Verify current method signatures against the official MCP docs or Context7 since the API has changed over time.

How do I register a tool in the MCP TypeScript SDK?▼

Register tools with server.tool() or registerTool() depending on your SDK version—some versions take positional arguments, others take an options object. Always define a Zod input schema and check the official docs for the exact signature to avoid copy-paste errors.

Should I use stdio or Streamable HTTP for my MCP server?▼

Use stdio for local clients like Claude Desktop and Streamable HTTP for remote clients like Cursor or cloud deployments. Keep your server logic independent of transport so you can plug in either one in the entrypoint.

Does the MCP SDK support input validation for tools?▼

Yes, use Zod or the SDK's preferred schema format to define input schemas for every tool. Document parameters and return shapes, and return structured errors the model can interpret rather than raw stack traces.

Why does my MCP tool registration fail after an SDK upgrade?▼

The official SDK has changed registration APIs over time, switching between tool()/resource() and registerTool()/registerResource() patterns. Pin your SDK version in package.json and check release notes and current docs when upgrading.