AI测试协议服务器

AI Testing MCP是一个基于模型上下文协议(MCP)的服务器,提供标准化的AI/ML系统测试方法、评估指标和自动化测试工作流程。

  • by groovy-web
  • 本地部署
  • 19 星标
  • 更新于
在 GitHub 查看 groovy-web/ai-testing-mcp

使用说明

人工智能测试MCP

模型上下文协议(MCP)服务器,用于全面的人工智能测试、评估和质量保证。

概述

AI测试MCP为AI/ML系统提供标准化的测试方法、评估指标和自动化测试工作流程。它实现了模型上下文协议,与人工智能开发工具无缝集成。

特征

测试能力

  • 单元测试:组件级测试
  • 集成测试:端到端工作流测试
  • 性能测试:延迟、吞吐量、资源使用率
  • 安全测试对抗性攻击,迅速注射
  • 质量测试:输出验证、一致性检查

评估指标

  • 准确度:精确度、召回率、F1分数
  • 质量:连贯性、相关性、流畅性
  • 安全:毒性、偏差检测
  • 演出:响应时间、令牌使用情况
  • 成本:API成本、计算资源

MCP集成

  • 标准协议:实施MCP规范
  • 工具定义:AI助手的测试工具
  • 资源管理:测试数据和配置
  • 提示模板:可重复使用的测试提示

快速开始

# Clone the repository
git clone https://github.com/groovy-web/ai-testing-mcp.git
cd ai-testing-mcp

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit with your API keys

# Start the MCP server
npm start

# Use with MCP client
# Add server configuration to your MCP client

MCP服务器配置

{
  "mcpServers": {
    "ai-testing": {
      "command": "node",
      "args": ["/path/to/ai-testing-mcp/dist/index.js"],
      "env": {
        "OPENAI_API_KEY": "your-key",
        "ANTHROPIC_API_KEY": "your-key"
      }
    }
  }
}

可用工具

测试工具

run_test_suite

为AI模型执行全面的测试套件。

{
  "name": "run_test_suite",
  "description": "Run tests on an AI model",
  "inputSchema": {
    "type": "object",
    "properties": {
      "model": { "type": "string" },
      "testCategory": {
        "type": "string",
        "enum": ["accuracy", "performance", "security", "quality"]
      },
      "testCases": { "type": "array" }
    }
  }
}

evaluate_output

根据指标评估AI模型输出。

{
  "name": "evaluate_output",
  "description": "Evaluate model output quality",
  "inputSchema": {
    "type": "object",
    "properties": {
      "output": { "type": "string" },
      "expected": { "type": "string" },
      "metrics": { "type": "array" }
    }
  }
}

generate_test_cases

为特定场景生成测试用例。

{
  "name": "generate_test_cases",
  "description": "Generate test cases",
  "inputSchema": {
    "type": "object",
    "properties": {
      "scenario": { "type": "string" },
      "count": { "type": "number" }
    }
  }
}

仓库结构

ai-testing-mcp/
├── docs/                    # Documentation
│   ├── mcp-protocol.md
│   ├── testing-guide.md
│   └── metrics.md
├── examples/                # Usage examples
│   ├── basic-testing/
│   ├── custom-metrics/
│   └── integration-examples/
├── src/                     # Source code
│   ├── server/              # MCP server
│   ├── tools/               # Tool implementations
│   ├── metrics/             # Evaluation metrics
│   └── tests/               # Test definitions
└── schemas/                 # JSON schemas

使用示例

基本测试

from mcp_client import MCPClient

client = MCPClient("ai-testing")

# Run accuracy tests
result = client.call_tool("run_test_suite", {
    "model": "gpt-4",
    "testCategory": "accuracy",
    "testCases": [
        {
            "input": "What is 2+2?",
            "expected": "4"
        }
    ]
})

print(f"Accuracy: {result.metrics.accuracy}")

自定义指标

# Evaluate with custom metrics
evaluation = client.call_tool("evaluate_output", {
    "output": model_response,
    "expected": expected_response,
    "metrics": [
        "exact_match",
        "semantic_similarity",
        "coherence",
        "relevance"
    ]
})

文档

测试类别

1.精度测试

  • 精确匹配
  • 语义相似性
  • 事实正确性
  • 数学精度

2.性能测试

  • 响应时间
  • 吞吐量
  • 代币效率
  • 资源使用

3.安全测试

  • 快速注射
  • 越狱企图
  • 有毒物质含量
  • 偏差检测

4.质量测试

  • 连贯性
  • 流畅度
  • 相关性
  • 完整性

配置

module.exports = {
  // Models to test
  models: [
    {
      name: "gpt-4",
      provider: "openai",
      apikey: process.env.OPENAI_API_KEY
    },
    {
      name: "claude-3-opus",
      provider: "anthropic",
      apikey: process.env.ANTHROPIC_API_KEY
    }
  ],

  // Test configurations
  tests: {
    accuracy: {
      enabled: true,
      threshold: 0.95
    },
    performance: {
      maxLatency: 2000,
      maxTokens: 1000
    },
    security: {
      enabled: true,
      strict: true
    }
  },

  // Output format
  reports: {
    format: "json",
    destination: "./test-results"
  }
};

运行测试

# Run all tests
npm test

# Run specific category
npm test -- --category accuracy

# Run with specific model
npm test -- --model gpt-4

# Generate report
npm run report

贡献

我们欢迎捐款!请看 贡献.md 作为指导方针。

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 了解详情。

行为准则

请阅读 代码_OF_CONDUCT.md 了解我们的社区标准。

支持

  • GitHub问题:Bug报告和功能请求
  • 讨论:社区问题
  • MCP文件:https://modelcontextprotocol.io

相关项目


相关存储库

探索更多开源工具 Groovy Web: