使用说明
MCP Bench:通过MCP服务器使用LLM代理进行复杂现实任务的基准测试工具
概述
MCP Bench是一个综合评估框架,旨在通过模型上下文协议(MCP)评估大型语言模型(LLM)在工具使用场景中的能力。该基准测试提供了一个端到端的管道,用于评估不同LLM如何有效地发现、选择和利用工具来解决现实世界的任务。
排行榜
| 排名 | 型号 | 总分 |
|---|---|---|
| 1 | gpt-5 | 0.749 |
| 2 | o3 | 0.715 |
| 3 | gpt-oss-120b | 0.692 |
| 4 | 双子座-2.5-pro | 0.690 |
| 5 | claude-connect-4 | 0.681 |
| 6 | qwen3-235b-a22b-2507 | 0.678 |
| 7 | glm-4.5 | 0.668 |
| 8 | gpt-oss-20b | 0.654 |
| 9 | 2 | 0.629 |
| 10 | qwen3-30b-a3b-指令-2507 | 0.627 |
| 11 | 双子座-2.5克拉石 | 0.598 |
| 12 | gpt-4o | 0.595 |
| 13 | 宝石-3-27b-it | 0.582 |
| 14 | 火焰-3-3-70b-指令 | 0.558 |
| 15 | gpt-4o-mini | 0.557 |
| 16 | 偏小-2503 | 0.530 |
| 17 | 火焰-3-1-70b-指令 | 0510 |
| 18 | 新千伏1 | 0.508 |
| 19 | Calma-3-2-90b-Vision-Instruct | 0495 |
| 20 | 火焰-3-1-8b-指令 | 0.428 |
总体得分代表了所有评估维度的平均表现,包括基于规则的模式理解、LLM判断的任务完成、工具使用和规划有效性。分数在单服务器和多服务器设置中平均。
快速开始
安装
- 克隆存储库
git clone https://github.com/accenture/mcp-bench.git
cd mcp-bench
- 安装依赖项
conda create -n mcpbench python=3.10
conda activate mcpbench
cd mcp_servers
# Install MCP server dependencies
bash ./install.sh
cd ..
- 设置环境变量
# Create .env file with API keys
# Default setup uses both OpenRouter and Azure OpenAI
# For Azure OpenAI, you also need to set your API version in file benchmark_config.yaml (line205)
# For OpenRouter-only setup, see "Optional: Using only OpenRouter API" section below
cat > .env << EOF
export OPENROUTER_API_KEY="your_openrouterkey_here"
export AZURE_OPENAI_API_KEY="your_azureopenai_apikey_here"
export AZURE_OPENAI_ENDPOINT="your_azureopenai_endpoint_here"
EOF
- 配置MCP服务器API密钥
一些MCP服务器需要外部API密钥才能正常工作。这些密钥是从以下位置自动加载的 ./mcp_servers/api_key。你应该在文件中自己设置这些密钥 ./mcp_servers/api_key:
# View configured API keys
cat ./mcp_servers/api_key
所需的API密钥包括(这些API密钥免费且易于获取。您可以在10分钟内获取所有密钥):
NPS_API_KEY:国家公园管理局API密钥(用于国家公园服务器)- 获取API密钥NASA_API_KEY:NASA开放数据API密钥(用于NASA-mcp服务器)- 获取API密钥HF_TOKEN:拥抱脸令牌(用于拥抱脸mcp服务器)- 获取令牌GOOGLE_MAPS_API_KEY:谷歌地图API密钥(适用于mcp-Google-map服务器)- 获取API密钥NCI_API_KEY:国家癌症研究所API密钥(用于biomcp服务器)- 获取API密钥
基本用法
# 1. Verify all MCP servers can be connected
##You should see "28/28 servers connected"
##and "All successfully connected servers returned tools!" after running this
python ./utils/collect_mcp_info.py
# 2. List available models
source .env
python run_benchmark.py --list-models
# 3. Run benchmark (gpt-oss-20b as an example)
## run all tasks
source .env
python run_benchmark.py --models gpt-oss-20b
## single server tasks
source .env
python run_benchmark.py --models gpt-oss-20b \
--tasks-file tasks/mcpbench_tasks_single_runner_format.json
## two server tasks
source .env
python run_benchmark.py --models gpt-oss-20b \
--tasks-file tasks/mcpbench_tasks_multi_2server_runner_format.json
## three server tasks
source .env
python run_benchmark.py --models gpt-oss-20b \
--tasks-file tasks/mcpbench_tasks_multi_3server_runner_format.json
可选:添加其他模型提供程序
要从OpenRouter添加新模型,请执行以下操作:
-
在OpenRouter上查找您的型号
- 访问 OpenRouter型号 浏览可用型号
- 复制模型ID(例如。,
anthropic/claude-sonnet-4或meta-llama/llama-3.3-70b-instruct)
-
添加模型配置
- 编辑
llm/factory.py并在OpenRouter部分(第152行附近)添加您的模型 - 遵循以下模式:
configs["your-model-name"] = ModelConfig( name="your-model-name", provider_type="openrouter", api_key=os.getenv("OPENROUTER_API_KEY"), base_url="https://openrouter.ai/api/v1", model_name="provider/model-id" # The exact model ID from OpenRouter ) - 编辑
-
验证模型是否可用
source .env python run_benchmark.py --list-models # Your new model should appear in the list -
使用您的模型运行基准测试
source .env python run_benchmark.py --models your-model-name
可选:仅使用OpenRouter API
如果你只想在没有Azure的情况下使用OpenRouter:
- 仅使用OpenRouter设置.env文件:
cat > .env << EOF
OPENROUTER_API_KEY=your_openrouterkey_here
EOF
- 修改代码以通过OpenRouter访问Azure模型:
编辑 llm/factory.py 并注释掉Azure部分(第69-101行),然后通过OpenRouter添加Azure模型:
# Comment out or remove the Azure section (lines 69-109)
# if os.getenv("AZURE_OPENAI_API_KEY") and os.getenv("AZURE_OPENAI_ENDPOINT"):
# configs["o4-mini"] = ModelConfig(...)
# ...
# Add Azure models through OpenRouter (in the OpenRouter section around line 106)
if os.getenv("OPENROUTER_API_KEY"):
# Add OpenAI models via OpenRouter
configs["gpt-4o"] = ModelConfig(
name="gpt-4o",
provider_type="openrouter",
api_key=os.getenv("OPENROUTER_API_KEY"),
base_url="https://openrouter.ai/api/v1",
model_name="openai/gpt-4o"
)
configs["gpt-4o-mini"] = ModelConfig(
name="gpt-4o-mini",
provider_type="openrouter",
api_key=os.getenv("OPENROUTER_API_KEY"),
base_url="https://openrouter.ai/api/v1",
model_name="openai/gpt-4o-mini"
)
configs["o3"] = ModelConfig(
name="o3",
provider_type="openrouter",
api_key=os.getenv("OPENROUTER_API_KEY"),
base_url="https://openrouter.ai/api/v1",
model_name="openai/o3"
)
configs["o4-mini"] = ModelConfig(
name="o4-mini",
provider_type="openrouter",
api_key=os.getenv("OPENROUTER_API_KEY"),
base_url="https://openrouter.ai/api/v1",
model_name="openai/o4-mini"
)
configs["gpt-5"] = ModelConfig(
name="gpt-5",
provider_type="openrouter",
api_key=os.getenv("OPENROUTER_API_KEY"),
base_url="https://openrouter.ai/api/v1",
model_name="openai/gpt-5"
)
# Keep existing OpenRouter models...
通过这种方式,所有模型都将通过OpenRouter的统一API访问。
MCP服务器
MCP Bench包括28个不同的MCP服务器:
- 生物MCP -生物医学研究数据、临床试验和健康信息
- 书目 -《易经》中的占卜、卦和神秘指引
- 征稿 -学术会议提交和电话公告
- 汽车价格评估员 -汽车估值和汽车市场分析
- 背景7 -项目背景管理和文件服务
- DEX辣椒粉 -加密货币DeFi分析和去中心化交易数据
- 水果副 -全面的水果营养信息和饮食数据
- 游戏趋势 -游戏行业统计和趋势分析
- 谷歌地图 -位置服务、地理编码和地图功能
- 巨大的图标 -图标搜索、管理和设计资源
- 拥抱脸 -机器学习模型、数据集和人工智能能力
- 数学MCP -数学计算和计算操作
- 医疗计算器 -临床计算工具和医学公式
- 纽约大都会博物馆 -艺术收藏数据库和博物馆信息
- 电影推荐 -电影推荐和电影元数据
- 美国国家航空航天局数据 -空间任务数据和天文信息
- 国家公园 -美国国家公园信息和游客服务
- NixOS -包管理和系统配置工具
- OKX交易所 -加密货币交易数据和市场信息
- OpenAPI浏览器 -API规范探索和测试工具
- OSINT情报 -开源情报收集和分析
- 论文搜索 -跨多个研究数据库的学术论文搜索
- 红迪 -社交媒体内容和社区讨论
- 科学计算 -高级数学计算和数据分析
- 时间MCP -日期、时间实用程序和时区转换
- 单元转换器 -不同单位系统之间的测量转换
- 天气数据 -天气预报和气象信息
- 维基百科 -百科全书内容搜索和检索
项目结构
mcp-bench/
├── agent/ # Task execution agents
│ ├── __init__.py
│ ├── executor.py # Multi-round task executor with retry logic
│ └── execution_context.py # Execution context management
├── benchmark/ # Evaluation framework
│ ├── __init__.py
│ ├── evaluator.py # LLM-as-judge evaluation metrics
│ ├── runner.py # Benchmark orchestrator
│ ├── results_aggregator.py # Results aggregation and statistics
│ └── results_formatter.py # Results formatting and display
├── config/ # Configuration management
│ ├── __init__.py
│ ├── benchmark_config.yaml # Benchmark configuration
│ └── config_loader.py # Configuration loader
├── llm/ # LLM provider abstractions
│ ├── __init__.py
│ ├── factory.py # Model factory for multiple providers
│ └── provider.py # Unified provider interface
├── mcp_modules/ # MCP server management
│ ├── __init__.py
│ ├── connector.py # Server connection handling
│ ├── server_manager.py # Multi-server orchestration
│ ├── server_manager_persistent.py # Persistent connection manager
│ └── tool_cache.py # Tool call caching mechanism
├── synthesis/ # Task generation
│ ├── __init__.py
│ ├── task_synthesis.py # Task generation with fuzzy conversion
│ ├── generate_benchmark_tasks.py # Batch task generation script
│ ├── benchmark_generator.py # Unified benchmark task generator
│ ├── README.md # Task synthesis documentation
│ └── split_combinations/ # Server combination splits
│ ├── mcp_2server_combinations.json
│ └── mcp_3server_combinations.json
├── utils/ # Utilities
│ ├── __init__.py
│ ├── collect_mcp_info.py # Server discovery and tool collection
│ ├── local_server_config.py # Local server configuration
│ └── error_handler.py # Error handling utilities
├── tasks/ # Benchmark task files
│ ├── mcpbench_tasks_single_runner_format.json
│ ├── mcpbench_tasks_multi_2server_runner_format.json
│ └── mcpbench_tasks_multi_3server_runner_format.json
├── mcp_servers/ # MCP server implementations (28 servers)
│ ├── api_key # API keys configuration file
│ ├── commands.json # Server command configurations
│ ├── install.sh # Installation script for all servers
│ ├── requirements.txt # Python dependencies
│ └── [28 server directories]
├── cache/ # Tool call cache directory (auto-created)
├── run_benchmark.py # Main benchmark runner script
├── README.md # Project documentation
├── .gitignore # Git ignore configuration
└── .gitmodules # Git submodules configuration
引用
如果您在研究中使用MCP Bench,请引用:
@article{wang2025mcpbench,
title={MCP-Bench: Benchmarking Tool-Using LLM Agents with Complex Real-World Tasks via MCP Servers},
author={Wang, Zhenting and Chang, Qi and Patel, Hemani and Biju, Shashank and Wu, Cheng-En and Liu, Quan and Ding, Aolin and Rezazadeh, Alireza and Shah, Ankit and Bao, Yujia and Siow, Eugene},
journal={arXiv preprint arXiv:2508.20453},
year={2025}
}
明星历史
致谢
- 建立在 模型上下文协议 通过Anthropic
- 由于使用了所有开源的MCP服务器实现