Skip to main content
Glama

Hello World MCP Server

by jageenshukla

Hello World MCP サーバー

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

このプロジェクトは、ブログ記事「TypeScript MCPサーバーの構築:既存サービスの統合ガイド」の一部です。このプロジェクトの背景にあるコンセプトや実装の詳細については、ブログをご覧ください。


特徴

  • 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


プロジェクト構造

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

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

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


関連プロジェクト


貢献

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


ライセンス

このプロジェクトはMITライセンスの下で提供されています。詳細はLICENSEファイルをご覧ください。

-
security - not tested
A
license - permissive license
-
quality - not tested

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

  1. 特徴
    1. 前提条件
      1. はじめる
        1. リポジトリのクローンを作成する
        2. 依存関係をインストールする
        3. 環境変数を設定する
        4. プロジェクトをビルドする
        5. サーバーを実行する
      2. サーバーのテスト
        1. MCPインスペクターの使用
      3. プロジェクト構造
        1. トラブルシューティング
          1. よくある問題
          2. デバッグ
        2. 関連プロジェクト
          1. 貢献
            1. ライセンス

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
                Last updated -
                3
                9
                36
                JavaScript
                Apache 2.0
              • -
                security
                A
                license
                -
                quality
                MCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.
                Last updated -
                4
                3
                TypeScript
                MIT License
              • -
                security
                A
                license
                -
                quality
                MCP Server provides a simpler API to interact with the Model Context Protocol by allowing users to define custom tools and services to streamline workflows and processes.
                Last updated -
                13
                2
                TypeScript
                MIT License
              • -
                security
                -
                license
                -
                quality
                A specialized server that helps users create new Model Context Protocol (MCP) servers by providing tools and templates for scaffolding projects with various capabilities.
                Last updated -
                1
                TypeScript

              View all related MCP servers

              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/jageenshukla/hello-world-mcp-server'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server