Skip to main content
Glama

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
NameRequiredDescriptionDefault
filePathYesPath to the LaTeX file
gitTokenNoGit token (optional, uses env var)
projectIdNoProject ID (optional, uses env var)
projectNameNoProject name (default, project2, etc.)

Implementation Reference

  • 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;
    }
  • 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),
          },
        ],
      };
    }
  • 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'],
      },
    },
  • 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'],
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Get all sections' but doesn't explain what 'sections' means (e.g., LaTeX section commands like \section), how they are returned (e.g., list of strings, structured data), or any limitations (e.g., file size, parsing errors). This leaves significant gaps in understanding the tool's behavior.

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

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words, making it easy to parse and understand quickly. It's appropriately sized for a simple tool and front-loads the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (4 parameters, no output schema, no annotations), the description is incomplete. It doesn't address what the tool returns (e.g., format of sections), error handling, or dependencies between parameters. For a tool that parses LaTeX files, more context is needed to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the input schema already documents all parameters thoroughly. The description adds no additional meaning beyond the schema, such as explaining interactions between parameters (e.g., how gitToken and projectId relate to filePath). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb 'Get' and the resource 'sections from a LaTeX file', making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_section_content' or 'read_file', which might have overlapping functionality, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives such as 'get_section_content' or 'read_file'. It lacks context about use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name alone.

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

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