Skip to main content
Glama
ARQAWA

code_nav MCP

by ARQAWA

code_nav.search

Read-only

Performs deterministic search and navigation in code repositories using git-aware methods to find relevant code sections based on a given task.

Instructions

Main deterministic code navigation workflow.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYes
memory_contextNo
scopeNo
limitNo
max_context_tokensNo

Implementation Reference

  • The main handler function for the 'code_nav.search' tool. Orchestrates the full search workflow: loads repo config, lists candidate files, plans the query, finds files by name (fff), performs exact pattern searches (with fallback), ranks candidates, extracts context, and returns packed results.
    export async function search(input: SearchInput, cwd = process.cwd()) {
      const repo = await getRepoRoot(cwd);
      const loaded = await loadConfig(repo.repoRoot);
      const listed = await listCandidateFiles(repo.repoRoot, repo.isGitRepo, loaded.config);
      const warnings = [...repo.warnings, ...loaded.warnings, ...listed.warnings];
      const limit = clampLimit(input.limit, loaded.config.result_limit, 50);
      const maxTokens = clampLimit(input.max_context_tokens, DEFAULT_CONTEXT_TOKENS, 50_000);
      const plan = planQuery(input.task, input.memory_context, input.scope ?? []);
    
      const fileHits = [];
      for (const fileQuery of plan.file_queries.slice(0, 8)) {
        const found = await fffFindFiles(repo.repoRoot, listed.files, fileQuery, input.scope, limit);
        if (found.warning) warnings.push(`fff: ${found.warning}`);
        fileHits.push(...found.results);
      }
    
      let exactHits: ExactSearchResult[] = [];
      if (plan.exact_patterns.length > 0) {
        try {
          exactHits = await exactSearch(
            {
              patterns: plan.exact_patterns,
              scope: input.scope,
              limit: Math.max(limit * 4, 40),
              context_lines: 1,
              fixed: true,
              case_sensitive: false,
            },
            cwd,
          );
        } catch {
          const fallback = await rgExactSearch(
            repo.repoRoot,
            listed.files,
            plan.exact_patterns,
            input.scope,
            Math.max(limit * 4, 40),
            1,
            true,
            false,
          );
          exactHits = fallback.results;
          if (fallback.warning) warnings.push(fallback.warning);
        }
      }
    
      const candidates = rankCandidates(plan, fileHits, exactHits, input.task, limit);
      const extracted = await extractContext(
        repo.repoRoot,
        targetsFromCandidates(candidates),
        input.task,
        maxTokens,
      );
      warnings.push(...extracted.warnings);
      return {
        query_plan: plan,
        results: packSearchResults(candidates, extracted.blocks, maxTokens),
        warnings,
      };
    }
  • Input schema type for the search tool: task (string), memory_context (optional string), scope (optional string array), limit (optional positive int), max_context_tokens (optional positive int).
    export interface SearchInput {
      task: string;
      memory_context?: string;
      scope?: string[];
      limit?: number;
      max_context_tokens?: number;
    }
  • src/mcp.ts:116-130 (registration)
    Registration of the 'code_nav.search' tool with the MCP server. Registers it with description, inputSchema (Zod validation for task, memory_context, scope, limit, max_context_tokens), readOnlyHint annotation, and a handler that calls the imported 'search' function.
    server.registerTool(
      "code_nav.search",
      {
        description: "Main deterministic code navigation workflow.",
        inputSchema: {
          task: z.string(),
          memory_context: z.string().optional(),
          scope: z.array(z.string()).optional(),
          limit: z.number().int().positive().optional(),
          max_context_tokens: z.number().int().positive().optional(),
        },
        annotations: { readOnlyHint: true, openWorldHint: false },
      },
      async (input) => mcpJson(await search(input)),
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate readOnlyHint=true and openWorldHint=false. The description adds 'deterministic' but no other behavioral details (e.g., performance, limitations, or what 'code navigation' entails). No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise but comes at the cost of completeness. It is appropriately front-loaded but insufficiently informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 5 parameters, no output schema, and moderate complexity, the description is severely lacking. It omits what the tool does, what it returns, and how to effectively use it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 5 parameters with 0% description coverage. The description provides no explanation of any parameter, leaving the agent to infer meaning from names alone (e.g., task, scope, limit).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Main deterministic code navigation workflow' is vague. It uses 'main' but does not specify the actual function (e.g., searching, navigating) or differentiate from sibling tools like exact_search or structural_search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. The phrase 'main workflow' implies primacy but provides no context for when to choose it over more specific siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ARQAWA/code-nav-mcp'

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