haive.mcp.tools.server_tester¶
MCP server testing and validation tools.
This module provides tools for testing MCP server configurations, validating connections, and ensuring servers are working correctly before use in production.
- The testing system provides:
Connection testing for individual servers
Batch testing for multiple servers
Health monitoring and diagnostics
Performance benchmarking
Configuration validation
- Classes:
MCPServerTester: Main testing interface TestResult: Results from server testing HealthMonitor: Continuous health monitoring
Example
Testing server configurations:
from haive.mcp.tools import MCPServerTester
from haive.mcp.config import MCPServerConfig
# Test individual server
tester = MCPServerTester()
server_config = MCPServerConfig(
name="test_server",
transport="stdio",
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem"]
)
result = await tester.test_server(server_config)
if result.success:
print(f"✅ {server_config.name} is working")
else:
print(f"❌ {server_config.name} failed: {result.error}")
# Test multiple servers
results = await tester.test_multiple_servers([server_config])
# Monitor health
monitor = tester.create_health_monitor()
await monitor.start_monitoring([server_config])
Note
Server testing requires the actual MCP packages to be installed and may need appropriate environment variables.
Classes¶
Continuous health monitoring for MCP servers. |
|
Health status for a server. |
|
Main testing interface for MCP servers. |
|
Result from testing an MCP server. |
Module Contents¶
- class haive.mcp.tools.server_tester.HealthMonitor(check_interval=60)[source]¶
Continuous health monitoring for MCP servers.
Initialize health monitor.
- Parameters:
check_interval (int) – Seconds between health checks
- async start_monitoring(servers)[source]¶
Start monitoring the specified servers.
- Parameters:
servers (list[haive.mcp.config.MCPServerConfig]) – List of server configurations to monitor
- class haive.mcp.tools.server_tester.MCPServerTester[source]¶
Main testing interface for MCP servers.
Initialize server tester.
- create_health_monitor(check_interval=60)[source]¶
Create a health monitor instance.
- Parameters:
check_interval (int) – Seconds between health checks
- Returns:
HealthMonitor instance
- Return type:
- async test_config(config)[source]¶
Test an entire MCP configuration.
- Parameters:
config (haive.mcp.config.MCPConfig) – MCP configuration to test
- Returns:
Dictionary mapping server names to test results
- Return type:
- async test_multiple_servers(servers, timeout=60, parallel=True)[source]¶
Test multiple servers.
- Parameters:
servers (list[haive.mcp.config.MCPServerConfig]) – List of server configurations to test
timeout (int) – Timeout per server in seconds
parallel (bool) – Whether to test servers in parallel
- Returns:
List of TestResult objects
- Return type:
- async test_server(server_config, timeout=60)[source]¶
Test a single MCP server configuration.
- Parameters:
server_config (haive.mcp.config.MCPServerConfig) – Server configuration to test
timeout (int) – Timeout in seconds for the test
- Returns:
TestResult with test outcome
- Return type: