mcp-server-base
MCP Server Base v2.0 — スケールと運用性 (2026)
最新スタックを使用したモダンな Model Context Protocol サーバー:
MCP SDK
1.12+—McpServer高レベル API +StreamableHTTPServerTransport(新規) &StdioServerTransportTypeScript 5.7 ESM +
NodeNextモジュールZod バリデーション → 自動 JSON Schema + 環境変数バリデーション (
src/config.ts:1)Express 4 + helmet + CORS 許可リスト + レート制限 + health/ready + Admin UI
デュアルトランスポート: STDIO (Claude Desktop) と Streamable HTTP (リモート、2025-03 仕様、ステートレス + RedisEventStore によるステートフル再開)
構造化されたツール/リソース/プロンプトモジュール + RAG (ローカルベクター)、Web (キャッシュ付き)、GitHub 統合
OTEL トレーシング/メトリクス (
src/utils/otel.ts:1)、Tasks (実験的 +create_task)、k6 ロードテストtsxwatch、vitest(130 テスト、91% カバレッジ)、グレースフルシャットダウン、docker-compose(redis、postgres、qdrant)
🚀 クイックスタート
npm install
npm run build
# STDIO (for Claude Desktop, Cursor, opencode, etc.)
npm start
# HTTP (Streamable HTTP - latest)
npm run start:http
# → http://localhost:3000/mcp
# → health http://localhost:3000/health開発
npm run dev # stdio watch
npm run dev:http # http watch (Streamable HTTP at http://localhost:3000/mcp)
npm test # unit + e2e (InMemory + HTTP)
npm run test:coverage # coverage 80% thresholds
npm run lint # eslint 9 flat config
npm run format:check # prettier
npm run typecheck # tsc --noEmit
npm run buildCI
.github/workflows/ci.yml は push/PR で main に対して、Node 20+22 のマトリックスで実行されます: lint、format:check、typecheck、test:coverage、build、docker build。
Related MCP server: MCP Server
🔌 トランスポート
トランスポート | 用途 | コマンド |
STDIO | ローカルクライアント (Claude Desktop) |
|
Streamable HTTP | リモート / Docker / クラウド |
|
Streamable HTTP は、SSE (2025年3月に廃止) に代わる新しい標準です。
🧰 ツール (31)
ツール | 説明 | 入力 | ||||
| メッセージをエコー |
| ||||
| 加算/減算/乗算/除算 |
| ||||
| 現在時刻 |
| ||||
| URL取得 |
| ||||
| ALLOWED_ROOT 配下のファイルを一覧表示 |
| ||||
| ファイルを読み込む (1MB 制限) |
| ||||
| ファイルに書き込み + リソース変更を通知 |
| ||||
| ファイル内のテキストを検索 |
| ||||
| メモリにKVを設定 |
| ||||
| KVを取得 |
| ||||
| KVを削除 |
| ||||
| KV一覧を表示 | — | ||||
| すべてクリア | — | ||||
| alasql による SQL (users、notes) |
| ||||
| テーブルの行数を一覧表示 | — | ||||
| シェル (許可リスト、デフォルト無効) |
| ||||
| 引き出しデモ (連絡先/プリファレンス) |
| ||||
| サンプリングデモ (LLM) |
| ||||
| テキストを取り込む (チャンク化、埋め込み) |
| ||||
| ベクタ検索 (コサイン類似度) |
| ||||
*rag_list` | ディジドキュメントを一覧 | — | ||||
*rag_clear` | ベクタストアをクリア | — | ||||
| Brae API (キーがなければモック) |
| ||||
| Tavily API(キーがなければモック) |
| ||||
| キャッシュ付き Web 取得 |
| ||||
| GitHub リポジトを検索 |
|
| GitHub リポジトを取得 |
| |
| GitHub issue を取得 |
|
| バックグラウンドタスクを作成 |
| |
| タスク状態を取得 |
| ||||
| タスク結果を取得 |
|
📦 リソース (6)
config://server-info— サーバーメタデータ (JSON、featuresを含むようになりました)greeting://{name}— 動的挨拶テンプレートfile:///{+path}— サンドボックス化されたファイル (ALLOWED\_ROOT)、一覧表示 + 補完、file:///notes.txtmemory://{key}— メモリ KV、一覧表示 + 補完db://{table}/{id}— デモ用 DB レコード (users/notes)、一覧表示 + 補完docs://{id}— RAG チャンク (rag_ingestで取り込んだもの)、一覧表示 + 補完
💬 プロンプト (4)
code-review— 引数:language、codeexplain-concept— 引数:concept、levelsummarize— 引数:text、length(short/medium/long)、style(bullets/paragraph/tldr)research— 引数:topic、depth(overview/deep)、audience(beginner/expert/executive)
⚙️ クライアント設定
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"mcp-server-base": {
"command": "node",
"args": ["/absolute/path/to/mcp-server/dist/index.js"]
}
}
}HTTP クライアント
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
const client = new Client({ name: 'my-client', version: '1.0.0' });
await client.connect(new StreamableHTTPClientTransport(new URL('http://localhost:3000/mcp')));
const tools = await client.listTools();Inspector
npm run inspect
# or
npx @modelcontextprotocol/inspector node dist/index.js
npx @modelcontextprotocol/inspector http://localhost:3000/mcp🐳 Docker
# Single container
docker build -t mcp-server-base .
docker run -p 3000:3000 --env TRANSPORT=http mcp-server-base
# Full stack (app + redis + postgres + qdrant) — see docker-compose.yml
docker compose up -d
docker compose logs -f app
# → http://localhost:3000/health, http://localhost:3000/mcp
# → redis :6379, postgres :5432, qdrant :6333RAG デモ (取り込み → 検索 → docs://)
# via MCP tools (Inspector or Client)
# 1. ingest
rag_ingest { "text": "MCP is Model Context Protocol...", "id": "mcp-intro" }
# 2. search
rag_search { "query": "what is MCP?", "topK": 3 }
# 3. read resource
# docs://mcp-intro → returns ingested text📁 構造
src/
├── index.ts # entry: stdio + http (helmet/cors/rateLimit/auth/resumability)
├── server.ts # createMcpServer() factory
├── config.ts # zod env (AUTH, CORS, rateLimit, RAG, cache, integrations)
├── types.ts # Zod schemas
├── middleware/auth.ts # AUTH_MODE none|apiKey|bearer
├── middleware/rateLimit.ts
├── middleware/requestId.ts
├── utils/logger.ts # stderr, JSON/text, redaction, child(requestId)
├── utils/eventStore.ts # InMemoryEventStore for Last-Event-ID
├── utils/cache.ts # MemoryCache (TTL) + defaultCache
├── utils/queue.ts # SimpleQueue
├── tools/ # 31 tools: echo, fs, memory, db, shell, rag, web, github, elicitation, sampling, tasks
│ ├── filesystem.tool.ts, memory.tool.ts, database.tool.ts, shell.tool.ts
│ ├── rag.tool.ts, web.tool.ts, github.tool.ts, elicitation.tool.ts, sampling.tool.ts, tasks.tool.ts
├── resources/ # 6 resources: config, greeting, file, memory, db, docs
├── routes/admin.ts # Admin UI + metrics + spans
└── prompts/ # 4 prompts: code-review, explain-concept, summarize, research新しいツールを追加するには: src/tools/my.tool.ts を作成 → registerMyTool(server) をエクスポート → src/tools/index.ts に追加。
🔐 セキュリティ (Phase 2)
helmet ヘッダー (
x-dns-prefetch-control、x-frame-options、x-content-type-optionsなど) をhelmet@7で設定 (src/index.ts:1)CORS 許可リスト (
CORS\_ORIGIN=*またはカンマ区切りリスト) とcors認証情報処理 (src/config.ts:60)認証
AUTH\_MODE=none|apiKey|bearerをsrc/middleware/auth.ts:1で設定 — 有効なX-API-KeyまたはAuthorization: Bearerがない場合401(health/ready と OPTIONS は除外)レート制限
express-rate-limit(デフォルト 100回/15分) を/mcpに適用 —429 Too Many Requests(src/middleware/rateLimit.ts:1)RequestId (
X-Request-Idに randomUUID、ヘッダーでエコー、子ロガーで相関付け) (src/middleware/requestId.ts:1)Zod 環境変数バリデーション (
src/config.ts:1) —parseEnv()がPORT、AUTH\_MODE、API\_KEYをフィールド横断で検証し、無効な環境変数があれば即座に失敗構造化ロガー JSON/テキスト対応、
authorization、apiKey、tokenは[REDACTED]に秘匿 (src/utils/logger.ts:24)再開可能性
InMemoryEventStore(src/utils/eventStore.ts:1) +RESUMABILITY\_ENABLED=trueのときのステートフルセッションマップ (Last-Event-IDによるリプレイ、GET /mcpストリーム、DELETEでクローズ)Docker の堅牢化 非 root の
appuser+HEALTHCHECK(Dockerfile:1)テスト:
tests/unit/auth.test.ts、tests/unit/logger.test.ts、tests/unit/eventStore.test.ts、tests/e2e/security.test.ts(helmet/auth/rateLimit/resumability) —67 tests → 130 total with Phase 5, 90.89%
🔗 インテグレーション (Phase 4)
キャッシュ
MemoryCacheTTL (src/utils/cache.ts:1) — web/github 用のdefaultCache、SimpleQueue(src/utils/queue.ts:1)RAG ローカルベクタ (ハッシュ埋め込み 128次元、コサイン類似度、チャンク 500/50) (
src/tools/rag.tool.ts:1) —rag_ingest(チャンク化 +sendResourceListChanged)、rag_search(topK、threshold)、rag_list、rag_clear+docs://{id}リソースWeb (
src/tools/web.tool.ts:1) —brave_search(BRAVE\_API\_KEYがない場合はモック)、tavily_search(モック)、web_fetch(defaultCache、CACHE\_MAX\_MSによるキャッシュ付き)GitHub (
src/tools/github.tool.ts:1) —github_search_repos、github_get_repo、github_get_issue(キャッシュ付き、summaryTokenで API レート制限対策)スタック (
docker-compose.yml:1) — app + redis:7 + postgres:16 + qdrant:v1.0.0 にヘルスチェック付きデモ
rag_ingest → rag→ docs://E2E をtests/integrations.test.ts:1(21 件) で検証
📈 スケールと運用性 (Phase 5 — v2.0)
バージョン化された MCP
v2.0.0(package.json:1、config.MCP\_SERVER\_VERSION) 各マイナー向けの説明付き (src/server.ts:1)OTEL トレーシング/メトリクス (
src/utils/otel.ts:1) —createSpan/withSpan、incrementCounter/recordHistogram、getMetrics/getSpans、OTEL\_EXPORTER\_OTLP\_ENDPOINT用の JSON エクスポートスタブ、OTEL\_フラグRedisEventStore (
src/utils/redisEventStore.ts:1) —storeEvent/replayEventsAfterを持つEventStore実装、インメモリフォールバック、水平スケール用eventStoreFactory.create()(EVENT\_STORE\_TYPE=memory|redis、REDIS\_URL)Admin UI (
src/routes/admin.ts:1) —GET /admin(HTML ダッシュボード)、/admin/tools|resources|prompts|metrics|spans|stores|health(JSON)、ADMIN\_TOKEN(X-Admin-Token) で保護、ADMIN\_ENABLEDフラグタスク (
src/tools/tasks.tool.ts:1) — 実験的なdelay_task(SDK タスクが利用可能な場合) + フォールバックcreate_task/get_task/get_task_result(インメモリ、ポーリング)、SimpleQueue/MemoryCache基盤ベンチマーク (
k6/load.js:1) —http_req_duration_ratiop(95) <100ms、stages10→50 VUs、checks >99%、npm run bench/bench:localCompose (
docker-compose.yml:1) — スケール用に redis/postgres/qdrant を既に内包テスト:
tests/scale.test.ts:1(OTEL spans/metrics、RedisEventStore リプレイ、キャッシュ TTL、キュー、admin HTML/metrics/token/ready、タスクの create/poll、バージョン、k6 スクリプト) — 合計 130 件デプロイ — Fly.io/Cloud Run 対応 (ステートレス + RedisEventStore)、
release.yml経由で GHCR、npm2.0.0ロガーは stderr で安全に動作し、シークレットを一切ログに記録しない (秘匿化)
Zod → JSON Schema を SDK 経由で生成 (
src/types.ts:1、src/tools/*.tool.ts)fetch のタイムアウト (10 秒) + 構造化エラー
グレースフルシャットダウン (
SIGINT/SIGTERM)ヘルスチェック (
GET /health) と readiness (GET /ready) を MCP と分離デフォルトはステートレス (
sessionIdGenerator: undefined)、RESUMABILITY\_ENABLED=trueのときはステートフル (src/index.ts:22)型安全な厳格 TS + ESLint flat + Prettier + husky + lint-staged
カバレッジ 行 85% / ブランチ 70% を強制 (
vitest.config.ts:1)、130 件のテスト: 単体 + e2e HTTP/セキュリティ/機能/インテグレーション/スケール
🤝 コントリビューション
CONTRIBUTING.md を参照してください — nvm use、npm test、ツール/リソース/プロンプトの追加、lint/typecheck/test が通ることを確認してください。CODE_OF_CONDUCT.md も参照してください。
📚 MCP ドキュメント
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
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that supports STDIO, SSE and Streamable HTTP protocols for AI model interactions.131MIT
- AlicenseNot gradedqualityFmaintenanceA robust server implementing the Model Context Protocol with SSE and STDIO transport, enabling real-time communication and extensible tooling for AI models.3813MIT
- AlicenseBqualityCmaintenanceA production-packaged Model Context Protocol server for coding agents that routes large file, git, web, database, and other tasks through token-budgeted tools and workflows.6111MIT
- AlicenseNot gradedqualityCmaintenanceA production-ready Model Context Protocol suite over Streamable HTTP providing a sandboxed file server with tools, resources, prompts, and both manual and AI-driven clients.MIT
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
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/ahmedalbanna/mcp-server-base'
If you have feedback or need assistance with the MCP directory API, please join our Discord server