setupHandlers() — mcp Function Reference
Architecture documentation for the setupHandlers() function in server.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD f3f1255a_0f7f_c2b0_e99d_eae489cac19d["setupHandlers()"] c038b2a8_9211_043e_36bd_8ccef7d18ab5["constructor()"] c038b2a8_9211_043e_36bd_8ccef7d18ab5 -->|calls| f3f1255a_0f7f_c2b0_e99d_eae489cac19d 90af3150_ce81_c645_faa7_5b8b9bcf5ecc["has()"] f3f1255a_0f7f_c2b0_e99d_eae489cac19d -->|calls| 90af3150_ce81_c645_faa7_5b8b9bcf5ecc 6407330b_8aa1_cc04_569a_747f6b1debfd["set()"] f3f1255a_0f7f_c2b0_e99d_eae489cac19d -->|calls| 6407330b_8aa1_cc04_569a_747f6b1debfd d6ed9355_f977_306b_b0ef_d7220fdefe68["get()"] f3f1255a_0f7f_c2b0_e99d_eae489cac19d -->|calls| d6ed9355_f977_306b_b0ef_d7220fdefe68 e5737e93_21e3_4389_2f31_c2c4b7b9ef6c["handler()"] f3f1255a_0f7f_c2b0_e99d_eae489cac19d -->|calls| e5737e93_21e3_4389_2f31_c2c4b7b9ef6c style f3f1255a_0f7f_c2b0_e99d_eae489cac19d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/server.ts lines 147–198
private setupHandlers() {
const experiment = process.env.SUPERMODEL_EXPERIMENT;
// Experiment variants: swap tool definitions to test parallel calling behavior
let allTools: typeof symbolContextTool[];
switch (experiment) {
case 'minimal-schema':
allTools = [{ tool: symbolContextMinimalTool, handler: symbolContextTool.handler }];
break;
case 'search-symbol':
allTools = [searchSymbolEndpoint];
break;
case 'split-tools':
allTools = [findDefinitionEndpoint, traceCallsEndpoint];
break;
case 'annotate':
allTools = [annotateEndpoint];
break;
case 'graphrag':
allTools = [exploreFunctionEndpoint];
break;
default:
allTools = [symbolContextTool];
break;
}
// Create a map for quick handler lookup
const toolMap = new Map<string, typeof allTools[0]>();
for (const t of allTools) {
if (toolMap.has(t.tool.name)) {
throw new Error(`Duplicate tool name: ${t.tool.name}`);
}
toolMap.set(t.tool.name, t);
}
this.server.server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: allTools.map(t => t.tool),
};
});
this.server.server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
const tool = toolMap.get(name);
if (tool) {
return tool.handler(this.client, args, this.defaultWorkdir);
}
throw new Error(`Unknown tool: ${name}`);
});
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does setupHandlers() do?
setupHandlers() is a function in the mcp codebase.
What does setupHandlers() call?
setupHandlers() calls 4 function(s): get, handler, has, set.
What calls setupHandlers()?
setupHandlers() is called by 1 function(s): constructor.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free