feat: Add testing framework and initial test cases for various tools and database operations
This commit is contained in:
35
tests/helpers/tool-helper.ts
Normal file
35
tests/helpers/tool-helper.ts
Normal 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());
|
||||
}
|
||||
Reference in New Issue
Block a user