Token导航 LogoToken导航TokenDH.com
toolvaluator (Cwbooth5) logo
AI代理stdio官方级别未说明来源级核验

toolvaluator (Cwbooth5)

MCP Server

Toolvaluator是一个用于测试和评估语言模型工具调用能力的框架,帮助开发者优化工具模式和提高模型性能。

工具数

5

提示词数

0

GitHub Stars

0

资源数

0
PythonClaudeAI代理Claude

安装说明

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

作者 / 组织

cwbooth5

提供方

cwbooth5

最后核验

2026/5/17 20:20

快速接入

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

命令预览

pip install toolvaluator

详细介绍

工具评估师

用于测试LLM工具调用能力的MCP工具模式评估框架。

Toolvaluator通过测量以下内容来帮助您评估语言模型使用FastMCP工具的情况:

  • 正确性:模型是否选择了正确的工具和正确的参数?
  • 延迟:模型做出工具调用决策的速度有多快?

您可以使用此功能:

  • 比较不同的模型,找出最适合您的工具的模型
  • 优化工具模式和描述,以获得更好的模型性能
  • 为您的MCP工具建立质量基准
  • 使用简单的合成工具定义来查看模型在工具调用方面有多好
  • 将多个工具调用(真实或模拟)链接在一起,并在此过程中进行评估

设计

我做这个是为了填补我的工具集中的一个小空白,在那里我可以创建所有这些 MCP服务器,但当模型偶然出现时,它不知道该怎么办 我的工具定义。工具名称和组织以及签名 而docstring对于确保模型能够理解我的工具至关重要。 在实践中,我看到了不同模型之间截然不同的行为。准确性 模型的决策非常重要。延迟是次要问题 因为有些情况下我需要把一堆串在一起 我想看看我能在一个时间单位内塞进多少次工具调用。

在基本测试流程中,这不会让模型调用工具。我们只是 衡量模型的决策。它正在读取您工具中的MCP工具定义 并将其与模型一起使用,就像你的AI客户端注册你的工具一样 与模型。

在更高级的链式测试流程中,您可以选择实际调用您的 工具。这允许您通过轻推来执行后续工具调用的评估 调用这些工具的模型。

工具签名

其主要目的是测试工具名称、描述和 论据。这是首先在模型中注册的数据。简单、无链 测试工作流可以帮助您对此进行测试。

模拟工具调用

这在链式工具调用测试流中最有用。当你想测试时,它很有用 模型在工具集中遵循的路径。你有能力嘲笑你的 工具调用或实际调用工具(处理副作用)。其目的 是 _不_ 测试工具本身,只是为了获得所需的信息(工具响应) 回到模型的上下文中,这样它就可以影响后续的工具调用决策。

安装

使用紫外线(推荐)

# Install the package
uv pip install toolvaluator

# Or install from source with dev dependencies
git clone https://github.com/cwbooth5/toolvaluator.git
cd toolvaluator
uv pip install -e ".[dev]"

or for an editable install...

uv tool install -e .

工具安装

您可以直接从github仓库中安装该工具。

uv tool install --from https://github.com/cwbooth5/toolvaluator.git toolvaluator

使用pip

pip install toolvaluator

# Or install from source with dev dependencies
git clone https://github.com/cwbooth5/toolvaluator.git
cd toolvaluator
pip install -e ".[dev]"

快速开始

1.创建您的FastMCP服务器

首先,使用您的工具创建FastMCP服务器(例如。, my_server.py):

from fastmcp import FastMCP

mcp = FastMCP("My Server")

@mcp.tool()
def search_docs(query: str) -> str:
    """Search through company documentation."""
    return f"Found documents matching '{query}'"

if __name__ == "__main__":
    mcp.run()

2.运行评估

# Evaluate with OpenAI GPT-4o-mini (default)
toolvaluator --server my_server

# Use a different model
toolvaluator --server my_server --model gpt-4o

