MCP TypeScript SDK
MCP TypeScript SDK
Überblick
Das Model Context Protocol (MCP) ermöglicht es Anwendungen, LLMs auf standardisierte Weise Kontext bereitzustellen, wobei die Belange der Kontextbereitstellung von der eigentlichen LLM-Interaktion getrennt werden.
Dieses Repository enthält die TypeScript SDK-Implementierung der MCP-Spezifikation. Es läuft auf Node.js, Bun und Deno und enthält:
MCP Server-Bibliotheken (Tools/Ressourcen/Prompts, Streamable HTTP, stdio, Auth-Helfer)
MCP Client-Bibliotheken (Transporte, High-Level-Helfer, OAuth-Helfer)
Optionale Middleware-Pakete für spezifische Laufzeiten/Frameworks (Express, Fastify, Hono, Node.js HTTP)
Ausführbare Beispiele (unter
examples/)
Pakete
Dieses Monorepo veröffentlicht aufgeteilte Pakete:
@modelcontextprotocol/server: MCP-Server erstellen@modelcontextprotocol/client: MCP-Clients erstellen
Tool- und Prompt-Schemata verwenden Standard Schema – bringen Sie Zod v4, Valibot, ArkType oder eine beliebige kompatible Bibliothek mit.
Sie sind bewusst dünne Adapter: Sie sollten keine neue MCP-Funktionalität oder Geschäftslogik einführen. Siehe packages/middleware/README.md für Details.
@modelcontextprotocol/node: Node.js Streamable HTTP-Transport-Wrapper fürIncomingMessage/ServerResponse@modelcontextprotocol/express: Express-Helfer (App-Standardeinstellungen + Host-Header-Validierung)@modelcontextprotocol/fastify: Fastify-Helfer (App-Standardeinstellungen + Host-Header-Validierung)@modelcontextprotocol/hono: Hono-Helfer (App-Standardeinstellungen + JSON-Body-Parsing-Hook + Host-Header-Validierung)
Installation
Server
npm install @modelcontextprotocol/server
# or
bun add @modelcontextprotocol/server
# or
deno add npm:@modelcontextprotocol/serverClient
npm install @modelcontextprotocol/client
# or
bun add @modelcontextprotocol/client
# or
deno add npm:@modelcontextprotocol/clientOptionale Middleware-Pakete
Das SDK veröffentlicht auch optionale „Middleware“-Pakete, die Ihnen helfen, MCP mit einer bestimmten Laufzeit oder einem Web-Framework zu verbinden (z.B. Express, Fastify, Hono oder Node.js http).
Diese Pakete sind bewusst dünne Adapter und sollten keine zusätzlichen MCP-Funktionen oder Geschäftslogik einführen. Siehe packages/middleware/README.md für Details.
# Node.js HTTP (IncomingMessage/ServerResponse) Streamable HTTP transport:
npm install @modelcontextprotocol/node
# Express integration:
npm install @modelcontextprotocol/express express
# Fastify integration:
npm install @modelcontextprotocol/fastify fastify
# Hono integration:
npm install @modelcontextprotocol/hono honoErste Schritte
So sieht ein MCP-Server aus. Dieses minimale Beispiel stellt ein einzelnes greet-Tool über stdio bereit:
import { McpServer } from '@modelcontextprotocol/server';
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
import * as z from 'zod/v4';
const server = new McpServer({ name: 'greeting-server', version: '1.0.0' });
server.registerTool(
'greet',
{
description: 'Greet someone by name',
inputSchema: z.object({ name: z.string() })
},
async ({ name }) => ({
content: [{ type: 'text', text: `Hello, ${name}!` }]
})
);
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main();Bereit, etwas Reales zu bauen? Folgen Sie den Schritt-für-Schritt-Tutorials:
Erstellen Sie Ihren ersten Server – ein stdio-Wetterwarn-Server, von
npm initbis zu einem Tool-AufrufErstellen Sie Ihren ersten Client – verbinden Sie sich mit diesem Server, listen Sie seine Tools auf und rufen Sie sie auf
Für ausführbare, durchgängige Beispiele über die Tutorials hinaus, siehe:
examples/README.md– ausführbare, sich selbst verifizierende Client/Server-Beispielpaare (eine Geschichte pro Verzeichnis)
Dokumentation
Einen Server erstellen – Ihr erster MCP-Server, Schritt für Schritt
Einen Client erstellen – Ihr erster MCP-Client, Schritt für Schritt
Dokumentationsseite – die vollständigen Anleitungen: Tools, Ressourcen, Prompts, Bereitstellung über HTTP und stdio, Clients, OAuth und Migration
Fehlerbehebung – häufige Fehler und deren Behebungen
Dokumentation lokal erstellen
Um lokal an der Dokumentationsseite zu arbeiten:
pnpm docs:api # Generate the API reference markdown (output: docs/api/)
pnpm docs:dev # Start the VitePress dev server for the V2 site
pnpm docs:build # Build the V2 site (output: docs/.vitepress/dist/)
pnpm docs:multi # Build the combined V1 + V2 site (output: tmp/docs-combined/)This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP (Model Context Protocol) server for Appwrite
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dilipbaviskar/mcp-server-sdk-typescript'
If you have feedback or need assistance with the MCP directory API, please join our Discord server