Skip to main content
Glama
sharozdawa

content-optimizer-mcp

optimize_headings

Analyze heading structure and suggest improvements for SEO by identifying issues and recommending optimized outlines based on target keywords.

Instructions

Analyze heading structure and suggest improvements. Returns current headings, issues, and recommended heading outline.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content to analyze
keywordYesThe target keyword

Implementation Reference

  • The handler function for the optimize_headings tool, which analyzes heading structures and generates improvement recommendations.
    async ({ content, keyword }) => {
      const headings = extractHeadings(content);
      const topics = getKeywordTopics(keyword);
      const keywordLower = keyword.toLowerCase();
    
      const issues: string[] = [];
      const h1s = headings.filter((h) => h.level === 1);
      const h2s = headings.filter((h) => h.level === 2);
      const h3s = headings.filter((h) => h.level === 3);
    
      if (h1s.length === 0) issues.push("Missing H1 heading.");
      if (h1s.length > 1) issues.push(`Multiple H1 headings found (${h1s.length}). Use only one.`);
      if (h1s.length > 0 && !h1s[0].text.toLowerCase().includes(keywordLower)) {
        issues.push("H1 does not contain the target keyword.");
      }
      if (h2s.length < 3) issues.push(`Only ${h2s.length} H2 headings. Aim for 3-8 for comprehensive structure.`);
      if (h2s.length > 0 && !h2s.some((h) => h.text.toLowerCase().includes(keywordLower))) {
        issues.push("No H2 heading contains the target keyword.");
      }
    
      // Check for heading hierarchy issues
      let prevLevel = 0;
      for (const h of headings) {
        if (h.level > prevLevel + 1 && prevLevel > 0) {
          issues.push(`Heading hierarchy skip: H${prevLevel} followed by H${h.level}. Don't skip levels.`);
          break;
        }
        prevLevel = h.level;
      }
    
      // Generate recommended headings
      const kwTitle = keyword.charAt(0).toUpperCase() + keyword.slice(1);
      const recommended: { level: number; text: string }[] = [
        { level: 1, text: `${kwTitle}: Complete Guide` },
      ];
    
      const topicSuggestions = topics.slice(0, 6);
      for (const topic of topicSuggestions) {
        const topicTitle = topic.charAt(0).toUpperCase() + topic.slice(1);
        recommended.push({ level: 2, text: `${kwTitle} ${topicTitle}` });
        if (topic.includes("best practices") || topic.includes("strategies") || topic.includes("tips")) {
          recommended.push({ level: 3, text: `Top ${topicTitle} for Beginners` });
          recommended.push({ level: 3, text: `Advanced ${topicTitle}` });
        }
      }
      recommended.push({ level: 2, text: "Conclusion" });
    
      // Suggest missing heading topics
      const existingTopics = headings.map((h) => h.text.toLowerCase());
      const missingSuggestions = topics
        .filter((t) => !existingTopics.some((et) => et.includes(t.toLowerCase())))
        .slice(0, 5)
        .map((t) => `H2: ${kwTitle} ${t.charAt(0).toUpperCase() + t.slice(1)}`);
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify({
              currentHeadings: headings,
              headingCounts: { h1: h1s.length, h2: h2s.length, h3: h3s.length, total: headings.length },
              issues,
              recommendedOutline: recommended,
              missingSuggestions,
              keywordInH1: h1s.some((h) => h.text.toLowerCase().includes(keywordLower)),
              keywordInH2: h2s.some((h) => h.text.toLowerCase().includes(keywordLower)),
            }, null, 2),
          },
        ],
      };
  • Input schema for the optimize_headings tool.
    {
      content: z.string().describe("The content to analyze"),
      keyword: z.string().describe("The target keyword"),
    },
  • Registration of the optimize_headings tool.
    server.tool(
      "optimize_headings",
      "Analyze heading structure and suggest improvements. Returns current headings, issues, and recommended heading outline.",
      {
        content: z.string().describe("The content to analyze"),
        keyword: z.string().describe("The target keyword"),
      },
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 mentions the tool returns 'current headings, issues, and recommended heading outline', which gives some insight into output behavior. However, it lacks critical details like whether this is a read-only analysis, if it modifies content, performance characteristics, or error handling.

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

Conciseness4/5

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

The description is concise and well-structured in a single sentence. It front-loads the core purpose ('Analyze heading structure and suggest improvements') and adds useful detail about the return values. Every part of the sentence contributes value without unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no annotations, no output schema), the description is minimally adequate. It explains what the tool does and what it returns, but lacks details about behavioral traits, usage context, and deeper parameter meaning. Without an output schema, the description should ideally elaborate more on return values.

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?

Schema description coverage is 100%, so the schema already documents both parameters ('content' and 'keyword') adequately. The description adds no additional parameter semantics beyond what's in the schema. The baseline score of 3 reflects that the schema does the heavy lifting for parameter documentation.

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 tool's purpose: analyzing heading structure and suggesting improvements. It specifies the verb 'analyze' and resource 'heading structure' with the outcome 'suggest improvements'. However, it doesn't explicitly differentiate from sibling tools like 'check_readability' or 'get_content_recommendations', which might also involve content analysis.

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. It doesn't mention sibling tools or specific contexts where heading optimization is preferred over other content analysis tools. The user must 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

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/content-optimizer'

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