Hello World MCP Server

by jageenshukla
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Manages environment configuration for the MCP server through .env files

  • Handles HTTP endpoints for server-sent events (SSE) and message communication in the MCP server

  • Used for version control and cloning the repository to set up the MCP server

Hello World MCP サーバー

Hello World MCP Serverへようこそ!このプロジェクトでは、Model Context Protocol (MCP) SDK を使用してサーバーをセットアップする方法を説明します。サーバー送信イベント (SSE) とメッセージを処理するためのツール、プロンプト、エンドポイントが含まれています。


特徴

  • MCP 統合: MCP SDK を使用して、ツールとプロンプトを備えたサーバーを作成します。
  • Express Framework : SSE およびメッセージ通信用の HTTP エンドポイントを処理します。
  • 環境構成: .envファイルを使用して簡単に構成できます。
  • TypeScript サポート: 開発者エクスペリエンスを向上させる、完全に型付けされたコードベース。

前提条件

始める前に、以下がインストールされていることを確認してください。

  1. Node.js (v16 以上) -ここからダウンロード
  2. npm (Node.jsに付属)またはyarn

はじめる

プロジェクトをセットアップして実行するには、次の手順に従います。

1. リポジトリのクローンを作成する

まだ行っていない場合は、リポジトリをローカル マシンにクローンします。

git clone https://github.com/your-username/hello-world-mcp-server.git cd hello-world-mcp-server

2. 依存関係をインストールする

npm または yarn を使用して必要な依存関係をインストールします。

npm install

または

yarn install

3. 環境変数を設定する

このプロジェクトでは、サーバーのポートを設定するために.envファイルを使用します。サンプルの.env.exampleファイルが提供されています。

  1. .env.exampleファイルを.envにコピーします。
    cp .env.example .env
  2. .envファイルを開き、必要に応じてPORT変数を更新します。デフォルトは4000です。
    PORT=4000

4. プロジェクトをビルドする

TypeScript コードを JavaScript にコンパイルします。

npm run build

これにより、 distディレクトリにコンパイルされたファイルが生成されます。

5. サーバーを実行する

サーバーを本番モードで起動します。

npm start

あるいは、ライブリロードを使用した開発モードでは、次を使用します。

npm run dev

サーバーのテスト

1. MCPインスペクターの使用

MCP Inspectorは、MCPサーバーをテストおよび検査するためのツールです。ツールとプロンプトが正しく登録されているかどうかを確認できます。

次のコマンドを実行してサーバーを検査します。

npx @modelcontextprotocol/inspector ./dist/server.js

これにより、以下のようにサーバーに登録されているツールとプロンプトをテストできる対話型インターフェイスが開きます。


プロジェクト構造

プロジェクト構造の概要は次のとおりです。

hello-world-mcp-server/ ├── src/ │ ├── server.ts # Main server entry point │ ├── modules/ │ │ ├── tools.ts # Registers MCP tools │ │ ├── prompts.ts # Registers MCP prompts │ │ └── transports.ts # Handles SSE and message endpoints ├── .env # Environment variables ├── .env.example # Example environment variables ├── package.json # Project metadata and scripts ├── tsconfig.json # TypeScript configuration └── README.md # Project documentation

トラブルシューティング

よくある問題

  1. ポートがすでに使用されています: ポートが使用中であるというエラーが表示される場合は、 .envファイル内のPORT変数を更新します。
  2. TypeScript エラー: すべての依存関係がインストールされており、正しい Node.js バージョンを使用していることを確認してください。

デバッグ

サーバーをデバッグするには、次のコマンドを使用します。

npm run dev

これにより、ライブリロードと詳細なログを備えたサーバーが起動します。


貢献

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


ライセンス

このプロジェクトはISCライセンスに基づいてライセンスされています。詳細はLICENSEファイルをご覧ください。

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

モデル コンテキスト プロトコル (MCP) SDK を実装し、サーバー送信イベントとメッセージ処理用のツールとエンドポイントを提供するデモ サーバー。

  1. Features
    1. Prerequisites
      1. Getting Started
        1. 1. Clone the Repository
        2. 2. Install Dependencies
        3. 3. Configure Environment Variables
        4. 4. Build the Project
        5. 5. Run the Server
      2. Testing the Server
        1. 1. Using the MCP Inspector
      3. Project Structure
        1. Troubleshooting
          1. Common Issues
          2. Debugging
        2. Contributing
          1. License
            ID: 80jthm8z6d