Skip to main content
Glama

generate_faq_schema

Generate FAQPage JSON-LD schema markup from question-answer pairs to enhance search visibility and structured data.

Instructions

Generate a FAQPage JSON-LD schema from a list of question-answer pairs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionsYesArray of question-answer pairs

Implementation Reference

  • Implementation of the logic to build the FAQ schema.
    function buildFaqSchema(params: {
      questions: Array<{ question: string; answer: string }>;
    }): object {
      const mainEntity = params.questions.map((q) => ({
        "@type": "Question",
        name: q.question,
        acceptedAnswer: {
          "@type": "Answer",
          text: q.answer,
        },
      }));
    
      return {
        "@context": "https://schema.org",
        "@type": "FAQPage",
        mainEntity,
      };
    }
  • Registration of the 'generate_faq_schema' tool and call to the handler.
    server.tool(
      "generate_faq_schema",
      "Generate a FAQPage JSON-LD schema from a list of question-answer pairs.",
      {
        questions: z
          .array(
            z.object({
              question: z.string().describe("The question text"),
              answer: z.string().describe("The answer text"),
            })
          )
          .describe("Array of question-answer pairs"),
      },
      async (params) => {
        const schema = buildFaqSchema(params);
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(schema, null, 2),
            },
          ],
        };
      }
    );

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/sharozdawa/schema-gen'

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