read_file
Access and retrieve specific files from Overleaf projects by providing the file path and project details. Enables reading LaTeX files, analyzing document structure, and extracting content via Git integration.
Instructions
Read a file from an Overleaf project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to the file | |
| gitToken | No | Git token (optional, uses env var) | |
| projectId | No | Project ID (optional, uses env var) | |
| projectName | No | Project name (default, project2, etc.) |
Implementation Reference
- overleaf-mcp-server.js:273-284 (handler)Executes the 'read_file' tool logic: creates an OverleafGitClient instance and invokes its readFile method to fetch and return the file contents as text response.case 'read_file': { const client = getProject(args.projectName); const content = await client.readFile(args.filePath); return { content: [ { type: 'text', text: content, }, ], }; }
- overleaf-mcp-server.js:166-179 (schema)Defines the input schema for the 'read_file' tool, specifying required 'filePath' and optional 'projectName' parameters.inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the file', }, projectName: { type: 'string', description: 'Project identifier (optional)', }, }, required: ['filePath'], },
- overleaf-mcp-server.js:163-180 (registration)Registers the 'read_file' tool in the listTools response, providing name, description, and input schema.{ name: 'read_file', description: 'Read a file from an Overleaf project', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the file', }, projectName: { type: 'string', description: 'Project identifier (optional)', }, }, required: ['filePath'], }, },
- overleaf-mcp-server.js:72-76 (helper)OverleafGitClient.readFile helper method that ensures the repository is up-to-date via cloneOrPull and reads the file content using Node.js fs.readFile.async readFile(filePath) { await this.cloneOrPull(); const fullPath = path.join(this.repoPath, filePath); return await readFile(fullPath, 'utf-8'); }