Skip to main content
Glama

get_section_content

Extracts specific section content from a LaTeX file in an Overleaf project, enabling targeted analysis and retrieval of document segments using file path and section title.

Instructions

Get content of a specific section

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the LaTeX file
gitTokenNoGit token (optional, uses env var)
projectIdNoProject ID (optional, uses env var)
projectNameNoProject name (default, project2, etc.)
sectionTitleYesTitle of the section

Implementation Reference

  • Core handler function in OverleafGitClient that implements get_section_content logic: reads file, finds sections, extracts content between target section and next.
    async getSectionContent(filePath, sectionTitle) { const content = await this.readFile(filePath); const sections = await this.getSections(filePath); const targetSection = sections.find(s => s.title === sectionTitle); if (!targetSection) { throw new Error(`Section "${sectionTitle}" not found`); } const nextSection = sections.find(s => s.index > targetSection.index); const startIdx = targetSection.index; const endIdx = nextSection ? nextSection.index : content.length; return content.substring(startIdx, endIdx); }
  • Input schema definition for the get_section_content tool, specifying required filePath and sectionTitle parameters.
    inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the LaTeX file', }, sectionTitle: { type: 'string', description: 'Title of the section', }, projectName: { type: 'string', description: 'Project identifier (optional)', }, }, required: ['filePath', 'sectionTitle'], },
  • Registration and dispatch logic in the CallToolRequestSchema handler switch statement.
    case 'get_section_content': { const client = getProject(args.projectName); const content = await client.getSectionContent(args.filePath, args.sectionTitle); return { content: [ { type: 'text', text: content, }, ], }; }
  • Helper method getSections used by getSectionContent to parse LaTeX sections and their positions.
    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; }
  • Tool registration in the ListToolsRequestSchema response, including name, description, and schema.
    { name: 'get_section_content', description: 'Get content of a specific section', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the LaTeX file', }, sectionTitle: { type: 'string', description: 'Title of the section', }, projectName: { type: 'string', description: 'Project identifier (optional)', }, }, required: ['filePath', 'sectionTitle'], }, },

Other Tools

Related 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/mjyoo2/OverleafMCP'

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