# Use a local/OSS model
toolvaluator --server my_server --model llama-3.1 --base-url http://localhost:1234/v1 --api-key none

# Set a minimum score threshold (useful for CI/CD)
toolvaluator --server my_server --min-score 0.85

3.创建自定义评估脚本(推荐)

要测试您自己的MCP工具,请使用 kickstart工具 生成独立的评估脚本:

# Generate a custom evaluation script for your MCP server
toolvaluator-init \
  --server my_server \
  --server-var mcp \
  --output eval_my_tools.py

# This auto-detects your tools and creates a template script
# Edit eval_my_tools.py to customize the evaluation examples

# Run your custom evaluation
python eval_my_tools.py --model gpt-4o-mini --verbose

# Use in CI/CD with quality gates
python eval_my_tools.py --model gpt-4o --min-score 0.85

什么是“数据集”? 数据集是以下内容的集合 评估示例 -验证模型是否能够:

  1. 决定何时调用工具(should_call)
  2. 选择正确的工具(tool_name)
  3. 提取正确的论点(arguments)

示例评估示例:

dspy.Example(
    user_query="Find the company vacation policy",
    tool_name="search_docs",
    tool_description="Search through company documentation",
    tool_schema=schema,
    expected_should_call=True,
    expected_tool_name="search_docs",
    expected_arguments={"query": "vacation policy"},
).with_inputs("user_query", "tool_name", "tool_description", "tool_schema")

在这三个维度上,每个例子的得分都是0-1,总分是平均值。

将Toolvaluator用作库

您还可以在自己的脚本中以编程方式使用toolvaluator:

from toolvaluator import (
    build_dataset,
    eval_model,
    get_tool_schemas_sync,
    extract_input_schema,
    extract_tool_description
)
import dspy
from my_server import mcp

# Fetch tool schemas
tool_schemas = get_tool_schemas_sync(mcp)

# Create custom evaluation examples
examples = []
if "my_tool" in tool_schemas:
    tool_name = "my_tool"
    tool_description = extract_tool_description(tool_schemas[tool_name])
    tool_schema = extract_input_schema(tool_schemas[tool_name])

    examples.append(
        dspy.Example(
            user_query="Use my tool to process ABC",
            tool_name=tool_name,
            tool_description=tool_description,
            tool_schema=tool_schema,
            expected_should_call=True,
            expected_tool_name=tool_name,
            expected_arguments={"input": "ABC"},
        ).with_inputs("user_query", "tool_name", "tool_description", "tool_schema")
    )

# Run evaluation
result = eval_model(
    model_name="gpt-4o-mini",
    api_key="your-api-key",
    base_url=None,
    dataset=examples,
    verbose=True,
)

print(f"Score: {result['score']:.3f}")

使用ExampleBuilder减少锅炉板

为了获得更简洁的代码,请使用 ExampleBuilder 帮助类以减少样板:

from toolvaluator import ExampleBuilder, get_tool_schemas_sync, eval_model
from my_server import mcp

# Fetch tool schemas
tool_schemas = get_tool_schemas_sync(mcp)

# Create builder
builder = ExampleBuilder(tool_schemas)

# Add examples with minimal boilerplate
builder.add_positive(
    tool="search_docs",
    query="Find our vacation policy",
    arguments={"query": "vacation policy"}
)

builder.add_negative(
    tool="search_docs",
    query="What is 2+2?"  # Should answer directly
)

# Method chaining works too!
builder.add_positive(
    tool="get_weather",
    query="Weather in Tokyo?",
    arguments={"location": "Tokyo", "units": None}  # None = wildcard
).add_positive(
    tool="calculate",
    query="What is 5 * 10?",
    arguments={"operation": "multiply", "a": 5, "b": 10}
)

# Run evaluation
result = eval_model(
    model_name="gpt-4o-mini",
    api_key="your-api-key",
    dataset=builder.examples,
    verbose=True,
)

主要优势:

  • 无需手动提取架构:自动提取tool_name、tool_description和tool_schema
  • 更简洁的语法:关注查询和预期参数,而不是样板
  • 方法链:流利地构建测试套件
  • 内置验证:如果工具不存在,则引发错误
  • 便利方法: add_positive()add_negative() 对于常见情况

项目结构

toolvaluator/
├── src/
│   └── toolvaluator/
│       ├── __init__.py          # Package initialization with version
│       ├── cli.py               # Command-line interface
│       ├── evaluator.py         # Core evaluation logic
│       └── test_server.py       # Example MCP server for testing
├── tests/
│   ├── __init__.py
│   ├── conftest.py              # Pytest fixtures
│   ├── test_evaluator.py        # Tests for evaluator module
│   └── test_server.py           # Tests for test server
├── pyproject.toml               # Project configuration
└── README.md

发展

设置开发环境

# Clone the repository
git clone https://github.com/cwbooth5/toolvaluator.git
cd toolvaluator

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

# Or using pip
pip install -e ".[dev]"

运行测试

# Run all tests
pytest

# Run with coverage
pytest --cov=toolvaluator --cov-report=html

# Run specific test file
pytest tests/test_evaluator.py

代码质量

# Format code with black
black src tests

# Lint with ruff
ruff check src tests

# Fix auto-fixable issues
ruff check --fix src tests

建筑

# Build the package
uv build

# Or using hatch
hatch build

# This creates dist/toolvaluator-*.whl and dist/toolvaluator-*.tar.gz

版本管理

该版本由赫氏公司管理并存储在 src/toolvaluator/__init__.py.

要更新版本,请执行以下操作:

# Edit src/toolvaluator/__init__.py
__version__ = "0.2.0"

然后重建:

uv build

示例:使用测试服务器

该软件包包括一个带有示例工具的测试MCP服务器:

# Run evaluation against the test server
toolvaluator --server toolvaluator.test_server

# Or use it programmatically
python -c "from toolvaluator.test_server import mcp; print(mcp)"

测试服务器包括以下工具:

  • search_docs(query) -搜索文档
  • get_weather(location, units) -获取天气信息
  • calculate(operation, a, b) -执行计算
  • send_email(to, subject, body, cc) -发送电子邮件
  • create_task(title, description, priority, due_date) -创建任务

运作原理

  1. 模式提取:使用MCP协议从FastMCP服务器获取工具模式
  2. 数据集创建:使用用户查询和预期的工具调用行为创建测试示例
  3. 法学硕士评估:使用DSPy提示模型决定:

- 是否应该调用该工具? - 应该叫哪个工具? - 应该通过哪些论点?

  1. 评分:在三个维度上将模型的决策与预期行为进行比较:

- 应该调用正确性(二进制:它是否正确地决定使用/不使用该工具?) - 工具名称正确性(二进制:它选择了正确的工具吗?) - 参数正确性(分数:匹配了多少个参数?)

  1. 指标:报告总体正确性得分(0-1)和延迟统计数据(平均值、p50、p95、最大值)

高级功能

通配符参数值

您可以使用 None 作为通配符值 expected_arguments 表明一个具体的论点 必须存在 但你 不在乎它的价值。这在以下情况下很有用:

  • 您想验证模型是否提取了参数,但确切值会有所不同
  • 在不关心内容的情况下测试论点的存在
  • 该值是动态的(时间戳、ID、生成的文本等)

示例:

# Exact value checking (strict)
expected_arguments = {
    "location": "Tokyo",
    "units": "celsius"
}
# Model must return exactly: location="Tokyo", units="celsius"

# Wildcard value checking (flexible)
expected_arguments = {
    "location": None,      # Any location is acceptable
    "units": "celsius"     # Must be exactly "celsius"
}
# Model can return: location="Tokyo" ✓, location="Paris" ✓, etc.

# Mixed approach
expected_arguments = {
    "to": None,            # Any email address
    "subject": "Meeting",  # Must be exactly "Meeting"
    "body": None          # Any body text
}

重要区别:

  • expected_arguments=None → 根本不在乎任何争论(得分1.0)
  • expected_arguments={} → 预计没有参数(如果模型提供任何参数,则得分为0.0)
  • expected_arguments={"key": None} → 期望“key”以任何值存在

增强论证评分

论点比较使用复杂的评分:

  1. 精确匹配:每个正确匹配的参数都有贡献 1/n 分数(其中n=预期参数的数量)
  2. 通配符:争论 None 如果键存在,则值计为匹配
  3. 钥匙丢失:应该存在但没有贡献的论点 0/n 得分
  4. 额外钥匙罚款:意外的参数会引发 -0.5/n 每额外一把钥匙的罚款
  5. 最终得分: max(0.0, base_score - extra_penalty)

示例:

# Perfect match
expected = {"arg1": "val1", "arg2": 42}
predicted = {"arg1": "val1", "arg2": 42}
# Score: 1.0

# Partial match
expected = {"arg1": "val1", "arg2": 42}
predicted = {"arg1": "val1", "arg2": 99}
# Score: 0.5 (only arg1 matched)

# Extra arguments penalty
expected = {"arg1": "val1", "arg2": 42}
predicted = {"arg1": "val1", "arg2": 42, "extra1": "foo", "extra2": "bar"}
# Base: 2/2 = 1.0, Penalty: (2 * 0.5) / 2 = 0.5, Final: 0.5

# Empty dict means "no arguments expected"
expected = {}
predicted = {"arg1": "val1"}
# Score: 0.0 (model should not have provided arguments)

工具上下文感知

评估者为模型提供了完整的工具上下文,以防止产生幻觉:

  • 工具名称:正在评估的工具的确切名称
  • 工具描述:这个工具做什么
  • 工具架构:参数定义和类型

这可以防止模型产生工具名称的幻觉或误解工具目的。每次评估都会问:“给定这个特定的工具和这个查询,应该调用这个工具吗?使用什么参数?”

系统提示(可选)

默认情况下,评估不使用系统提示。但是,您可以选择使用优先级系统在两个级别提供系统提示:

优先: 示例/步骤级别>评估级别>无(默认)

定期评估:

# Build dataset with optional per-example system prompts
builder = ExampleBuilder(tool_schemas)

# Example 1: No system prompt (will use eval-level if provided)
builder.add_positive(
    tool="calculate",
    query="What is 5 + 10?",
    arguments={"operation": "add", "a": 5, "b": 10}
)

# Example 2: Custom system prompt (overrides eval-level)
builder.add_positive(
    tool="search_docs",
    query="Find our vacation policy",
    arguments={"query": "vacation"},
    system_prompt="You are a helpful HR assistant."  # Example-level
)

dataset = builder.build()

# Evaluate with optional default system prompt
result = eval_model(
    model_name="gpt-4o-mini",
    api_key="your-key",
    base_url=None,
    dataset=dataset,
    system_prompt="You are a helpful assistant."  # Eval-level (optional)
)

连锁评估:

# Build chained dataset with optional per-step system prompts
builder = ChainedExampleBuilder(tool_schemas, mcp)

builder.add_chain(
    mocks={}
).add_step(
    initial_query="Calculate 5 * 10",
    expected_tool="calculate",
    expected_arguments={"operation": "multiply", "a": 5, "b": 10},
    system_prompt="You are a math expert."  # Step-level (optional)
)

dataset = builder.build()

# Evaluate with optional default system prompt
result = eval_chained_model(
    model_name="gpt-4o-mini",
    api_key="your-key",
    dataset=dataset,
    system_prompt="You are a helpful assistant."  # Eval-level (optional)
)

