MCP Server Patterns

VerifiedSafe

Build and debug MCP servers with the Node/TypeScript SDK: tools, resources, prompts, Zod validation, stdio vs Streamable HTTP transport.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude CodeCursorCodex
#mcp#typescript#nodejs#tools#transport

Recommended for

Automated summary

A reference guide for building and maintaining MCP servers in Node/TypeScript with the official SDK: tools, resources, prompts, Zod validation, and choosing between stdio and Streamable HTTP transports.

Strengths

  • Covers all four protocol building blocks (tools, resources, prompts, transport) with current naming conventions
  • Explicitly flags that SDK signatures drift and points to Context7 or official docs instead of hardcoding a stale API
  • Practical best practices: schema-first tool inputs, model-readable structured errors, idempotency, rate/cost awareness, and SDK version pinning
  • Keeps server logic decoupled from transport, making it easy to swap local stdio for remote Streamable HTTP

Limitations

  • Example code is deliberately partial — tool/resource registration is described in prose rather than given as complete snippets
  • No full end-to-end server example, and nothing on testing or deployment
  • The document is truncated at the end (official SDKs section cut off) and targets only the Node/TypeScript SDK, not Python or Go
When to use it

Reach for it when starting an MCP server or debugging tool registration, input validation, or transport choice.

When not to use it

Skip it if you want a step-by-step tutorial with complete copy-paste code, or if you are building an MCP server in a language other than TypeScript.

Security analysis

Safe
Quality score78/100

The skill is purely instructional documentation about building MCP servers with the Node/TypeScript SDK. It declares no tools, contains no shell commands beyond a benign `npm install` of official packages, makes no network calls, exfiltrates nothing, and disables no safety features. The only external references are the official MCP docs and a relative repo doc path, both benign.

No concerns found

How this analysis is made

Examples

New MCP server scaffold
Scaffold a new MCP server in TypeScript with the official SDK and Zod: one search tool with a validated input schema, one resource that returns file contents by URI, and a stdio entrypoint.
stdio vs Streamable HTTP
My MCP server currently runs over stdio for Claude Desktop. Show me how to restructure it so I can also expose it over Streamable HTTP for remote clients, keeping the tool logic transport-agnostic.
Debug tool registration
My MCP tools aren't showing up in the client after I upgraded @modelcontextprotocol/sdk. Check whether I'm using registerTool() vs tool() correctly for this SDK version and fix the registration.

name: mcp-server-patterns description: Build MCP servers with Node/TypeScript SDK — tools, resources, prompts, Zod validation, stdio vs Streamable HTTP. Use Context7 or official MCP docs for latest API. Use when building or debugging an MCP server — tools, resources, prompts, validation, or transport choice. metadata: origin: ECC

MCP Server Patterns

The Model Context Protocol (MCP) lets AI assistants call tools, read resources, and use prompts from your server. Use this skill when building or maintaining MCP servers. The SDK API evolves; check Context7 (query-docs for "MCP") or the official MCP documentation for current method names and signatures.

For the broader routing decision of when a capability should be a rule, a skill, MCP, or a plain CLI/API workflow, see docs/capability-surface-selection.md.

When to Use

Use when: implementing a new MCP server, adding tools or resources, choosing stdio vs HTTP, upgrading the SDK, or debugging MCP registration and transport issues.

How It Works

Core concepts

  • Tools: Actions the model can invoke (e.g. search, run a command). Register with registerTool() or tool() depending on SDK version.
  • Resources: Read-only data the model can fetch (e.g. file contents, API responses). Register with registerResource() or resource(). Handlers typically receive a uri argument.
  • Prompts: Reusable, parameterised prompt templates the client can surface (e.g. in Claude Desktop). Register with registerPrompt() or equivalent.
  • Transport: stdio for local clients (e.g. Claude Desktop); Streamable HTTP is preferred for remote (Cursor, cloud). Legacy HTTP/SSE is for backward compatibility.

The Node/TypeScript SDK may expose tool() / resource() or registerTool() / registerResource(); the official SDK has changed over time. Always verify against the current MCP docs or Context7.

Connecting with stdio

For local clients, create a stdio transport and pass it to your server’s connect method. The exact API varies by SDK version (e.g. constructor vs factory). See the official MCP documentation or query Context7 for "MCP stdio server" for the current pattern.

Keep server logic (tools + resources) independent of transport so you can plug in stdio or HTTP in the entrypoint.

Remote (Streamable HTTP)

For Cursor, cloud, or other remote clients, use Streamable HTTP (single MCP HTTP endpoint per current spec). Support legacy HTTP/SSE only when backward compatibility is required.

Examples

Install and server setup

npm install @modelcontextprotocol/sdk zod
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

const server = new McpServer({ name: "my-server", version: "1.0.0" });

Register tools and resources using the API your SDK version provides: some versions use server.tool(name, description, schema, handler) (positional args), others use server.tool({ name, description, inputSchema }, handler) or registerTool(). Same for resources — include a uri in the handler when the API provides it. Check the official MCP docs or Context7 for the current @modelcontextprotocol/sdk signatures to avoid copy-paste errors.

Use Zod (or the SDK’s preferred schema format) for input validation.

Best Practices

  • Schema first: Define input schemas for every tool; document parameters and return shape.
  • Errors: Return structured errors or messages the model can interpret; avoid raw stack traces.
  • Idempotency: Prefer idempotent tools where possible so retries are safe.
  • Rate and cost: For tools that call external APIs, consider rate limits and cost; document in the tool description.
  • Versioning: Pin SDK version in package.json; check release notes when upgrading.

Official SDKs and Docs

  • JavaScript/TypeScript: @modelcontextprotocol/sdk (npm). Use Context7 with library name "MCP" for current registration and transport patterns.
  • Go: Official Go SDK on GitHub (modelcontextprotocol/go-sdk).
  • C#: Official C# SDK for .NET.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/mcp-server-patterns-mte1lklq' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/mcp-server-patterns-mte1lklq/download' --output '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md.part' && mv '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md.part' '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md' && test -s '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/mcp-server-patterns' && cp -R '.skill-downloads/mcp-server-patterns-mte1lklq' '.claude/skills/mcp-server-patterns'

Cursor
test -f '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md' && test -s '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/mcp-server-patterns' && cp -R '.skill-downloads/mcp-server-patterns-mte1lklq' '.cursor/skills/mcp-server-patterns'

Codex
test -f '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md' && test -s '.skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/mcp-server-patterns' && cp -R '.skill-downloads/mcp-server-patterns-mte1lklq' '.agents/skills/mcp-server-patterns'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/mcp-server-patterns-mte1lklq'

openskills read 'mcp-server-patterns-mte1lklq'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/mcp-server-patterns-mte1lklq/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills