Token导航 LogoToken导航TokenDH.com
Agent Testing MCP logo
开发工具stdio官方级别未说明来源级核验

Agent Testing MCP

MCP Server

一个基于Model Context Protocol (MCP)的通用AI编码代理测试框架,支持通过声明式测试场景自动评估Claude Code、Cursor、GitHub Copilot等工具。

工具数

6

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude开发工具ClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Purv123

提供方

Purv123

最后核验

2026/5/17 20:19

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -it --rm agent-testing-mcp

详细介绍

代理测试MCP服务器

使用模型上下文协议(MCP)的AI编码代理的通用测试框架。该服务器允许通过声明性测试场景自动评估人工智能代理,如Claude Code、Cursor、GitHub Copilot和类似工具。

特性

  • 通用测试框架:测试任何与MCP兼容的AI编码代理
  • 声明性测试场景:使用JSON/YAML文件定义测试
  • 安全代码执行:基于Docker的沙盒,具有子进程回退功能
  • 智能评估:DeepEval集成用于综合评估
  • 多种指标:正确性、代码质量、完整性和相关性
  • 丰富的报告:JSON结果和带有完整交互日志的Markdown报告
  • 可扩展:易于添加自定义测试场景和评估指标

建筑

┌─────────────────┐
│   AI Agent      │ (Claude Code, Cursor, etc.)
│  (MCP Client)   │
└────────┬────────┘
         │ MCP Protocol
         │
┌────────▼────────────────────────────────────┐
│         Agent Testing MCP Server            │
│  ┌──────────────────────────────────────┐  │
│  │  MCP Tools (list, get, submit, etc.) │  │
│  └──────────────┬───────────────────────┘  │
│                 │                           │
│  ┌──────────────▼───────────────────────┐  │
│  │      Test Scenario Manager           │  │
│  │  (Load & manage test definitions)    │  │
│  └──────────────┬───────────────────────┘  │
│                 │                           │
│  ┌──────────────▼───────────────────────┐  │
│  │       Code Executor                  │  │
│  │  (Docker/Subprocess sandboxing)      │  │
│  └──────────────┬───────────────────────┘  │
│                 │                           │
│  ┌──────────────▼───────────────────────┐  │
│  │      Test Evaluator                  │  │
│  │  (DeepEval + Custom metrics)         │  │
│  └──────────────┬───────────────────────┘  │
│                 │                           │
│  ┌──────────────▼───────────────────────┐  │
│  │      Result Reporter                 │  │
│  │  (JSON/Markdown reports)             │  │
│  └──────────────────────────────────────┘  │
└─────────────────────────────────────────────┘

安装

🐳 Docker快速入门(推荐)

无需安装Python! 只是Docker。

一个命令设置⭐

git clone https://github.com/Purv123/Agent-Testing-MCP.git
cd Agent-Testing-MCP
./run_mcp.sh

就是这样!脚本会自动执行以下操作:

  • 检查Docker安装
  • 构建图像
  • 启动MCP服务器

替代方法

# Using docker-compose
docker-compose up -d

# Using docker build
docker build -t agent-testing-mcp .
docker run -it --rm agent-testing-mcp

看 快速指南或 医生.md 以获取完整的文档。

______________________________________________________________________

🐍 替代方案:本地Python安装

先决条件

  • Python 3.10或更高版本 (3.11+推荐)

- ⚠️ 重要:The mcp 软件包需要Python 3.10+ - Python 3.9及以下版本不受支持

  • pip(Python包管理器)

快速设置

  1. 检查Python版本:
   python3 --version
   # Must show 3.10.x or higher
  1. 克隆存储库:
   git clone https://github.com/Purv123/Agent-Testing-MCP.git
   cd Agent-Testing-MCP
  1. 创建虚拟环境:
   python3 -m venv venv
   source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. 安装依赖项:
   pip install --upgrade pip
   pip install -r requirements.txt
💡 有安装问题吗?安装.md 详细故障排除
  1. 设置DeepEval (可选,用于高级评估):
   # DeepEval requires an API key for LLM-based metrics
   export OPENAI_API_KEY="your-api-key"  # Or use other supported providers
  1. 验证Docker (可选但推荐):
   docker --version
   # If not installed, the server will fall back to subprocess execution

