neuroverse_assemble_context
Assemble relevant codebase file chunks by scanning directories based on search queries to provide context for development tasks.
Instructions
Scan the codebase and assemble the most relevant file chunks based on a query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query for context assembly | |
| dir | No | Root directory to scan (defaults to cwd) |
Implementation Reference
- npm/src/core/arachne.ts:33-59 (handler)The core logic for `assembleContext` which scans the codebase and scores chunks based on query words.
export function assembleContext(query: string, dir: string = process.cwd()): ContextChunk[] { const queryWords = query.toLowerCase().split(/\W+/).filter(w => w.length > 2); const allFiles = walkDir(dir); const scored: ContextChunk[] = []; for (const f of allFiles) { try { const content = readFileSync(f, "utf-8"); const lines = content.split("\n"); for (let i = 0; i < lines.length; i += 40) { const chunkLines = lines.slice(i, i + 40); const chunk = chunkLines.join("\n"); const chunkLower = chunk.toLowerCase(); let score = 0; for (const w of queryWords) { if (chunkLower.includes(w)) score++; } if (score > 0) { scored.push({ file: `${f}:${i+1}-${i+chunkLines.length}`, score, content: chunk }); } } } catch {} } scored.sort((a, b) => b.score - a.score); return scored.slice(0, 3); } - npm/src/index.ts:525-544 (registration)MCP tool registration for `neuroverse_assemble_context`.
server.registerTool( "neuroverse_assemble_context", { title: "Assemble Code Context (Arachne Protocol)", description: "Scan the codebase and assemble the most relevant file chunks based on a query.", inputSchema: AssembleContextSchema, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async (params) => { const chunks = assembleContext(params.query, params.dir); return { content: [{ type: "text" as const, text: JSON.stringify(chunks, null, 2) }], }; } ); - npm/src/index.ts:518-523 (schema)Zod schema definition for `neuroverse_assemble_context` input parameters.
const AssembleContextSchema = z .object({ query: z.string().min(1).describe("Search query for context assembly"), dir: z.string().optional().describe("Root directory to scan (defaults to cwd)"), }) .strict();