feat: Add testing framework and initial test cases for various tools and database operations

This commit is contained in:
ethan.chen
2026-01-07 10:05:04 +08:00
parent 372b52b214
commit 47ecc40186
23 changed files with 1781 additions and 40 deletions

View File

@@ -0,0 +1,35 @@
/**
* Tool testing helper - helps test MCP tools
*/
import { mcpServer } from "../../src/server.js";
import type { ToolHandler } from "../../src/server.js";
/**
* Call a tool by name with arguments
*/
export async function callTool(
toolName: string,
args: Record<string, unknown>
): Promise<{
content: Array<{ type: string; text: string }>;
isError?: boolean;
}> {
// Get the tool handler from the server
const tools = mcpServer.getTools();
const toolEntry = tools.get(toolName);
if (!toolEntry) {
throw new Error(`Tool ${toolName} not found`);
}
return await toolEntry.handler(args);
}
/**
* Get all registered tools
*/
export function getRegisteredTools(): string[] {
const tools = mcpServer.getTools();
return Array.from(tools.keys());
}