快速开始

运行MCP服务器

使用stdio传输(MCP的标准)启动服务器:

python -m mcp_server.server

服务器将:

  • 从加载所有测试场景 test_scenarios/
  • 开始监听MCP客户端连接
  • 将活动记录到 logs/mcp_server.log

与克劳德代码连接

添加到您的Claude Code MCP配置中:

{
  "mcpServers": {
    "agent-testing": {
      "command": "python",
      "args": ["-m", "mcp_server.server"],
      "cwd": "/path/to/Agent-Testing-MCP"
    }
  }
}

重新启动Claude Code,服务器工具将可用。

用法

可用的MCP工具

服务器向AI代理公开以下工具:

1. list_test_scenarios

列出所有可用的测试场景。

{
  "category": "basic"  // optional filter
}

2. get_test_scenario

获取特定测试的详细信息。

{
  "scenario_id": "basic_001"
}

3. submit_solution

提交您的解决方案以供评估。

{
  "scenario_id": "basic_001",
  "code": "def is_palindrome(text):\n    return text == text[::-1]",
  "language": "python",
  "explanation": "Using string slicing to reverse and compare"
}

4. execute_code

在沙箱中执行代码而不进行完全评估。

{
  "code": "print('Hello, World!')",
  "language": "python",
  "timeout": 30
}

5. get_test_results

获取测试运行的详细结果。

{
  "run_id": "basic_001_20250121_143022"
}

6. list_test_runs

列出所有具有可选筛选的测试运行。

{
  "scenario_id": "basic_001",  // optional
  "status": "passed"           // optional: passed, failed, error
}

工作流示例

作为使用MCP服务器的AI代理:

1. Agent: list_test_scenarios()
   → Receives list of available tests

2. Agent: get_test_scenario(scenario_id="basic_001")
   → Receives detailed requirements and test cases

3. Agent: Writes solution code

4. Agent: submit_solution(scenario_id="basic_001", code="...", language="python")
   → Receives evaluation results immediately

5. Agent: get_test_results(run_id="...")
   → Receives detailed report with feedback

创建自定义测试场景

测试场景在JSON或YAML格式中定义 test_scenarios/ 目录。

场景结构

{
  "id": "unique_scenario_id",
  "title": "Human-readable title",
  "description": "What the agent should build",
  "category": "basic|intermediate|advanced|bug_fix|refactoring",
  "difficulty": "easy|medium|hard",
  "context": "Background information and constraints",

  "requirements": [
    "Specific requirement 1",
    "Specific requirement 2"
  ],

  "success_criteria": [
    "What defines success for this test"
  ],

  "language": "python|javascript|typescript",
  "timeout": 30,

  "test_cases": [
    {
      "input": "input data (can be any JSON type)",
      "expected_output": "expected result",
      "description": "What this test validates"
    }
  ],

  "starter_code": "Optional template code",
  "hints": ["Optional hints for the agent"],

  "evaluation_metrics": {
    "weights": {
      "correctness": 0.4,
      "quality": 0.3,
      "completeness": 0.2,
      "relevance": 0.1
    },
    "pass_threshold": 0.7
  }
}

示例:简单测试场景

{
  "id": "hello_world",
  "title": "Hello World Function",
  "description": "Write a function that returns 'Hello, {name}!'",
  "category": "basic",
  "difficulty": "easy",
  "language": "python",

  "requirements": [
    "Create a function named 'greet'",
    "Take a name parameter",
    "Return greeting string"
  ],

  "test_cases": [
    {
      "input": "Alice",
      "expected_output": "Hello, Alice!",
      "description": "Basic greeting"
    },
    {
      "input": "World",
      "expected_output": "Hello, World!",
      "description": "Classic hello world"
    }
  ],

  "starter_code": "def greet(name):\n    pass\n\ndef main(name):\n    return greet(name)"
}

评价体系

指标

评估人员从多个维度评估解决方案:

  1. 正确率(40%):测试用例通过了吗?
  2. 代码质量(20%):代码是否干净、有文档记录且结构良好?
  3. 完整性(20%):是否满足了所有要求?
  4. 相关性(20%):它解决了正确的问题吗?

*权重可以根据场景进行定制*

DeepEval集成

