Simple-MCP-Server
MCP エージェント宿題
MCP_HOMEWORK_SKILL.md の課題用に構築された TypeScript 製 MCP (Model Context Protocol) システムです。Agent Skill (SKILL.md) を読み込み、3 つの必須トランスポートすべてを通じて 3 つの MCP サーバーに接続し、それらのツールを検出・集約して、Gemini が適切なサーバー上の適切なツールを選択・呼び出しできるようにする Agent Host です。
アーキテクチャ
Agent Host (src/host)
skill-loader + connection-manager
+ tool-bridge + gemini-client
|
+------------------+------------------+
| | |
v v v
stdio server local HTTP server public HTTP server
(src/servers/stdio- (src/servers/http- (same http-server.ts,
server.ts) server.ts, no auth) API-key protected)
| | |
+------------------+-------------------+
|
shared tool logic (src/servers/shared/tools.ts)
3 tools (calculator, text_stats, unit_convert) + 1 resource + 1 promptsrc/servers/shared/tools.ts— 3 つのツール、1 つのリソース、1 つのプロンプトの単一実装。すべてのサーバーに同一に登録されるため、同じロジックがどこでも再利用されます (ビジネスロジックの重複なし)。src/servers/stdio-server.ts— stdio 上の MCP (子プロセスとして起動)。src/servers/http-server.ts— Streamable HTTP 上の MCP。「ローカル」サーバーと「パブリック」サーバーの両方でまったく同じファイル/コードが実行されます。違いは設定のみです (PORT、PUBLIC_MCP_API_KEY)。src/host/connection-manager.ts— MCP ホスト: 設定されたすべてのサーバーに接続し、ツール/リソース/プロンプトを検出し、衝突を避けるためにツール名を<namespace>__<tool>として名前空間化し、ツール呼び出しを所有サーバーにディスパッチします。src/host/tool-bridge.ts— 検出された MCP ツールを Gemini の関数宣言に変換します。src/host/gemini-client.ts— Gemini のツール呼び出しループ (メッセージ送信 → 関数呼び出しの読み取り → コネクションマネージャー経由でディスパッチ → 関数レスポンスを送信 → 最終テキストが返るまで繰り返し)。src/host/skill-loader.ts— SKILL.md を読み込み、モデルのシステム指示として注入し、スキルがツールの使用方法を積極的に形成できるようにします。src/host/agent-host.ts— config/servers.json から上記を結び付けます。src/host/cli.ts— CLI エントリポイント (対話モードまたは--demo)。
Related MCP server: mcp-tools-server
セットアップ
npm installシークレットは api.env にあります (すでに gitignore 済み):
API_KEY=your-gemini-api-key
# Optional, only needed once you deploy the public server:
# PUBLIC_MCP_URL=https://your-app.onrender.com/mcp
# PUBLIC_MCP_API_KEY=some-strong-random-key各コンポーネントの実行
stdio サーバー (20 点)
npm run server:stdio # run directly
npm run inspector:stdio # open MCP Inspector against itInspector は 3 つのツール (calculator、text_stats、unit_convert)、1 つのリソース (docs://unit-conversions)、1 つのプロンプト (explain-tool-result) を検出し、それらすべてを実行/読み取りできます。
ローカル HTTP サーバー
npm run server:http # listens on http://127.0.0.1:8787/mcp, no auth
npm run inspector:http # then connect Inspector to that URLパブリック HTTP サーバー (15 点)
同じ http-server.ts は、PUBLIC_MCP_API_KEY が設定されると「パブリック」サーバーになります。以降、すべてのリクエストには一致する x-api-key ヘッダーが必要となり、キーがない場合や無効な場合は 401 Unauthorized が返ります。
$env:PORT=8788; $env:PUBLIC_MCP_API_KEY="a-strong-secret"; npm run server:http公開デプロイ (同梱の render.yaml を使用した Render.com):
git init && git add -A && git commit -m "MCP homework"を実行し、自分が所有する GitHub リポジトリにプッシュします。Render で: New + → Blueprint → リポジトリを選択 (
render.yamlを自動的に読み取ります)。または、Web Service を手動で作成します:ビルドコマンド:
npm install && npm run build開始コマンド:
npm run start:httpヘルスチェックパス:
/health
Render ダッシュボードで、
PUBLIC_MCP_API_KEY環境変数に強力なシークレットを設定します (決してコミットしないでください)。デプロイ後、取得した URL とキーを
api.envに設定します:PUBLIC_MCP_URL=https://<your-service>.onrender.com/mcpとPUBLIC_MCP_API_KEY=<same secret>。Inspector で検証します:
キーなし → 拒否:
curl -X POST https://<url>/mcp -H "Content-Type: application/json" -d "{...}"は401を返します。キーあり → 動作:
npx @modelcontextprotocol/inspector --cli <url> --method tools/listに--header "x-api-key: <secret>"を渡します。
Agent Host
npm run agent # interactive CLI
npm run agent:demo # runs a scripted set of demo queries起動時にホストは次のことを行います:
SKILL.mdをシステム指示として読み込みます。config/servers.json を読み取り、stdio サーバー (自動的に起動)、ローカル HTTP サーバー (すでに実行されている必要があります)、パブリック HTTP サーバー (
PUBLIC_MCP_URL/PUBLIC_MCP_API_KEYが設定されていない場合は自動的にスキップ — ライブデプロイがなくてもデモが動作するようにオプションです) に接続します。すべてのツールを検出して名前空間化し、Gemini に渡し、Gemini が行う各ツール呼び出しを正しい MCP サーバーにディスパッチします。
設定
サーバー登録は config/servers.json によるデータ駆動型です。ホストコードを編集する代わりに、そこでサーバーを追加/削除します。url 内の ${VAR} は接続時に process.env から解決されます。apiKeyEnv は、その値が x-api-key として送信される環境変数を指定します。
Agent Skill
SKILL.md は、エージェントに対して、算術/変換/テキスト統計を推測するよりもツールを呼び出すことを優先し、論理的なリクエストごとに 1 つの名前空間化されたツールを選択し、サポートされている変換について不明な場合は docs://unit-conversions リソースを参照し、結果を平易な言葉で説明するよう指示します。これは毎回の実行で Gemini のシステム指示にそのまま読み込まれるため (src/host/skill-loader.ts を参照)、そのルールはツールの選択と応答スタイルに直接影響します — デモ出力で確認できます (例: エージェントは算術を自分で計算せず、常にツールを呼び出します)。
セキュリティに関する注意事項
シークレットはコミットされません。
api.envは gitignore されており、パブリックサーバーは環境からPUBLIC_MCP_API_KEYのみを読み取ります。パブリック HTTP サーバーは、一致する
x-api-keyヘッダーのないリクエストを拒否し (401)、有効なキーが提供されるとリクエストを受け入れます。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseAqualityDmaintenanceA lightweight MCP server providing utility tools for math, text processing, data conversion, and URL fetching. It supports both STDIO and SSE communication modes for seamless integration with Claude Desktop and remote AI agents.51
- AlicenseNot gradedqualityBmaintenanceA general-purpose MCP server with utility tools including datetime information, safe math calculations, text statistics, JSON extraction, knowledge base search, and HTTP GET requests. It demonstrates server-side MCP implementation and can be connected to Claude Desktop or LangGraph agents.MIT
- FlicenseNot gradedqualityDmaintenanceProvides math and weather tools accessible via LangGraph agent using MCP protocol with stdio and streamable HTTP transports.1
- FlicenseNot gradedqualityDmaintenanceLocal MCP server that exposes fixed tools for GPT, Claude, and Gemini while routing to any OpenAI-compatible chat completions backend with independent configuration per target.1
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/kindinh903/Simple-MCP-Server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server