analyze_keyword
Analyze SERP data for keywords to identify word counts, heading patterns, common topics, and SERP features in top results.
Instructions
Analyze SERP data for a keyword. Returns simulated top 10 results with word counts, heading counts, common topics, and SERP features.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | The keyword to analyze |
Implementation Reference
- mcp-server/src/index.ts:352-369 (handler)Registration and handler definition for the 'analyze_keyword' tool.
server.tool( "analyze_keyword", "Analyze SERP data for a keyword. Returns simulated top 10 results with word counts, heading counts, common topics, and SERP features.", { keyword: z.string().describe("The keyword to analyze"), }, async ({ keyword }) => { const result = analyzeSERP(keyword); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2), }, ], }; } ); - mcp-server/src/index.ts:280-315 (helper)The core logic function 'analyzeSERP' which generates the keyword analysis data.
function analyzeSERP(keyword: string) { const rng = seededRandom(keyword.toLowerCase()); const topics = getKeywordTopics(keyword); const results = []; for (let i = 0; i < 10; i++) { const wordCount = 800 + Math.floor(rng() * 2500); const headingCount = 3 + Math.floor(rng() * 12); const h2Count = 2 + Math.floor(rng() * 8); const h3Count = Math.floor(rng() * 6); results.push({ position: i + 1, title: `${keyword.charAt(0).toUpperCase() + keyword.slice(1)}: ${["Complete Guide", "Everything You Need to Know", "Ultimate Guide", "Best Practices", "How to Get Started", "Expert Tips", "A Comprehensive Overview", "Step-by-Step Guide", "What You Should Know", "Top Strategies"][i]}`, wordCount, headingCount, h2Count, h3Count, estimatedReadingTime: `${Math.ceil(wordCount / 250)} min`, }); } const avgWordCount = Math.round(results.reduce((s, r) => s + r.wordCount, 0) / 10); const avgHeadings = Math.round(results.reduce((s, r) => s + r.headingCount, 0) / 10); return { keyword, topResults: results, averages: { wordCount: avgWordCount, headingCount: avgHeadings, recommendedWordCount: Math.round(avgWordCount * 1.1), }, commonTopics: topics, serpFeatures: { featuredSnippet: rng() > 0.4,