MCP TypeScript Simple Template

Integrations

  • Provides the runtime environment for the MCP server, enabling server-side execution of the tools and communication via standard I/O.

  • Supports package management for the MCP server, allowing easy installation of dependencies and execution of build scripts.

  • Serves as the foundation for building custom MCP tools, providing type safety and structure for implementing tools that can be integrated with AI systems.

MCP TypeScript シンプルテンプレート

モデルコンテキストプロトコル(MCP)サーバーを構築するためのシンプルなTypeScriptテンプレート。このプロジェクトは、AIシステムに統合できるカスタムMCPツールを作成するための基盤を提供します。

概要

このテンプレートは、サンプルのBMI計算ツールを備えた基本的なMCPサーバーを実装します。以下の操作方法を示します。

  • TypeScriptでMCPサーバーをセットアップする
  • Zodを使用した入力検証を備えたMCPツールの定義と実装
  • 通信のためにサーバーを標準I/Oに接続する

前提条件

  • Node.js (v20以上を推奨)
  • npmまたはyarn

インストール

  1. このリポジトリをクローンする
  2. 依存関係をインストールします:
npm install

プロジェクト構造

  • index.ts - サンプルツールを使用したメインサーバーの実装
  • package.json - プロジェクトの依存関係とスクリプト
  • tsconfig.json - TypeScript 設定

使用法

構築と実行

サーバーをビルドして起動します。

npm start

これにより、TypeScript コードがコンパイルされ、MCP サーバーが起動します。

発達

開発の場合、次のことが可能です。

  1. index.tsを修正して独自のツールを追加する
  2. ビルド コマンドを実行してコンパイルします。
npm run build

カスタムツールの作成

新しいツールを作成するには、 index.tsの次のパターンに従います。

server.tool( "your-tool-name", { // Define input schema using Zod paramName: z.string(), // Add more parameters as needed }, async ({ paramName }) => ({ content: [{ type: "text", text: "Your tool's response" }] }) );

依存関係

  • @modelcontextprotocol/sdk - コア MCP SDK
  • zod - スキーマ検証
  • dotenv - 環境変数の管理
  • typescript - TypeScript コンパイラ

ライセンス

ISC

貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

-
security - not tested
F
license - not found
-
quality - not tested

AI システムと統合できるカスタム モデル コンテキスト プロトコル サーバーを作成するための基盤であり、実装例としてシンプルな BMI 計算ツールを提供します。

  1. Overview
    1. Prerequisites
      1. Installation
        1. Project Structure
          1. Usage
            1. Building and Running
            2. Development
          2. Creating Custom Tools
            1. Dependencies
              1. License
                1. Contributing
                  ID: 50o10f60hi