它是如何工作的:

  • 如果一个示例/步骤有自己的 system_prompt,即使用
  • 否则,如果eval函数具有 system_prompt,即使用
  • 否则,不使用系统提示(默认行为)

使用案例:

  • 测试系统提示如何影响工具调用行为
  • 比较不同系统提示下的模型性能
  • 为特定示例提供特定角色的上下文

链式工具调用(高级)

警告:此功能实际上在您的MCP服务器上执行工具!

对于测试多步骤工作流,其中一个工具的输出馈送到下一个工具,请使用与常规评估相同的模式:

步骤1:构建数据集

from toolvaluator import ChainedExampleBuilder, eval_chained_model, get_tool_schemas_sync
from my_server import mcp

tool_schemas = get_tool_schemas_sync(mcp)

# Build chained test dataset (same pattern as ExampleBuilder!)
builder = ChainedExampleBuilder(tool_schemas, mcp)

# Add a chain (sequence of tool calls)
builder.add_chain(
    mocks={}  # Optional: mock tools to avoid side effects
).add_step(
    initial_query="Calculate 15 * 23, then divide the result by 5",
    expected_tool="calculate",
    expected_arguments={"operation": "multiply", "a": 15, "b": 23}
).add_step(
    expected_tool="calculate",
    expected_arguments={"operation": "divide", "a": None, "b": 5}  # 'a' comes from step 1
)

# Build dataset
dataset = builder.build()

第二步:使用模型进行评估

# Evaluate with model config (same pattern as eval_model!)
result = eval_chained_model(
    model_name="gpt-4o-mini",
    api_key="your-api-key",
    dataset=dataset,
    verbose=True
)

print(f"Overall score: {result['score']:.2f}")
print(f"Steps completed: {result['num_steps']}")
for chain in result['chain_results']:
    for step in chain['step_results']:
        print(f"  Step {step['step']}: {step['predicted_tool']} → {step['tool_result']}")

使用多个模型测试同一数据集:

# Test with GPT-4o-mini
result1 = eval_chained_model(
    model_name="gpt-4o-mini",
    api_key="openai-key",
    dataset=dataset
)

# Test with Claude (same dataset!)
result2 = eval_chained_model(
    model_name="claude-3-sonnet",
    api_key="anthropic-key",
    dataset=dataset
)

# Test with local model
result3 = eval_chained_model(
    model_name="local-model",
    api_key="lm-studio",
    base_url="http://localhost:1234/v1",
    dataset=dataset
)

print(f"GPT-4o-mini score: {result1['score']:.2f}")
print(f"Claude score: {result2['score']:.2f}")
print(f"Local model score: {result3['score']:.2f}")

使用模拟来避免副作用:

模拟放在数据集中(测试配置),而不是eval函数(模型配置):

# Add mocks when building the dataset
builder.add_chain(
    mocks={
        "calculate": lambda args: str(args["a"] + args["b"]),  # Callable mock
        "search_docs": "Here are the relevant documents...",   # Static mock
    }
).add_step(
    initial_query="Calculate 5 + 10",
    expected_tool="calculate",
    expected_arguments={"operation": "add", "a": 5, "b": 10}
).add_step(
    expected_tool="search_docs",
    expected_arguments={"query": None},
    mock_result="Custom result for this step"  # Per-step override
)

dataset = builder.build()

# Evaluate - no tools executed because of mocks!
result = eval_chained_model(
    model_name="gpt-4o-mini",
    api_key="your-key",
    dataset=dataset
)

模拟优先级:

  1. 每一步 mock_result (最高优先级)
  2. 全球 mocks 字典
  3. 实际工具执行(最低优先级)

模拟类型:

  • 静态字符串: mocks={"tool": "result"} -总是返回“结果”
  • 可调用的: mocks={"tool": lambda args: ...} -根据参数计算结果
  • 每步超控: add_step(..., mock_result="...") -覆盖全球模拟

多条链条:

您可以将多个链添加到同一数据集中:

