get_sections
Extract all sections from a LaTeX file to analyze and understand its structure. Requires the file path and integrates with Overleaf projects via Git for efficient document processing.
Instructions
Get all sections from a LaTeX file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to the LaTeX 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:78-93 (handler)Core handler function that parses LaTeX file content to extract sections using regex matching for \section, \subsection, \subsubsection commands.async getSections(filePath) { const content = await this.readFile(filePath); const sections = []; const sectionRegex = /\\(?:section|subsection|subsubsection)\{([^}]+)\}/g; let match; while ((match = sectionRegex.exec(content)) !== null) { sections.push({ title: match[1], type: match[0].split('{')[0].replace('\\', ''), index: match.index }); } return sections; }
- overleaf-mcp-server.js:286-297 (handler)MCP server dispatch handler for 'get_sections' tool call, which instantiates the client and invokes the core getSections method.case 'get_sections': { const client = getProject(args.projectName); const sections = await client.getSections(args.filePath); return { content: [ { type: 'text', text: JSON.stringify(sections, null, 2), }, ], }; }
- overleaf-mcp-server.js:181-198 (registration)Tool registration in ListTools response, defining name, description, and input schema for get_sections tool.{ name: 'get_sections', description: 'Get all sections from a LaTeX file', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the LaTeX file', }, projectName: { type: 'string', description: 'Project identifier (optional)', }, }, required: ['filePath'], }, },
- overleaf-mcp-server.js:184-197 (schema)Input schema defining parameters for the get_sections tool.inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the LaTeX file', }, projectName: { type: 'string', description: 'Project identifier (optional)', }, }, required: ['filePath'], },