Skip to main content
Glama
doko89
by doko89

search_context

Find information across all project documentation files by searching for keywords in local markdown files organized by project and layer.

Instructions

Search for a keyword across all context files in all projects

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Implementation Reference

  • Main handler function that searches for the query across all projects in the context directory by listing projects and recursively searching each one.
    async function searchContext(query: string): Promise<any[]> {
      const projects = await listProjects();
      const results: any[] = [];
    
      for (const project of projects) {
        const matches = await searchInProject(project, "", query);
        if (matches.length > 0) {
          results.push({
            project,
            matches,
          });
        }
      }
    
      return results;
    }
  • Recursive helper function that traverses project directories, reads .md files, and finds lines matching the query (case-insensitive).
    async function searchInProject(
      projectName: string,
      subPath: string,
      query: string
    ): Promise<any[]> {
      const fullPath = path.join(CONTEXT_DIR, projectName, subPath);
      const entries = await fs.readdir(fullPath, { withFileTypes: true });
      const matches: any[] = [];
    
      for (const entry of entries) {
        const entryPath = path.join(subPath, entry.name);
    
        if (entry.isDirectory()) {
          const subMatches = await searchInProject(projectName, entryPath, query);
          matches.push(...subMatches);
        } else if (entry.name.endsWith(".md")) {
          const content = await readContext(projectName, entryPath);
          const lines = content.split("\n");
          const queryLower = query.toLowerCase();
    
          lines.forEach((line, index) => {
            if (line.toLowerCase().includes(queryLower)) {
              matches.push({
                file: entryPath,
                line: index + 1,
                content: line.trim(),
              });
            }
          });
        }
      }
    
      return matches;
    }
  • Tool schema definition including name, description, and input schema (requires 'query' string). Used in ListTools response.
    {
      name: "search_context",
      description:
        "Search for a keyword across all context files in all projects",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query",
          },
        },
        required: ["query"],
      },
    },
  • src/index.ts:287-313 (registration)
    Registration in the CallToolRequest handler switch: validates input, calls searchContext, and formats response as JSON with total results.
    case "search_context": {
      const query = args.query as string;
      if (!query) {
        throw new Error("query is required");
      }
    
      const results = await searchContext(query);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                query,
                total_results: results.reduce(
                  (sum, r) => sum + r.matches.length,
                  0
                ),
                results,
              },
              null,
              2
            ),
          },
        ],
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the search scope ('across all context files in all projects') but doesn't describe what 'search' entails (e.g., exact match, fuzzy search, case sensitivity), what the output format looks like, or any limitations like rate limits or permissions needed. This leaves significant gaps for a tool with no annotation coverage.

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 immediately conveys the core functionality without any wasted words. It's appropriately sized and front-loaded with the essential information.

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?

For a search tool with no annotations and no output schema, the description is incomplete. It doesn't explain what constitutes a 'context file', how results are returned, whether there's pagination or sorting, or what happens with no matches. Given the complexity of search functionality and lack of structured data, more context is needed.

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 the single parameter 'query' documented as 'Search query'. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 where the schema does the heavy lifting.

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 ('context files in all projects'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'read_context' or 'get_project_structure', which prevents a perfect score.

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 like 'read_context' or 'get_project_structure'. It doesn't specify whether this is for full-text search versus structured retrieval, or mention any prerequisites or exclusions for usage.

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/doko89/mcp-mycontext'

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