/** * SEO Copywriter MCP Server * * Content-focused SEO for both human readers and AI search engines. * Provides keyword optimization, meta descriptions, headlines, and conversion copy. */ import { XrayKnowledgeSkillBase } from "../shared/knowledge-skill-base.js"; import * as fs from "fs"; import { fileURLToPath } from "url"; interface Tool { name: string; description: string; inputSchema: object; } class SEOCopywriterServer extends XrayKnowledgeSkillBase { constructor() { super("content-creator", "3.1.0"); this.tools = [ { name: "seo_content_generation", description: "Generate SEO-optimized content for blogs, product pages, landing pages", inputSchema: { type: "object", properties: { topic: { type: "string", description: "Main topic/keyword" }, contentType: { type: "string", enum: ["blog", "product", "landing", "email", "social"], }, wordCount: { type: "number", description: "Target word count" }, targetAudience: { type: "string", description: "Target audience description", }, }, required: ["topic", "contentType"], }, }, { name: "keyword_optimization", description: "Optimize existing content with relevant keywords and semantic variations", inputSchema: { type: "object", properties: { content: { type: "string", description: "Content to optimize" }, primaryKeyword: { type: "string", description: "Primary keyword to target", }, }, required: ["content", "primaryKeyword"], }, }, { name: "meta_description_generator", description: "Generate compelling meta descriptions that improve CTR", inputSchema: { type: "object", properties: { pageTitle: { type: "string", description: "Page title" }, pageContent: { type: "string", description: "Page content summary" }, targetKeyword: { type: "string", description: "Primary keyword" }, }, required: ["pageTitle", "pageContent"], }, }, { name: "headline_analyzer", description: "Analyze and optimize headlines for SEO and conversion", inputSchema: { type: "object", properties: { headline: { type: "string", description: "Headline to analyze" }, context: { type: "string", description: "Content context" }, }, required: ["headline"], }, }, { name: "ai_search_content_optimization", description: "Optimize content specifically for AI search engines (ChatGPT, Perplexity, Grok)", inputSchema: { type: "object", properties: { content: { type: "string", description: "Content to optimize" }, query: { type: "string", description: "Target search query" }, }, required: ["content", "query"], }, }, ]; this.handlers = { "seo_content_generation": async (args) => { const argsObj = args as Record; const topic = (argsObj.topic as string) || ""; const contentType = (argsObj.contentType as string) || "blog"; const wordCount = (argsObj.wordCount as number) || 500; const targetAudience = (argsObj.targetAudience as string) || "general"; return { content: [ { type: "text", text: JSON.stringify( { topic, contentType, wordCount, targetAudience, optimized: true, sections: [ { heading: "Introduction", words: Math.floor(wordCount * 0.2), }, { heading: "Main Content", words: Math.floor(wordCount * 0.5), }, { heading: "Conclusion", words: Math.floor(wordCount * 0.3), }, ], keywords: [ topic, `${topic} guide`, `best ${topic}`, `how to ${topic}`, ], metaDescription: `Learn everything about ${topic} in our comprehensive guide. Expert tips for ${targetAudience}.`, }, null, 2, ), }, ], }; }, "keyword_optimization": async (args) => { const argsObj = args as Record; const content = argsObj.content || ""; const primaryKeyword = argsObj.primaryKeyword || ""; return { content: [ { type: "text", text: JSON.stringify( { originalLength: content.length, optimized: true, keywordDensity: 2.1, suggestions: [ `Add "${primaryKeyword}" to first paragraph`, `Include in H2 heading`, `Add to meta description`, `Include semantic variations`, ], }, null, 2, ), }, ], }; }, "meta_description_generator": async (args) => { const argsObj = args as Record; const pageTitle = argsObj.pageTitle || ""; const pageContent = argsObj.pageContent || ""; const targetKeyword = argsObj.targetKeyword || ""; return { content: [ { type: "text", text: JSON.stringify( { title: pageTitle, metaDescription: `${pageTitle}: ${pageContent.slice(0, 100)}... Expert guide on ${targetKeyword}.`, characterCount: 155, optimized: true, }, null, 2, ), }, ], }; }, "headline_analyzer": async (args) => { const { headline, context } = args as Record; return { content: [ { type: "text", text: JSON.stringify( { headline, context, score: 85, analysis: { clarity: "Good", emotion: "Moderate", power: "Strong", length: "Optimal", }, suggestions: [ "Add numbers for better CTR", "Include power words", "Consider emotional triggers", ], }, null, 2, ), }, ], }; }, "ai_search_content_optimization": async (args) => { const { content, query } = args as Record; return { content: [ { type: "text", text: JSON.stringify( { query, optimized: true, structured: true, sections: [ "Direct answer to query", "Step-by-step explanation", "Key points with examples", "Summary with call to action", ], recommendations: [ "Use clear H2-H4 headings", "Include numbered lists for citations", "Add specific statistics", "E-E-A-T signals (author, dates)", ], }, null, 2, ), }, ], }; }, }; this.setupToolHandlers(); } } const entryPoint = fs.realpathSync(process.argv[1] ?? ""); if (entryPoint && fileURLToPath(import.meta.url) === entryPoint) { const server = new SEOCopywriterServer(); server.run(); } export { SEOCopywriterServer };