Skip to main content
Glama
damian-pramparo

Enterprise Code Search MCP Server

search_codebase

Search enterprise codebases using semantic AI to find relevant code snippets across local projects and Git repositories based on natural language queries.

Instructions

Search the indexed codebase using semantic search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of results
project_filterNoFilter by specific project name
queryYesSearch query

Implementation Reference

  • The core handler function that executes the 'search_codebase' tool. Performs semantic search query on ChromaDB vector store, handles project filtering, formats results with similarity scores, file metadata, and code snippets in Markdown.
    async searchCodebase(args: {
      query: string;
      limit?: number;
      project_filter?: string;
    }) {
      const { query, limit = 10, project_filter } = args;
      
      const collection = await this.getOrCreateCollection();
      
      let whereClause: any = {};
      if (project_filter) {
        whereClause.project_id = { "$eq": project_filter };
      }
      
      const results = await collection.query({
        queryTexts: [query],
        nResults: limit,
        where: Object.keys(whereClause).length > 0 ? whereClause : undefined
      });
      
      if (!results.documents[0] || results.documents[0].length === 0) {
        return {
          content: [
            {
              type: "text",
              text: "No results found for your query."
            }
          ]
        };
      }
      
      const formattedResults = results.documents[0]
        .map((doc, i) => {
          const metadata = results.metadatas?.[0]?.[i] as any;
          const distance = results.distances?.[0]?.[i] || 0;
          const similarity = (1 - distance).toFixed(3);
          
          return `## Result ${i + 1} (Similarity: ${similarity})\n` +
                 `**File:** ${metadata?.file_path}\n` +
                 `**Project:** ${metadata?.project_name}\n\n` +
                 `\`\`\`${metadata?.file_type}\n${doc}\n\`\`\`\n`;
        })
        .join('\n---\n\n');
      
      return {
        content: [
          {
            type: "text",
            text: `Found ${results.documents[0].length} results for: "${query}"\n\n${formattedResults}`
          }
        ]
      };
    }
  • Input schema definition for the 'search_codebase' tool, specifying parameters: query (required string), limit (optional number, default 10), project_filter (optional string).
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Search query"
        },
        limit: {
          type: "number",
          description: "Maximum number of results",
          default: 10
        },
        project_filter: {
          type: "string",
          description: "Filter by specific project name"
        }
      },
      required: ["query"]
    }
  • src/index.ts:64-86 (registration)
    Registration of the 'search_codebase' tool in the ListTools response, including name, description, and input schema.
    {
      name: "search_codebase",
      description: "Search the indexed codebase using semantic search",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query"
          },
          limit: {
            type: "number",
            description: "Maximum number of results",
            default: 10
          },
          project_filter: {
            type: "string",
            description: "Filter by specific project name"
          }
        },
        required: ["query"]
      }
    },
  • src/index.ts:114-115 (registration)
    Dispatch/registration in the CallToolRequestSchema handler switch statement, routing tool calls to the searchCodebase method.
    case "search_codebase":
      return await this.searchCodebase(args as any);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool performs a 'semantic search' but doesn't explain what that entails (e.g., natural language understanding, relevance scoring), nor does it cover aspects like rate limits, authentication needs, or whether it's read-only (implied but not explicit). This leaves significant gaps for an agent to understand operational behavior.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It is appropriately sized and front-loaded, making it easy for an agent to quickly grasp the core purpose.

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

Completeness2/5

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

Given the tool's complexity (semantic search with multiple parameters) and the lack of annotations and output schema, the description is insufficient. It doesn't explain what the search returns (e.g., code snippets, file paths), how results are ranked, or any limitations (e.g., indexing requirements). This leaves critical context gaps for effective tool use.

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

Parameters3/5

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

The input schema has 100% description coverage, with clear documentation for 'query', 'limit', and 'project_filter'. The description adds no additional parameter semantics beyond what's in the schema, such as query format examples or filter usage details. This meets the baseline of 3, as the schema adequately handles parameter documentation.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('search') and resource ('indexed codebase'), and it specifies the search method ('semantic search'). However, it doesn't explicitly differentiate from sibling tools like 'list_indexed_projects' or 'get_embedding_provider_info', which reduces its score from a perfect 5.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer 'search_codebase' over 'list_indexed_projects' for browsing projects or 'get_embedding_provider_info' for understanding search capabilities, nor does it specify prerequisites like needing an indexed codebase first.

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/damian-pramparo/semantic-context-mcp'

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