如果可用,DeepEval会提供其他基于LLM的指标:

  • 回答相关性
  • 忠实于要求
  • 情境理解

通过/失败判定

  • 每个指标产生0.0到1.0的分数
  • 加权平均值产生总分
  • 默认通过阈值:0.7(70%)
  • 可根据场景进行定制

结果和报告

输出位置

  • JSON结果: results/{run_id}.json
  • Markdown报告: results/{run_id}.md
  • 代码快照: results/{run_id}_code.{ext}
  • 日志: logs/mcp_server.log

报告内容

每次测试运行都会生成:

  • 完整的场景详细信息
  • 提交的代码和说明
  • 执行输出和错误
  • 测试用例结果
  • 评估指标和分数
  • 详细反馈
  • 通过/失败判定

报告结构示例

# Test Report: Implement a Palindrome Checker

**Status:** ✓ PASSED
**Score:** 0.85/1.00

## Execution Results
- All 5 test cases passed
- No errors
- Clean output

## Evaluation
- Correctness: 1.00/1.00
- Quality: 0.75/1.00
- Completeness: 0.85/1.00
- Relevance: 0.90/1.00

## Feedback
- ✓ All test cases passed successfully
- ✓ Solution appears complete
- Code quality issues: No comments or documentation

配置

环境变量

# DeepEval (optional)
export OPENAI_API_KEY="your-key"

# Execution timeout (optional, default: 30s)
export DEFAULT_TIMEOUT=60

# Docker usage (optional, default: auto-detect)
export FORCE_DOCKER=true

服务器配置

创建 config.json 对于高级设置:

{
  "scenarios_dir": "test_scenarios",
  "results_dir": "results",
  "logs_dir": "logs",
  "executor": {
    "use_docker": true,
    "default_timeout": 30,
    "docker_image": "python:3.11-slim"
  },
  "evaluator": {
    "enable_deepeval": true,
    "default_pass_threshold": 0.7
  }
}

发展

项目结构

Agent-Testing-MCP/
├── mcp_server/           # Core server implementation
│   ├── server.py         # MCP server with tool definitions
│   ├── test_manager.py   # Test scenario management
│   ├── executor.py       # Safe code execution
│   ├── evaluator.py      # DeepEval integration
│   └── reporter.py       # Results and reporting
├── test_scenarios/       # Test definitions (JSON/YAML)
├── results/              # Test results and reports
├── logs/                 # Server logs
├── requirements.txt      # Python dependencies
└── README.md            # This file

运行测试

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

# Code formatting
black mcp_server/

# Linting
ruff check mcp_server/

添加新功能

  1. 新的评估指标:扩展 evaluator.py
  2. 新语言:更新 executor.py 有语言支持
  3. 自定义工具:添加到 server.py 工具定义
  4. 新报告格式:扩展 reporter.py

故障排除

常见问题

Docker不可用

WARNING: Docker not available, falling back to subprocess execution

→ 安装Docker或继续子进程(隔离程度较低)

DeepEval导入错误

WARNING: DeepEval not available. Using basic evaluation only.

→ 安装DeepEval: pip install deepeval 并配置API密钥

测试场景未加载

WARNING: Scenarios directory not found

→ 确保 test_scenarios/ 存在有效的JSON/YAML文件

Docker上的权限错误

Error: permission denied while trying to connect to Docker

→ 将用户添加到docker组: sudo usermod -aG docker $USER

示例

test_scenarios/ 完整示例目录:

  • 001_basic_function.json -简单回文检查器
  • 002_data_processing.json -JSON解析和分析
  • 003_bug_fix.json -调试练习
  • 004_refactoring.json -代码改进任务
  • 005_algorithm.json -二进制搜索实现

贡献

欢迎投稿!拜托:

  1. 分叉存储库
  2. 创建要素分支
  3. 添加新功能的测试
  4. 确保代码通过linting
  5. 提交拉取请求

许可证

MIT许可证-有关详细信息,请参阅许可证文件

致谢

支持

______________________________________________________________________

基于模型上下文协议构建,用于通用AI代理测试

目录标签

目录标签

PythonClaude开发工具AI测试框架本地部署代码评估自动化测试MCP协议

支持客户端

ClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

api-key

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdioapi-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP