Skip to main content
Glama

doc_find

Search and retrieve documents from local storage using queries to find relevant information quickly.

Instructions

Alias of doc.find

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYes
topNo
limitNo

Implementation Reference

  • Core handler function for document search using MiniSearch index. Loads index, builds if missing, searches, and extracts snippets.
    export async function docFind(q: string, top = 5) {
      let idx = loadIndex();
      if (!idx) { await indexBuild(CONFIG.sandboxDir); idx = loadIndex(); }
      if (!idx) return [];
      const res = idx.mini.search(q, { prefix: true, fuzzy: 0.2, boost: { title: 2 } }).slice(0, top);
      return res.map((r: any) => {
        const doc = idx.docs.find(d => d.id === r.id)!;
        const text = doc.text || '';
        const i = text.toLowerCase().indexOf(q.toLowerCase());
        const start = Math.max(0, i - 80);
        const end = Math.min(text.length, i + 80);
        const snippet = text.slice(start, end).replace(/\s+/g, ' ');
        return { path: doc.path, score: r.score, snippet };
      });
    }
  • Zod input schema defining parameters for doc_find: query string and optional top/limit numbers.
    const docFindShape = {
      q: z.string(),
      top: z.number().int().optional(),
      limit: z.number().int().optional()
    };
  • src/server.ts:116-121 (registration)
    MCP server registration for the 'doc_find' tool, alias calling the docFind handler.
    server.tool('doc_find', 'Alias of doc.find',
      docFindShape, OPEN,
      async ({ q, top, limit }) => {
        const res = await docFind(q, top ?? limit ?? 5);
        return { content: [{ type: 'text', text: JSON.stringify(res) }] };
      }
  • src/server.ts:109-115 (registration)
    Primary MCP server registration for 'doc.find' tool using the same handler and schema.
    server.tool('doc.find', 'Search local documents within sandbox directory. Builds index if missing.',
      docFindShape, OPEN,
      async ({ q, top, limit }) => {
        const res = await docFind(q, top ?? limit ?? 5);
        return { content: [{ type: 'text', text: JSON.stringify(res) }] };
      }
    );
  • Helper function to load the document index from cache file, used by docFind.
    function loadIndex() {
      if (!fssync.existsSync(INDEX_PATH)) return null;
      const payload = JSON.parse(fssync.readFileSync(INDEX_PATH, 'utf-8'));
      const mini = MiniSearch.loadJSON(payload.index, { fields: ['title','text'], storeFields: ['path','title'] });
      return { mini, docs: payload.docs as DocRecord[] };
    }
Behavior3/5

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

The annotation provides openWorldHint=true, indicating this tool can handle queries about topics not explicitly in its training data. The description adds no behavioral context beyond stating it's an alias - no information about what gets searched, authentication needs, rate limits, or result format. Since annotations cover the open-world capability, the description gets baseline credit but adds minimal value.

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 maximally concise with just three words. There's no wasted language or unnecessary elaboration. However, this extreme conciseness comes at the cost of being under-specified rather than efficiently informative.

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 3 parameters, 0% schema coverage, no output schema, and only one annotation, the description is completely inadequate. It doesn't explain what the tool searches (documents? which documents?), what it returns, or how parameters affect results. The user would need to already understand 'doc.find' to use this tool effectively.

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

Parameters2/5

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

With 0% schema description coverage for 3 parameters (q, top, limit), the description provides zero information about what these parameters mean or how to use them. 'Alias of doc.find' doesn't explain that 'q' is a search query, 'top' might control result ranking, or 'limit' might restrict result count. The description fails to compensate for the complete lack of schema documentation.

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 'Alias of doc.find' is a tautology that restates the tool name without explaining what the tool actually does. It doesn't specify the verb (search/find) or resource (documents/content), nor does it distinguish this tool from its sibling 'doc.find' which appears to be the same functionality. The user must already know what 'doc.find' does to understand this tool's purpose.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tools (like doc.read, web.search, wiki.search) or explain why one would choose this alias over the original 'doc.find' tool. There's no context about appropriate use cases or limitations.

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/khanhs-234/tool4lm'

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