/** * MCP Server Testing - First-class support for testing MCP (Model Context Protocol) servers. * * Supports both stdio-based and HTTP-based MCP servers with tool invocation, * tool listing, error handling, and response time assertions. */ import type { AssertionResult } from './types'; export interface MCPServerConfig { /** Stdio-based: command to spawn the server */ command?: string; /** Stdio-based: arguments */ args?: string[]; /** HTTP-based: URL of the MCP server */ url?: string; /** Environment variables for stdio server */ env?: Record; /** Startup timeout in ms */ startup_timeout_ms?: number; } export interface MCPExpectations { /** Expected substring in tool output */ output_contains?: string | string[]; /** Output must not contain */ output_not_contains?: string | string[]; /** Expected error substring */ error_contains?: string; /** Response time constraint */ response_time_ms?: { lt?: number; gt?: number; }; /** Tools that should be listed */ tools_include?: string[]; /** Tools that should NOT be listed */ tools_exclude?: string[]; /** Exact tool count */ tool_count?: number; /** Output matches regex */ output_matches?: string; } export interface MCPTestCase { name: string; /** Tool to invoke */ tool?: string; /** Input arguments for the tool */ input?: Record; /** Action instead of tool call */ action?: 'list_tools' | 'ping' | 'initialize'; /** Expected results */ expect: MCPExpectations; /** Per-test timeout */ timeout_ms?: number; tags?: string[]; } export interface MCPTestSuite { adapter: 'mcp'; mcp_server: MCPServerConfig; tests: MCPTestCase[]; tags?: string[]; } export interface MCPToolInfo { name: string; description?: string; inputSchema?: Record; } export interface MCPToolResult { content: string; error?: string; duration_ms: number; } export interface MCPTestResult { name: string; passed: boolean; assertions: AssertionResult[]; duration_ms: number; error?: string; tags?: string[]; } export interface MCPSuiteResult { passed: number; failed: number; total: number; duration_ms: number; results: MCPTestResult[]; } /** * Evaluate MCP expectations against a tool result. */ export declare function evaluateMCPExpectations(result: MCPToolResult, expect: MCPExpectations, listedTools?: MCPToolInfo[]): AssertionResult[]; /** * Validate an MCP test suite configuration. */ export declare function validateMCPSuite(suite: MCPTestSuite): string[]; /** * Build a mock MCP tool result for testing purposes. */ export declare function buildMockMCPResult(content: string, opts?: { error?: string; duration_ms?: number; }): MCPToolResult; /** * Format MCP test results for console display. */ export declare function formatMCPResults(results: MCPSuiteResult): string; export interface MCPSecurityCheck { toolName: string; checks: MCPSecurityCheckItem[]; score: number; passed: boolean; } export interface MCPSecurityCheckItem { name: string; passed: boolean; severity: 'critical' | 'warning' | 'info'; message: string; } export interface MCPSecurityReport { tools: MCPSecurityCheck[]; overall_score: number; passed_count: number; total_count: number; critical_issues: string[]; } /** Check if a tool name suggests a dangerous operation. */ export declare function isDangerousTool(name: string): boolean; /** * Analyze security posture of MCP tools. */ export declare function analyzeMCPSecurity(tools: MCPToolInfo[], toolResults?: Map): MCPSecurityReport; /** Format security report for display. */ export declare function formatMCPSecurity(report: MCPSecurityReport): string; /** * Run MCP test suite against provided tool/action handlers. * This is the evaluation-only version - actual server spawning is done by adapters. */ export declare function evaluateMCPSuite(suite: MCPTestSuite, toolResults: Map, listedTools?: MCPToolInfo[]): MCPSuiteResult; //# sourceMappingURL=mcp-test.d.ts.map