Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYesSearch query for context assembly
dirNoRoot directory to scan (defaults to cwd)

Implementation Reference

  • 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);
    }
  • 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) }],
        };
      }
    );
  • 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();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/joshua400/neuroverse'

If you have feedback or need assistance with the MCP directory API, please join our Discord server