Skip to main content
Glama
kvnpetit

SRC (Structured Repo Context)

by kvnpetit

get_index_status

Verify if a codebase is indexed for AI search. Returns file count, chunk count, and indexed languages to confirm readiness.

Instructions

Check if a codebase is indexed and ready for search. USE THIS to verify index exists before searching. Returns file count, chunk count, and indexed languages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryNoPath to the directory to check (defaults to current directory).

Implementation Reference

  • Main handler function that validates the directory, checks if an index exists, connects to the vector store, retrieves status (file count, chunk count, language breakdown), and returns a formatted result.
    export async function execute(
      input: GetIndexStatusInput,
    ): Promise<FeatureResult> {
      const { directory } = input;
    
      // Validate directory exists
      if (!fs.existsSync(directory)) {
        return {
          success: false,
          error: `Directory not found: ${directory}`,
        };
      }
    
      const absoluteDir = path.resolve(directory);
      const indexPath = getIndexPath(absoluteDir);
    
      // Check if index exists
      if (!fs.existsSync(indexPath)) {
        const status: IndexStatus = {
          directory: absoluteDir,
          indexPath,
          exists: false,
          totalChunks: 0,
          totalFiles: 0,
          languages: {},
        };
    
        return {
          success: true,
          message: `No index found for ${absoluteDir}. Run index_codebase to create one.`,
          data: status,
        };
      }
    
      try {
        const vectorStore = createVectorStore(absoluteDir, EMBEDDING_CONFIG);
        await vectorStore.connect();
    
        const status = await vectorStore.getStatus(absoluteDir);
        vectorStore.close();
    
        // Format language breakdown
        const languageLines = Object.entries(status.languages)
          .sort(([, a], [, b]) => b - a)
          .map(([lang, count]) => `  - ${lang}: ${String(count)} chunks`);
    
        const message = [
          `Index Status for ${absoluteDir}`,
          ``,
          `Index Path: ${status.indexPath}`,
          `Total Files: ${String(status.totalFiles)}`,
          `Total Chunks: ${String(status.totalChunks)}`,
          ``,
          `Languages:`,
          ...languageLines,
        ].join("\n");
    
        return {
          success: true,
          message,
          data: status,
        };
      } catch (err) {
        const errorMsg = err instanceof Error ? err.message : String(err);
        return {
          success: false,
          error: `Failed to read index status: ${errorMsg}`,
        };
      }
    }
  • Zod schema defining the input: an optional directory string defaulting to '.'.
    export const getIndexStatusSchema = z.object({
      directory: z
        .string()
        .optional()
        .default(".")
        .describe("Path to the directory to check (defaults to current directory)"),
    });
  • Feature registration object: name 'get_index_status', description, schema reference, and execute function reference.
    export const getIndexStatusFeature: Feature<typeof getIndexStatusSchema> = {
      name: "get_index_status",
      description:
        "Check if a codebase is indexed and ready for search. USE THIS to verify index exists before searching. Returns file count, chunk count, and indexed languages.",
      schema: getIndexStatusSchema,
      execute,
    };
  • Feature registry array listing getIndexStatusFeature as one of five exposed features.
    export const features: Feature[] = [
      infoFeature,
      indexCodebaseFeature,
      searchCodeFeature,
      getIndexStatusFeature,
      updateIndexFeature,
    ];
  • Helper function that constructs the .src-index path for a given directory.
     */
    export function getIndexPath(directory: string): string {
      return path.join(directory, INDEX_DIR_NAME);
    }
Behavior3/5

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

No annotations provided, so description must disclose behavior. It lists return values (file count, chunk count, indexed languages) but omits details on permissions, error handling, or performance implications.

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?

Two sentences: first states purpose, second adds usage guidance and return values. No wasted words, information is front-loaded.

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

Completeness4/5

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

Covers purpose, usage, and return values. No output schema, but description compensates. Lacks details on error cases, but sufficient for a simple verification tool.

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?

Schema description coverage is 100% for the single parameter 'directory'. The tool description adds no additional meaning beyond the schema's existing description.

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

Purpose5/5

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

Description clearly states the tool checks if a codebase is indexed and ready for search. It names the specific resource and provides context relative to sibling tools like index_codebase and search_code.

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

Usage Guidelines4/5

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

Explicitly tells when to use: 'USE THIS to verify index exists before searching.' Provides clear context for usage, though does not list alternatives or when not to use.

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/kvnpetit/structured-repo-context-mcp'

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