Skip to main content
Glama

doc_read

Reads and extracts content from documents to provide information for local LLMs. Use this tool to access file contents without requiring API keys.

Instructions

Alias of doc.read

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The core handler function that reads the content of a file (text or PDF) from the sandbox directory, resolves the path, checks access permissions, parses PDF if necessary, and returns the path and text content.
    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 }; }
  • Zod schema defining the input for the doc_read tool: a string path parameter.
    const docReadShape = { path: z.string() };
  • src/server.ts:133-139 (registration)
    Registration of the 'doc_read' tool on the MCP server, which is an alias calling the docRead handler with the provided path and formatting the response.
    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) }] }; } );

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