MCP TypeScript SDK
MCP TypeScript SDK
概要
Model Context Protocol (MCP) は、アプリケーションが LLM にコンテキストを提供するための標準化された方法を提供し、コンテキストの提供と実際の LLM インタラクションの関心事を分離します。
このリポジトリには、MCP 仕様の TypeScript SDK 実装が含まれています。Node.js、Bun、Deno で動作し、以下を提供します:
MCP サーバー ライブラリ(ツール/リソース/プロンプト、Streamable HTTP、stdio、認証ヘルパー)
MCP クライアント ライブラリ(トランスポート、高レベルヘルパー、OAuth ヘルパー)
特定のランタイム/フレームワーク向けのオプションの ミドルウェアパッケージ(Express、Fastify、Hono、Node.js HTTP)
実行可能な 例(
examples/以下)
パッケージ
このモノレポは分割されたパッケージを公開しています:
@modelcontextprotocol/server: MCP サーバーを構築@modelcontextprotocol/client: MCP クライアントを構築
ツールとプロンプトのスキーマは Standard Schema を使用します — Zod v4、Valibot、ArkType、または互換性のある任意のライブラリを持ち込んでください。
これらは意図的に薄いアダプターです:新しい MCP 機能やビジネスロジックを導入すべきではありません。詳細は packages/middleware/README.md を参照してください。
@modelcontextprotocol/node:IncomingMessage/ServerResponse用の Node.js Streamable HTTP トランスポートラッパー@modelcontextprotocol/express: Express ヘルパー(アプリのデフォルト + Host ヘッダー検証)@modelcontextprotocol/fastify: Fastify ヘルパー(アプリのデフォルト + Host ヘッダー検証)@modelcontextprotocol/hono: Hono ヘルパー(アプリのデフォルト + JSON ボディ解析フック + Host ヘッダー検証)
インストール
サーバー
npm install @modelcontextprotocol/server
# or
bun add @modelcontextprotocol/server
# or
deno add npm:@modelcontextprotocol/serverクライアント
npm install @modelcontextprotocol/client
# or
bun add @modelcontextprotocol/client
# or
deno add npm:@modelcontextprotocol/clientオプションのミドルウェアパッケージ
SDK は、MCP を特定のランタイムやウェブフレームワーク(Express、Fastify、Hono、Node.js http など)に 配線する のに役立つオプションの「ミドルウェア」パッケージも公開しています。
これらのパッケージは意図的に薄いアダプターであり、追加の MCP 機能やビジネスロジックを導入すべきではありません。詳細は packages/middleware/README.md を参照してください。
# 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 honoはじめに
MCP サーバーは次のようになります。この最小限の例では、stdio 上で単一の greet ツールを公開します:
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();実際のものを作る準備はできましたか?ステップバイステップのチュートリアルに従ってください:
最初のサーバーを構築する —
npm initからツール呼び出しまでの stdio 気象警報サーバー最初のクライアントを構築する — そのサーバーに接続し、ツールを一覧表示して呼び出す
チュートリアル以外の実行可能なエンドツーエンドの例については、以下を参照してください:
examples/README.md— 実行可能で自己検証可能なクライアント/サーバーの例のペア(ディレクトリごとに1つのストーリー)
ドキュメント
サーバーを構築する — 最初の MCP サーバーをステップバイステップで
クライアントを構築する — 最初の MCP クライアントをステップバイステップで
ドキュメントサイト — 完全なガイド:ツール、リソース、プロンプト、HTTP および stdio での提供、クライアント、OAuth、移行
トラブルシューティング — 一般的なエラーとその修正
ドキュメントをローカルでビルドする
ドキュメントサイトをローカルで作業するには:
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