Skip to main content
Glama

doc_read

Read document content from a specified file path, enabling local LLMs to access and process text directly for analysis or further tasks.

Instructions

Alias of doc.read

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The actual handler function for doc_read. Resolves the path, enforces sandbox restriction, reads the file (supports text and PDF), and returns {path, text}.
    export async function docRead(p: string) {
      const full = path.resolve(p);
      if (!full.startsWith(CONFIG.sandboxDir)) throw new Error('Access outside sandbox is not allowed');
      const buf = await fs.readFile(full);
      let text = '';
      if (/\.pdf$/i.test(full)) {
        try { const parsed = await pdfParseLazy(buf as unknown as Buffer); text = parsed.text || ''; } catch { text = ''; }
      } else { text = buf.toString('utf-8'); }
      return { path: full, text };
    }
  • src/server.ts:124-139 (registration)
    Registers both 'doc.read' (primary) and 'doc_read' (alias) tools with the MCP server using the same shape and handler.
    // ===== doc.read + alias =====
    const docReadShape = { path: z.string() };
    server.tool('doc.read', 'Read a file from sandbox directory (text or pdf).',
      docReadShape, OPEN,
      async ({ path }) => {
        const res = await docRead(path);
        return { content: [{ type: 'text', text: JSON.stringify(res) }] };
      }
    );
    server.tool('doc_read', 'Alias of doc.read',
      docReadShape, OPEN,
      async ({ path }) => {
        const res = await docRead(path);
        return { content: [{ type: 'text', text: JSON.stringify(res) }] };
      }
    );
  • Input shape for doc_read: a single required string field 'path'.
    const docReadShape = { path: z.string() };
  • Lazy-loaded PDF parser helper used by docRead when the file is a PDF.
    let _pdfParse: any | null = null;
    async function pdfParseLazy(buf: Buffer): Promise<{ text: string }> {
      try {
        if (!_pdfParse) {
          const mod = await import('pdf-parse');
          _pdfParse = (mod as any).default || (mod as any);
        }
        const out = await _pdfParse(buf);
        return { text: String(out.text || '') };
      } catch {
        return { text: '' };
      }
    }
Behavior2/5

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

The description adds no behavioral context beyond the openWorldHint annotation. It does not disclose read-only nature, side effects, or scope.

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

Conciseness2/5

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

The description is extremely short but at the expense of being informative. It is under-specified and fails to convey essential information.

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?

Given the absence of output schema and parameter descriptions, the description should provide a self-contained explanation. It does not, leaving the agent without sufficient context to use the tool correctly.

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?

The input schema has 0% description coverage, and the description does not explain what the 'path' parameter represents. The agent has no semantic guidance for providing this argument.

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

Purpose1/5

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

The description only states 'Alias of doc.read' without defining what the tool actually does. It fails to provide a verb-resource pair, and the agent gains no understanding of the tool's functionality.

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 explicit usage guidance is given. The description implies interchangeability with doc.read but does not clarify when to use this alias over the original.

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