Skip to main content
Glama
WhenYouAreStrange

goodbook-mcp

get_section_content

Retrieve specific food standards and preparation guidelines from PDF documents by section name, enabling targeted access to regulatory content.

Instructions

Get content from a specific section of the food standards document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
section_nameYesName of the section to retrieve content from
limitYes

Implementation Reference

  • The handler function that executes the get_section_content tool. It calls the PDF parser's getContent method and formats the response as MCP content blocks.
    async function getSectionContent(section_name, limit) {
      const content = pdfParser.getContent(section_name, limit);
      
      if (content.error) {
        return {
          content: [{
            type: "text",
            text: `Error: ${content.error}`
          }]
        };
      }
    
      return {
        content: [{
          type: "text",
          text: `Content from section "${content.section}":\n\n${content.content}`
        }]
      };
    }
  • Zod input schema validation for the get_section_content tool parameters.
    const getSectionContentSchema = z.object({
      section_name: z.string().describe("Name of the section to retrieve content from"),
      limit: z.number().default(1000).describe("Maximum number of characters to return"),
    });
  • src/index.js:186-190 (registration)
    Tool registration in the MCP server's tool definitions array, including name, description, and input schema.
    {
      name: "get_section_content",
      description: "Get content from a specific section of the food standards document",
      inputSchema: zodToJsonSchema(getSectionContentSchema)
    },
  • Core helper method in PDFParser class that retrieves the actual content from a named section or all content, limiting by character count.
    getContent(sectionName = null, limit = 1000) {
      if (!this.parsedContent) {
        return { error: 'PDF content not loaded' };
      }
    
      if (sectionName) {
        const section = this.sections[sectionName];
        if (!section) {
          return { error: `Section '${sectionName}' not found` };
        }
        return {
          section: sectionName,
          content: section.join('\n').substring(0, limit)
        };
      }
    
      return {
        section: 'all',
        content: this.parsedContent.substring(0, limit)
      };
    }
  • Alternative class-based handler for get_section_content tool in GoodbookTools class, similar logic delegating to PDF parser.
    async getSectionContent(sectionName, limit = 1000) {
      const content = this.pdfParser.getContent(sectionName, limit);
      
      if (content.error) {
        return {
          content: [{
            type: "text",
            text: `Error: ${content.error}`
          }]
        };
      }
    
      return {
        content: [{
          type: "text",
          text: `Content from section "${content.section}":\n\n${content.content}`
        }]
      };
    }

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/WhenYouAreStrange/goodbook-mcp'

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