MCP测试服务器架构

一个基于FastAPI的最小化、专注于测试的MCP(模型上下文协议)服务器,旨在展示清晰的架构、工具注册、验证和自动化测试。

  • by arafat-ds
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 abcde448/mcp-test-server-architecture

使用说明

MCP测试服务器架构

使用FastAPI构建的最小、以测试为重点的MCP(模型上下文协议)服务器,旨在演示干净的架构、工具注册、验证和自动化测试。


📌 概述

该项目实现了一个基本的MCP服务器,具有:

  • 明确分离关注点(服务器、工具、模式、测试)
  • 通过注册表模式执行工具
  • 输入验证和结构化错误处理
  • 使用pytest进行自动化测试

目标是为MCP风格的服务器提供一个干净且可扩展的参考架构。


🏗 项目结构

MCP测试服务器架构

使用FastAPI构建的最小、以测试为重点的MCP(模型上下文协议)服务器,旨在演示干净的架构、工具注册、验证和自动化测试。


📌 概述

该项目实现了一个基本的MCP服务器,具有:

  • 明确分离关注点(服务器、工具、模式、测试)
  • 通过注册表模式执行工具
  • 输入验证和结构化错误处理
  • 使用pytest进行自动化测试

目标是为MCP风格的服务器提供一个干净且可扩展的参考架构。


🏗 项目结构

mcp测试服务器架构/ ├── 架构/#架构注释和图表 ├── 服务器/ │ ├── main.py#FastAPI入口点 │ ├── register.py#工具注册表和执行逻辑 │ ├── config.py#服务器配置 │ ├── schemas/#Pydantic请求/响应模式 │ ├── 工具/#MCP工具(例如add_numbers、dummy_tool) │ └── tests/#基于Pytest的测试套件 pytest.ini # Pytest 配置 ├── requirements.txt#依赖关系 ├── run_tests.py#测试运行器脚本 └── README.md


⚙️ 技术栈

  • Python 3.9+
  • 快速API
  • 派丹蒂克
  • Pytest

🚀 设置和运行

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt


##Run the server
python server/main.py

🧪 Testing

##Run all tests from the project root:
python -m pytest
python -m pytest
✅ All tests are passing successfully


🎯 Key Highlights
Modular MCP server design
Tool-based execution model
Strong validation & error handling
Clean, reproducible test setup
Easy to extend with new tools


📎 Status
Architecture: Completed
Implementation: Completed
Testing: Completed (All tests passing)


Author
Md. Rabbi Hasan