# MCP Server Tool Evaluation Support
## Overview
Add support for evaluating tools from remote MCP servers without
requiring Python callables. Enables direct evaluation of any
MCP-compatible tool server.
## What's New
### Core Features
- **`MCPToolRegistry`**: Evaluate tools from a single MCP server
- **`CompositeMCPRegistry`**: Evaluate tools from multiple MCP servers
simultaneously
- **Automatic loaders**: `load_from_stdio()` and `load_from_http()` to
fetch tools from running servers
- **Automatic namespacing**: Tools prefixed with server name (e.g.,
`server_tool_name`)
- **Smart name resolution**: Use short names if unique, full names if
ambiguous
- **OpenAI strict mode**: Automatic schema conversion prevents parameter
hallucinations
### Usage
**Automatic Loading:**
```python
from arcade_evals import load_from_stdio, MCPToolRegistry
# Load tools automatically from MCP server
tools = load_from_stdio(["npx", "-y", "@modelcontextprotocol/server-github"])
registry = MCPToolRegistry(tools)
```
**Single MCP Server:**
```python
from arcade_evals import MCPToolRegistry, ExpectedToolCall
registry = MCPToolRegistry(mcp_tools)
suite = EvalSuite(catalog=registry)
suite.add_case(
expected_tool_calls=[
ExpectedToolCall(tool_name="tool_name", args={...})
]
)
```
**Multiple MCP Servers:**
```python
from arcade_evals import CompositeMCPRegistry, load_from_stdio
# Load from multiple servers
github_tools = load_from_stdio(["npx", "-y", "@modelcontextprotocol/server-github"])
slack_tools = load_from_stdio(["npx", "-y", "@modelcontextprotocol/server-slack"])
composite = CompositeMCPRegistry(
tool_lists={
"github": github_tools,
"slack": slack_tools,
}
)
suite = EvalSuite(catalog=composite)
suite.add_case(
expected_tool_calls=[
ExpectedToolCall(tool_name="github_list_issues", args={...})
]
)
```
## Implementation
### Files Changed
- **`libs/arcade-evals/arcade_evals/registry.py`** (NEW): Registry
abstractions and implementations
- **`libs/arcade-evals/arcade_evals/loaders.py`** (NEW): Automatic tool
loading from MCP servers
- **`libs/arcade-evals/arcade_evals/eval.py`** (MODIFIED): Enhanced
`ExpectedToolCall` and evaluation logic
- **`libs/arcade-evals/arcade_evals/__init__.py`** (MODIFIED): Exported
new registries and loaders
### Key Technical Details
- Added `BaseToolRegistry` interface for abstraction
- `MCPToolRegistry` handles single server tools
- `CompositeMCPRegistry` manages multiple servers with collision
detection
- `load_from_stdio()` and `load_from_http()` for automatic tool
discovery
- Fixed name normalization bug: MCP tools use underscores (not dots)
- Optimized tool copying: 2.5x faster via shallow copy
## Testing
- ✅ 41 tests passing (25 new tests added)
- ✅ `test_eval_mcp_registry.py`: MCPToolRegistry functionality
- ✅ `test_eval_composite_mcp.py`: CompositeMCPRegistry with multiple
servers
- ✅ Verified backward compatibility with Python tools
## Backward Compatibility
✅ **100% backward compatible** - No breaking changes
## Breaking Changes
**None**
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds end-to-end eval UX: examples, a robust CLI runner, and rich
outputs.
>
> - **New examples**: `eval_arcade_gateway.py`,
`eval_stdio_mcp_server.py`, `eval_http_mcp_server.py`,
`eval_comprehensive_comparison.py` with timeouts, error handling, and
track-based comparisons; detailed `README.md`
> - **CLI runner**: `arcade_cli/evals_runner.py` to execute
evals/capture in parallel with progress, error isolation, failed-only
filtering, context inclusion, and multi-provider/model support
> - **Output formatters**: `arcade_cli/formatters/` (txt, md, html,
json) for evals and capture; comparative and multi-model HTML with tabs
and context rendering
> - **Display refactor**: `display.py` now supports writing multiple
formats, failed-only disclaimers, include-context, and improved console
summaries
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ff8acf9c34a6b61462a019a1ee9df081006517d0. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Francisco Liberal <francisco@arcade.dev>
Co-authored-by: Mateo Torres <torresmateo@gmail.com>
142 lines
4.1 KiB
Python
142 lines
4.1 KiB
Python
"""Remote HTTP/SSE MCP server evaluation.
|
|
|
|
This example demonstrates loading and evaluating tools from remote MCP servers
|
|
accessible via HTTP or Server-Sent Events (SSE).
|
|
|
|
NOTE: This requires a running HTTP MCP server. Update the configuration below
|
|
with your server details.
|
|
|
|
Run:
|
|
arcade evals examples/evals/eval_http_mcp_server.py \\
|
|
-p openai:gpt-4o \\
|
|
-k openai:YOUR_KEY \\
|
|
-o results.html -d
|
|
"""
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
from arcade_evals import (
|
|
BinaryCritic,
|
|
EvalRubric,
|
|
EvalSuite,
|
|
ExpectedMCPToolCall,
|
|
tool_eval,
|
|
)
|
|
|
|
# =============================================================================
|
|
# CONFIGURATION - Update these for your HTTP MCP server
|
|
# =============================================================================
|
|
|
|
# Example: GitHub Copilot MCP (requires GitHub token)
|
|
HTTP_MCP_URL = os.environ.get("MCP_SERVER_URL", "https://api.githubcopilot.com/mcp/")
|
|
HTTP_MCP_TOKEN = os.environ.get("GITHUB_PAT", "YOUR_GITHUB_TOKEN_HERE")
|
|
|
|
# Example: SSE-based MCP server
|
|
SSE_MCP_URL = os.environ.get("SSE_MCP_URL", "https://mcp.example.com/sse")
|
|
|
|
default_rubric = EvalRubric(
|
|
fail_threshold=0.7,
|
|
warn_threshold=0.9,
|
|
)
|
|
|
|
|
|
# =============================================================================
|
|
# EVAL SUITE - HTTP MCP Server
|
|
# =============================================================================
|
|
|
|
|
|
@tool_eval()
|
|
async def eval_http_mcp_server() -> EvalSuite:
|
|
"""Evaluate tools from HTTP MCP server."""
|
|
suite = EvalSuite(
|
|
name="HTTP MCP Server Evaluation",
|
|
system_message="You are a helpful assistant with access to remote tools.",
|
|
rubric=default_rubric,
|
|
)
|
|
|
|
print("\n Loading HTTP MCP server...")
|
|
|
|
try:
|
|
await asyncio.wait_for(
|
|
suite.add_mcp_server(
|
|
url=HTTP_MCP_URL,
|
|
headers={"Authorization": f"Bearer {HTTP_MCP_TOKEN}"},
|
|
use_sse=False, # Use HTTP streaming
|
|
),
|
|
timeout=15.0,
|
|
)
|
|
print(" ✓ HTTP MCP server")
|
|
except asyncio.TimeoutError:
|
|
print(" ✗ HTTP MCP server - timeout")
|
|
return suite
|
|
except Exception as e:
|
|
print(f" ✗ HTTP MCP server - {type(e).__name__}: {e}")
|
|
return suite
|
|
|
|
# Add test cases based on your server's tools
|
|
# Example: If your server has an echo tool
|
|
suite.add_case(
|
|
name="HTTP server tool call",
|
|
user_message="Echo 'Hello from HTTP'",
|
|
expected_tool_calls=[
|
|
ExpectedMCPToolCall(
|
|
tool_name="echo", # Adjust to match your server's tool names
|
|
args={"message": "Hello from HTTP"},
|
|
)
|
|
],
|
|
critics=[
|
|
BinaryCritic(critic_field="message", weight=1.0),
|
|
],
|
|
)
|
|
|
|
return suite
|
|
|
|
|
|
# =============================================================================
|
|
# EVAL SUITE - SSE MCP Server
|
|
# =============================================================================
|
|
|
|
|
|
@tool_eval()
|
|
async def eval_sse_mcp_server() -> EvalSuite:
|
|
"""Evaluate tools from SSE MCP server."""
|
|
suite = EvalSuite(
|
|
name="SSE MCP Server Evaluation",
|
|
system_message="You are a helpful assistant with access to SSE-connected tools.",
|
|
rubric=default_rubric,
|
|
)
|
|
|
|
print("\n Loading SSE MCP server...")
|
|
|
|
try:
|
|
await asyncio.wait_for(
|
|
suite.add_mcp_server(
|
|
url=SSE_MCP_URL,
|
|
use_sse=True, # Use SSE transport
|
|
headers={"Accept": "text/event-stream"},
|
|
),
|
|
timeout=15.0,
|
|
)
|
|
print(" ✓ SSE MCP server")
|
|
except asyncio.TimeoutError:
|
|
print(" ✗ SSE MCP server - timeout")
|
|
return suite
|
|
except Exception as e:
|
|
print(f" ✗ SSE MCP server - {type(e).__name__}: {e}")
|
|
return suite
|
|
|
|
# Add test cases for your SSE server's tools
|
|
suite.add_case(
|
|
name="SSE server tool call",
|
|
user_message="Get status",
|
|
expected_tool_calls=[
|
|
ExpectedMCPToolCall(
|
|
tool_name="get_status", # Adjust to match your server's tools
|
|
args={},
|
|
)
|
|
],
|
|
critics=[],
|
|
)
|
|
|
|
return suite
|