mcp-explorer

mcp-explorer

A controllable, observable MCP server for dynamically setting tools and intercepting calls in real time, useful as a mock/MITM harness for testing MCP clients.

Category
访问服务器

README

mcp-explorer

A controllable, observable MCP server. It speaks the Model Context Protocol to real MCP clients (Claude, MCP Inspector, your own client), but its behavior is driven entirely at runtime by you over a REST API + SSE stream:

  • Dynamically set the tools exposed to a given MCP client — per session, with a global default. Changing a session's tools pushes tools/list_changed so the client re-fetches.
  • Observe tool calls in real time and set the response before it returns — either from a preset (canned response, optional simulated latency/errors) or a live human-in-the-loop reply while the call blocks.

Useful as a mock / MITM harness for testing how MCP clients behave against arbitrary tool sets and arbitrary responses, without writing a bespoke server.

Architecture

              ┌──────────────────────── FastAPI app ────────────────────────┐
 MCP client ──┤  /mcp         Streamable HTTP (stateful)  → low-level Server  │
 (Inspector)  │  /api/*       REST control plane           → SessionRegistry  │
              │  /api/events  SSE event stream             → EventBus         │
              └──────────────────────────────────────────────────────────────┘
 controller ──(REST: set tools, respond)──┘        controller ──(SSE: watch)──┘
  • Sessions are distinguished by the Mcp-Session-Id the server assigns on initialize (stateful Streamable HTTP). All state is in-memory in one process.
  • Built on the MCP Python SDK v2 low-level Server (arbitrary JSON-schema tools, per-session tool lists) — see src/mcp_explorer/mcp_server.py.

Run

uv run mcp-explorer            # serves on http://127.0.0.1:8000

Config via env vars: MCP_EXPLORER_HOST, MCP_EXPLORER_PORT, MCP_EXPLORER_TIMEOUT_S (live-response timeout, default 300s), MCP_EXPLORER_MODE (manual | auto), MCP_EXPLORER_API_TOKEN (optional bearer token guarding /api/*).

  • MCP endpoint: http://127.0.0.1:8000/mcp
  • REST + SSE: http://127.0.0.1:8000/api/... (OpenAPI docs at /docs)
  • Web dashboard: http://127.0.0.1:8000/live

Web dashboard

Open http://127.0.0.1:8000/live for a dependency-free (vanilla HTML/CSS/JS) dashboard that uses the REST + SSE APIs: watch the live event stream, see connected sessions (each gets a friendly auto-assigned adjective-animal name, which you can override), edit the tool set (global or per-session), toggle a session's mode, set presets, and answer blocked tool calls inline.

The UI is fully stream-driven — it does not poll. It fetches state once on load, then updates reactively from the SSE stream: pending-call counts come straight from tool-call events, and structural changes (a session connecting, or tools/mode/preset changes — the latter emit a session_updated event) trigger a single authoritative resync. It also resyncs whenever the EventSource reconnects. Because browsers can't attach headers to an EventSource, the live stream assumes MCP_EXPLORER_API_TOKEN is unset (the default).

Quick start

# 1. start the server
uv run mcp-explorer

# 2. define a default tool set
uv run python examples/set_tools.py

# 3. connect a client, e.g. the MCP Inspector
npx @modelcontextprotocol/inspector    # point it at http://127.0.0.1:8000/mcp

# 4. watch calls and answer them live
uv run python examples/respond_live.py

Interception modes

Each session has a mode (default from MCP_EXPLORER_MODE):

  • manual — a tool call blocks until either a matching preset exists or you POST a live response; if neither arrives within the timeout it returns an error.
  • auto — a call with a preset returns it immediately; a call without a preset returns a fast "no preset configured" error instead of blocking.

Presets always take precedence over blocking, in either mode.

REST API

Method & path Purpose
GET /api/healthz Liveness.
GET /api/sessions List active sessions.
GET /api/sessions/{sid} Session detail.
PUT /api/sessions/{sid}/name Rename a session (human-readable label).
PUT /api/tools Set the global default tool set.
PUT /api/sessions/{sid}/tools Set tools for one session (→ list_changed).
DELETE /api/sessions/{sid}/tools Revert a session to the default tool set.
PUT /api/sessions/{sid}/mode Set manual / auto.
PUT /api/sessions/{sid}/tools/{name}/preset Set/replace a preset response.
DELETE /api/sessions/{sid}/tools/{name}/preset Remove a preset.
GET /api/sessions/{sid}/pending Calls currently awaiting a response.
POST /api/calls/{call_id}/respond Resolve a blocked call with a live payload.
GET /api/events SSE stream (optional ?session_id= filter).

Tool definitions (ToolDef) carry a raw JSON Schema in input_schema, so you can expose any tool shape. Responses (PresetResponse / live RespondPayload) accept text (single text block) or content (list of MCP content blocks), structured_content, and is_error; presets also accept delay_s.

Events

SSE emits: session_created, session_closed, tools_updated, tool_call_started, tool_call_awaiting_response, tool_call_completed, tool_call_timeout — each with type, session_id, timestamp, and data.

Tests

uv run pytest

tests/test_end_to_end.py boots a real server and drives it with a real MCP client to exercise dynamic tools, live interception, presets, and timeouts.

Notes / limitations

  • Single-process, in-memory state. Horizontal scaling would need shared state + sticky sessions (out of scope).
  • tools/list_changed requires the client to hold its stream open; modern protocol clients (e.g. the Inspector) do.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选