Skip to main content
Glama
flamekk

MCP Streamable HTTP Demo

by flamekk

TP5 MCP Streamable HTTP デモ

このプロジェクトは、以下のデモ目的を再現します。

  • 2つのツールを公開する MCP サーバー。

  • @modelcontextprotocol/inspector によるテスト。

  • Streamable HTTP 経由で MCP を使用する LangChain/LangGraph 互換エージェント。

  • Streamable HTTP 経由で MCP を使用する n8n AI エージェントのセットアップ。

重要なセキュリティ上の注意

プロンプトに貼り付けられた OpenAI キーがチャットで公開されました。エージェントを実行する前に、そのキーを無効化し、新しいキーを作成してください。新しいキーは .env に記述し、コミットしないでください。

Related MCP server: SampleMCP

セットアップ

Copy-Item .env.example .env
npm install

.env を編集し、以下を設定します。

OPENAI_API_KEY=your_new_key

MCP サーバーの起動

npm run server

MCP エンドポイントは以下の通りです。

http://127.0.0.1:3000/mcp

ヘルスチェックエンドポイントは以下の通りです。

http://127.0.0.1:3000/health

MCP Inspector によるテスト

1つのターミナルでサーバーを実行し続けます。

npm run server

別のターミナルで、Inspector CLI を使用してツールを一覧表示します。

npm run inspector:list-tools

Windows では、現在の Inspector CLI は正しい JSON レスポンスを出力した後に Node/libuv のアサーションで終了する場合があります。calculate と text_stats を含む tools JSON が表示されていれば、MCP 呼び出し自体は成功しています。

Inspector CLI でツールを呼び出します。

npx --yes @modelcontextprotocol/inspector --cli http://127.0.0.1:3000/mcp --transport http --method tools/call --tool-name calculate --tool-arg operation=add --tool-arg "numbers=[2,3,4]"

Inspector UI を開くこともできます。

npm run inspector

次に、以下を選択します。

Transport: Streamable HTTP
URL: http://127.0.0.1:3000/mcp

ローカルスモークテスト

npm run smoke

これにより、MCP ツールが一覧表示され、calculate が呼び出されます。

LangChain エージェント

サーバーが実行されており、.env に有効で更新された OPENAI_API_KEY が含まれていることを確認してください。

npm run agent

カスタムプロンプト:

npm run agent -- "Calcule 42 / 6 puis analyse le texte: Bonjour depuis MCP."

n8n エージェント

docs/n8n-agent.md に従ってください。

n8n MCP クライアントツールの設定は以下の通りです。

Endpoint: http://127.0.0.1:3000/mcp
Server Transport: HTTP Streamable
Authentication: None
Tools to Include: All

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A Python-based MCP server demonstrating basic math and text tools, supporting both SSE and STDIO transports for integration with AI assistants like Cline in VS Code.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides math and weather tools accessible via LangGraph agent using MCP protocol with stdio and streamable HTTP transports.
    1
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A calculator MCP server providing add and subtract tools, along with file resources and a code review prompt, supporting in-memory, HTTP, and STDIO transports. It also includes a LangGraph ReAct agent example that uses the tools.
    -