mcp-server-patterns

Build MCP servers registering tools, resources, and prompts for AI clients.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/riftzen-bit/gemini-setup --skill mcp-server-patterns-riftzen-bit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mcp-server-patterns
Source: https://github.com/riftzen-bit/gemini-setup/tree/main/skills/mcp-server-patterns
Command: npx skills add https://github.com/riftzen-bit/gemini-setup --skill mcp-server-patterns-riftzen-bit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides practical patterns and best practices for building and maintaining Model Context Protocol (MCP) servers so AI clients can reliably invoke tools, fetch resources, and use prompts.

Core Features & Use Cases

  • Guidance for registering tools, resources, and prompts across evolving Node/TypeScript SDK APIs.
  • Transport patterns and tradeoffs for stdio (local) versus Streamable HTTP (remote) and how to keep server logic transport-agnostic.
  • Best practices including schema-first validation (Zod), structured errors, idempotency, rate and cost awareness, and SDK versioning for production readiness.

Quick Start

Start a Node/TypeScript MCP server that registers tools and resources, validates inputs with Zod, and exposes either a Streamable HTTP endpoint or a stdio transport for clients to connect.

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 with Node and TypeScript?

To build an MCP server with Node and TypeScript, you register tools, resources, and prompts using the @modelcontextprotocol/sdk. You must validate inputs with Zod and separate transport logic from business logic for reliable AI client communication.

What is the difference between stdio and Streamable HTTP transports in MCP?

The difference is that stdio is used for local MCP server connections while Streamable HTTP enables remote access. Choosing between them involves tradeoffs in network exposure, but keeping server logic transport-agnostic allows you to support both.

Why do I need Zod schema validation in a Model Context Protocol server?

You need Zod schema validation in an MCP server to enforce structured input types for tools and resources. This schema-first approach prevents runtime errors by ensuring AI clients send properly formatted data before the server processes requests.

How do I register tools and resources using the @modelcontextprotocol/sdk?

You register tools and resources using the evolving @modelcontextprotocol/sdk APIs by defining their schemas and handlers. Aligning with the current SDK versioning ensures your server properly exposes these capabilities for AI clients to invoke.

What are the best practices for production MCP servers?

Best practices for production MCP servers include using schema-first validation, returning structured errors, ensuring idempotency, and applying rate and cost awareness. Maintaining SDK versioning and transport-agnostic logic are also required for production readiness.

Why is my MCP server failing to register tools after an SDK upgrade?

Your MCP server fails to register tools after an SDK upgrade due to API changes in the @modelcontextprotocol/sdk. You must align your tool registration code with the current SDK versioning and debug transport or registration issues accordingly.