builder = ChainedExampleBuilder(tool_schemas, mcp)

# Chain 1: Calculate workflow
builder.add_chain(
    mocks={"calculate": lambda args: str(args["a"] * args["b"])}
).add_step(
    initial_query="Calculate 5 * 10, then add 25",
    expected_tool="calculate",
    expected_arguments={"operation": "multiply", "a": 5, "b": 10}
).add_step(
    expected_tool="calculate",
    expected_arguments={"operation": "add", "a": None, "b": 25}
)

# Chain 2: Weather workflow
builder.add_chain(
    mocks={"get_weather": "72°F, sunny"}
).add_step(
    initial_query="Get weather for San Francisco",
    expected_tool="get_weather",
    expected_arguments={"location": "San Francisco", "units": None}
)

# Evaluate all chains with one call
dataset = builder.build()
result = eval_chained_model(
    model_name="gpt-4o-mini",
    api_key="your-key",
    dataset=dataset
)

print(f"Evaluated {result['num_chains']} chains")
print(f"Overall score: {result['score']:.2f}")

API一致性:

连锁评估API遵循与常规评估完全相同的模式:

步骤定期评估连锁评估
1.构建数据集ExampleBuilder(...)ChainedExampleBuilder(...)
2.添加测试.add_positive(...).add_chain().add_step(...)
3.创建数据集.build().build()
4.评估eval_model(model, key, dataset)eval_chained_model(model, key, dataset)

关键原则: 数据集=要测试什么,Eval函数=用哪个模型进行测试

它是如何工作的:

  1. 模型接收初始查询
  2. 模型决定调用哪个工具(步骤1)
  3. 工具已执行 (如有规定,可嘲笑)
  4. 结果作为上下文反馈给模型
  5. 模型决定下一次工具调用(步骤2)
  6. 流程继续进行所有步骤
  7. 每一步都是独立评估的

副作用和警告:

工具是真实执行的 -这不是模拟!

  • 数据修改:工具可以创建、更新或删除数据
  • 网络通话:可以调用API、发送电子邮件等。
  • 资源消耗:数据库查询、文件操作等。
  • 成本:对外部服务的API调用可能会产生费用
  • 幂等性:多次运行链可能会产生不同的结果

最佳实践:

  • 使用测试/暂存MCP服务器,而不是生产服务器
  • 实施具有副作用的工具的模拟/测试版本
  • 使用可安全多次执行的工具
  • 记录所有工具执行情况以进行审计跟踪
  • 考虑在您的工具中实施模拟运行模式

何时使用:

  • 测试多步骤代理工作流
  • 验证工具编排逻辑
  • 工具链集成测试
  • 调试复杂的工具交互

何时不使用:

  • 生产数据或服务
  • 具有不可逆副作用的工具
  • 金融交易或关键业务
  • 除非你完全理解其中的含义!

配置选项

toolvaluator CLI选项

使用内置测试数据集运行评估:

toolvaluator [OPTIONS]

