Skip to main content
Glama
Rajendertyagi

MCPEvent

MCP 事件服务器 — 测试套件

针对 MCP 事件服务器(server.py、events.py、store.py、runtime.py、sources/)的功能聚焦、快速且防挂起的回归测试。

布局

test/
  run_all.py            # regression driver: isolated subprocess per file, hard 300s/file timeout
  helpers/              # lifecycle, mcp, wait, mock_http, runner — shared test support
  mcp_result.py         # SDK result normalization + safe teardown
  test_*.py             # one feature per file (the units of the suite)
  config.json           # base server config (overwritten per-test, restored after)
TEST_RUNTIME_MAP.md     # per-file server usage, harness behavior, run guidance

test/ 下的生产源代码已冻结——作为测试工作的一部分,请勿编辑 server.py、events.py、store.py、runtime.py、errors.py、client.py、config.json、requirements.txt 或 sources/*。

Related MCP server: MCP Server & Client Test Environment

运行

# Focused (preferred while debugging one feature):
python test/test_acknowledgement.py
python test/run_all.py --group fast

# Full regression (CI / release only — slow path):
python test/run_all.py
python test/run_all.py --timeout 300

参见 TEST_RUNTIME_MAP.md 了解服务器使用矩阵、有界等待策略,以及为什么在开发期间应运行聚焦测试而非完整测试。

原则

  • 除非测试需要 MCP/HTTP 边界,否则不启动服务器。 应用逻辑(存储、事件、路由、检查点/确认、后台任务、源生命周期、去重)直接针对真实对象进行测试,并采用内存存根总线。

  • 每个 D 级文件一个服务器(例外:test_errors.py / test_reconnect.py 中的重启测试,以及 test_subscriptions.py 中需要不同源配置的测试)。

  • 有界等待,无长时间固定休眠。 就绪/计数通过带超时的轮询来实现。

  • 硬超时(300 秒/文件)+ 父进程拥有的清理——运行器终止子进程的进程组,因此挂起的文件会快速失败(报告为 TIMEOUT),且其产生的任何 server.py 也会随之终止。不依赖子进程的 atexit(在硬终止后无法运行)。

已删除(请勿重新创建)

test/test_phase8.py、test/integrate_test.py——已被上述按功能划分的文件取代。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A test server implementing all features of the MCP protocol, including prompts, tools, resources, and sampling, designed for testing MCP clients rather than practical applications.
    MIT