BooCode wrapper tools for the 4 new MCP tools added to the codecontext sidecar (Go side committed separately at /opt/forks/codecontext). - get_blast_radius: reverse-edge BFS — "what breaks if I change this?" - get_hot_files: most-imported files by incoming edge count - get_routes: Fastify/Express route extraction via tree-sitter AST - get_middleware: middleware detection via import + registration patterns Wrappers follow the existing codecontext pattern: Zod input → callCodecontext → ToolDef export. Registered in ALL_TOOLS (alpha-sorted). All 4 are read-only. codecontext sidecar rebuilt from commit b19e646 with the 4 new Go handlers (2130 lines, 29 tests). Reviewer fixes applied: defer RUnlock on Tier 2 handlers, extractObjectProperty delegates to extractStringValue for template-literal route paths. 363/363 server tests passing. No schema changes, no frontend changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { z } from 'zod';
|
|
import type { ToolDef } from '../../tools.js';
|
|
import { callCodecontext, type CodecontextResponse } from '../../codecontext_client.js';
|
|
|
|
export const GetMiddlewareInput = z.object({});
|
|
export type GetMiddlewareInputT = z.infer<typeof GetMiddlewareInput>;
|
|
|
|
const DESCRIPTION =
|
|
'Detects middleware registrations in the project. Identifies auth, CORS, rate-limit, ' +
|
|
'security-headers, error-handler, logging, and validation middleware by analyzing ' +
|
|
'import names (@fastify/cors, helmet, etc.) and registration patterns ' +
|
|
'(app.register, app.addHook, app.setErrorHandler).';
|
|
|
|
export async function executeGetMiddleware(
|
|
_input: GetMiddlewareInputT,
|
|
projectPath: string,
|
|
fetcher: typeof fetch = fetch,
|
|
): Promise<CodecontextResponse> {
|
|
return callCodecontext({ toolName: 'get_middleware', args: {}, projectPath }, fetcher);
|
|
}
|
|
|
|
export const getMiddleware: ToolDef<GetMiddlewareInputT> = {
|
|
name: 'get_middleware',
|
|
description: DESCRIPTION,
|
|
inputSchema: GetMiddlewareInput,
|
|
jsonSchema: {
|
|
type: 'function',
|
|
function: {
|
|
name: 'get_middleware',
|
|
description: DESCRIPTION,
|
|
parameters: {
|
|
type: 'object',
|
|
properties: {},
|
|
additionalProperties: false,
|
|
},
|
|
},
|
|
},
|
|
async execute(input, projectRoot) {
|
|
return await executeGetMiddleware(input, projectRoot);
|
|
},
|
|
};
|