选项:

  • --model:型号名称(默认值: gpt-4o-mini)
  • --api-key:API密钥(默认为 OPENAI_API_KEY 任何人)
  • --base-url:OpenAI兼容端点的基本URL(例如。, http://localhost:1234/v1)
  • --min-score:最低可接受分数0-1(如果低于阈值,则以代码1退出)
  • --server:包含FastMCP服务器的Python模块(默认值: server)
  • --server-var:FastMCP实例变量的名称(默认值: mcp)

- 如果您的服务器使用不同的变量名,请使用此选项,例如 appserver

  • --verbose, -v:显示每个示例的详细调试信息

示例:

# Basic usage
toolvaluator --server my_server

# Custom variable name
toolvaluator --server my_server --server-var app

# Local model with verbose output
toolvaluator --server my_server \
  --model devstral-small \
  --base-url http://localhost:1234/v1 \
  --api-key lm-studio \
  --verbose

toolvaluator-init CLI选项

生成自定义评估脚本:

toolvaluator-init [OPTIONS]

选项:

  • --server:包含MCP服务器的Python模块(必需)
  • --server-var:FastMCP实例变量的名称(默认值: mcp)
  • --output, -o:输出文件名(默认值: eval_tools.py)
  • --tools:生成示例的工具名称(如果未指定,则自动检测)
  • --force, -f:覆盖输出文件(如果存在)

示例:

# Auto-detect tools and generate script
toolvaluator-init --server my_server --output eval_my_tools.py

# Specify custom variable name
toolvaluator-init --server my_server --server-var app --output eval.py

# Specify specific tools
toolvaluator-init --server my_server --tools tool1 tool2 tool3

# Overwrite existing file
toolvaluator-init --server my_server --output eval.py --force

环境变量

  • OPENAI_API_KEY:用于OpenAI模型的API密钥

用例

1.型号比较

测试哪种模型最适合您的工具:

toolvaluator --server my_server --model gpt-4o
toolvaluator --server my_server --model gpt-4o-mini
toolvaluator --server my_server --model claude-3-5-sonnet

注意:如果您正在使用 base_url 指向定制托管模型, 我们假设正在提供openai提供者或openai风格的API。 这恰好是LM工作室和Ollama提供的。

2.工具模式优化

迭代工具描述和模式以提高模型准确性:

# Before: vague description
@mcp.tool()
def search(q: str) -> str:
    """Search stuff."""
    ...

# After: clear, specific description
@mcp.tool()
def search_docs(query: str) -> str:
    """
    Search through company documentation including policies,
    procedures, and internal wikis.

    Args:
        query: Search keywords or natural language question
    """
    ...

3.CI/CD质量门

在CI/CD管道中使用生成的评估脚本来确保工具质量:

第一步:生成评估脚本(一次性)

toolvaluator-init --server my_server --output eval_tools.py
# Edit eval_tools.py to add your evaluation examples
# Commit eval_tools.py to your repository

步骤2:添加到CI管道

GitHub操作示例(.github/workflows/test.yml):

name: Test MCP Tools

on: [push, pull_request]

jobs:
  test-tools:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install dependencies
        run: |
          pip install toolvaluator
          pip install -r requirements.txt  # Your project dependencies

      - name: Evaluate MCP Tools
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          python eval_tools.py --model gpt-4o-mini --min-score 0.85 --verbose

直接使用CLI:

# Fail the build if tool-calling accuracy drops below 85%
toolvaluator --server my_server --min-score 0.85

优点:

  • 在工具描述或模式中捕捉回归
  • 部署前确保模型兼容性
  • 随时间跟踪质量指标
  • 防止工具调用精度下降

4.延迟基准测试

跨模型版本或配置跟踪工具调用延迟:

# Compare latency between models
python eval_tools.py --model gpt-4o-mini --verbose > results_mini.txt
python eval_tools.py --model gpt-4o --verbose > results_4o.txt

# Analyze latency stats from output
grep "Latency stats" results_*.txt

5.自定义评估工作流程

为不同场景创建专门的评估脚本:

# Generate evaluation for production tools
toolvaluator-init --server prod_server --output eval_prod.py

# Generate evaluation for experimental tools
toolvaluator-init --server experimental_server --output eval_experimental.py

# Run both in your test suite
python eval_prod.py --model gpt-4o --min-score 0.90      # High bar for prod
python eval_experimental.py --model gpt-4o --min-score 0.70  # Lower bar for experiments

贡献

欢迎投稿!请随时提交拉取请求。

许可证

MIT许可证

鸣谢

内置:

目录标签

目录标签

PythonClaudeAI代理LLM评估本地部署工具调用性能测试模型优化MCP工具

支持客户端

Claude

接入字段

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

stdio

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

none

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

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

0

权限和风险

stdionone部署方式未说明

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

安装前确认

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

来源信息

继续浏览同类 MCP