Skip to main content
Glama
dilipbaviskar

MCP TypeScript SDK

MCP TypeScript SDK

概要

Model Context Protocol (MCP) は、アプリケーションが LLM にコンテキストを提供するための標準化された方法を提供し、コンテキストの提供と実際の LLM インタラクションの関心事を分離します。

このリポジトリには、MCP 仕様の TypeScript SDK 実装が含まれています。Node.jsBunDeno で動作し、以下を提供します:

  • 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();

実際のものを作る準備はできましたか?ステップバイステップのチュートリアルに従ってください:

チュートリアル以外の実行可能なエンドツーエンドの例については、以下を参照してください:

  • examples/README.md — 実行可能で自己検証可能なクライアント/サーバーの例のペア(ディレクトリごとに1つのストーリー)

ドキュメント

ドキュメントをローカルでビルドする

ドキュメントサイトをローカルで作業するには:

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/)
-
license - not tested
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

View all MCP Connectors

Latest Blog Posts

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