Blog_Automation_MCP_Server/README.md at main · SohailShabbir867/Blog_Automation_MCP_Server · GitHub
Skip to content

Latest commit

 

History

History
266 lines (209 loc) · 9.37 KB

File metadata and controls

266 lines (209 loc) · 9.37 KB

MCP Blog Automation Server

A custom Model Context Protocol (MCP) server designed to fully automate the blog creation lifecycle. Connect this server to Claude Desktop or Codex to research topics, perform real-time SEO keyword optimization, fetch or generate cover images, and publish posts automatically.


🚀 Features

  • 🔍 Smart Web Research: Search tool integrating Tavily, Brave Search, or a DuckDuckGo HTML scraping fallback (works with zero API configuration).
  • 📈 SEO Optimization: Computes keyword density, monitors headings (H1-H4), calculates reading times, drafts titles/descriptions, and gives an SEO score from 0 to 100.
  • 🖼️ Cover Image Automation: Integrates OpenAI's DALL-E 3, Unsplash API, or uses smart keyword-based stock photo selections.
  • 📰 Multi-CMS Integration: Out-of-the-box support for:
    • MERN Stack Backend API (natively formatted JSON payloads with JWT/header auth)
    • WordPress REST API (via Application Passwords)
    • Ghost Admin API (using secure, dependency-free cryptographic JWT tokens)
    • Custom Webhooks (POST json to custom endpoint)
    • Local Markdown Files & JSON Database (default fallback)

🛠️ Installation & Setup

1. Prerequisite Checklist

  • Node.js v18+ (if running natively)
  • Docker (if running inside container)

2. Environment Configuration

Copy the .env.example file to .env and fill in your keys:

cp .env.example .env
Environment Variable Description Example / Note
CMS_TYPE Type of CMS to publish blogs local (default), wordpress, ghost, webhook, mern
CMS_URL Base URL of your website E.g. http://localhost:5000/api/posts for MERN
CMS_API_KEY Key for authentication JWT token (MERN/Webhook), WP password, or Ghost key
CMS_USERNAME WordPress Username admin (WordPress only)
CMS_AUTHOR Blog Author Name Name for post metadata (default: MCP Blog Bot)
TAVILY_API_KEY Search API Key (Optional) Tavily key
BRAVE_API_KEY Search API Key (Optional) Brave Search key
OPENAI_API_KEY OpenAI Key (Optional) DALL-E 3 image generation
UNSPLASH_ACCESS_KEY Unsplash API Key (Optional) Unsplash search API key

🏃 Running the Server

Option A: Running Locally (Node.js)

  1. Install dependencies:
    npm install
  2. Build the project:
    npm run build
  3. Start the server (stdio):
    npm start

Option B: Running with Docker (Recommended)

  1. Build the Docker image:
    docker build -t mcp-blogs-server:latest .
  2. Run the server interactively (stdio):
    docker run -i --rm --env-file .env -v "${PWD}/blogs:/app/blogs" mcp-blogs-server:latest
    (Note: The -v flag maps the container /app/blogs folder to your local /blogs directory, making posts generated in local mode visible on your computer.)

🔌 Connecting to LLM Clients (Docker — Recommended)

Prerequisites

  1. Docker Desktop is installed and running
  2. You have built the image once: docker build -t mcp-blogs-server:latest "d:/Backup/MCP blogs server"
  3. Your .env file is at d:/Backup/MCP blogs server/.env (adjust path in configs below if different)

All 4 clients use the same pattern — they spawn the Docker container as a child process over stdio. The --rm -i flags are critical: --rm cleans up the container when the session ends, -i keeps stdin open for the MCP JSON-RPC pipe.


1. 🟣 Claude Desktop

Config file location: %APPDATA%\Claude\claude_desktop.json
(Open with: notepad %APPDATA%\Claude\claude_desktop.json)

{
  "mcpServers": {
    "blogs-automation": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "--env-file", "d:/Backup/MCP blogs server/.env",
        "-v", "d:/Backup/MCP blogs server/blogs:/app/blogs",
        "mcp-blogs-server:latest"
      ]
    }
  }
}

After editing: Fully quit and reopen Claude Desktop. Look for blogs-automation in the tools panel (🔧 icon).

A ready-to-paste copy of this config is also saved at configs/claude_desktop_config.json.


2. 🔵 VS Code (Cline / Continue.dev / GitHub Copilot Agent)

Config file location: .vscode/mcp.json in your workspace root
(Create the file if it doesn't exist)

{
  "mcpServers": {
    "blogs-automation": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "--env-file", "d:/Backup/MCP blogs server/.env",
        "-v", "d:/Backup/MCP blogs server/blogs:/app/blogs",
        "mcp-blogs-server:latest"
      ]
    }
  }
}
  • Cline: Settings → MCP Servers → point to this file, or paste directly into Cline's MCP config panel
  • Continue.dev: Add to ~/.continue/config.json under "mcpServers"
  • GitHub Copilot: VS Code settings → github.copilot.chat.mcp.enabled: true, then this .vscode/mcp.json is auto-read

A ready-to-paste copy is also at configs/vscode_mcp_settings.json.


3. 🟢 OpenAI Codex CLI

Config file location: %USERPROFILE%\.codex\config.yaml
(Create C:\Users\YourName\.codex\config.yaml if it doesn't exist)

model: o4-mini        # or gpt-4o, o3, etc.
approvalMode: auto-edit

mcpServers:
  blogs-automation:
    command: docker
    args:
      - run
      - "--rm"
      - "-i"
      - "--env-file"
      - "d:/Backup/MCP blogs server/.env"
      - "-v"
      - "d:/Backup/MCP blogs server/blogs:/app/blogs"
      - "mcp-blogs-server:latest"

After editing: Run codex in any terminal to verify — it will list connected MCP servers on startup.

A ready-to-paste copy is also at configs/codex_mcp_config.yaml.


4. 🔴 Antigravity IDE

The file .agents/mcp.json in this project root is automatically discovered by Antigravity IDE:

{
  "mcpServers": {
    "blogs-automation": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "--env-file", "d:/Backup/MCP blogs server/.env",
        "-v", "d:/Backup/MCP blogs server/blogs:/app/blogs",
        "mcp-blogs-server:latest"
      ]
    }
  }
}

This file already exists at .agents/mcp.json — no action needed.


Legacy: Running via Node.js directly (without Docker)

If you prefer running without Docker, use the original approach:

{
  "mcpServers": {
    "blogs-automation": {
      "command": "node",
      "args": ["d:/Backup/MCP blogs server/dist/index.js"],
      "env": {
        "CMS_TYPE": "mern",
        "CMS_URL": "https://daily-blogs-backend-gnfdatd8eud6g2gd.eastasia-01.azurewebsites.net/api/blogs",
        "CMS_API_KEY": "mcp-secret-key-12345",
        "PEXELS_API_KEY": "YOUR_KEY",
        "GOOGLE_SEARCH_API_KEY": "YOUR_KEY",
        "GOOGLE_SEARCH_CX": "YOUR_CX"
      }
    }
  }
}

🧰 Available Tools & Prompts

Tools

  1. search_web: Researches topic content on the web.
    • Arguments: query (string, required), numResults (number, optional).
  2. analyze_seo: Audits post structure, title, description, and keywords.
    • Arguments: topic (string, required), content (string, HTML body, optional).
  3. generate_image: Generates/retrieves a blog header image.
    • Arguments: prompt (string, required).
  4. publish_blog: Publishes HTML to your CMS or saves a local markdown file.
    • Arguments: title (string, required), content (string, HTML, required), imageUrl (string, optional), tags (string[], optional), status (draft/publish, optional).
  5. get_keyword_trends: Checks Wikipedia pageview trend statistics over the last 30 days to assess query popularity completely for free.
    • Arguments: keywords (string[], required).

Prompts

  • generate-seo-blog: Instructs Claude/Codex on how to execute the entire search $\rightarrow$ plan $\rightarrow$ write $\rightarrow$ review $\rightarrow$ image $\rightarrow$ post workflow. Run this by asking:

    "Write a blog post about [Topic] using the generate-seo-blog prompt."


🔑 CMS Setup Instructions

WordPress

  1. Log in to your WordPress Dashboard.
  2. Go to Users -> Profile.
  3. Scroll down to Application Passwords.
  4. Add a new application password name (e.g. "MCP-Blog-Server") and click Add New.
  5. Copy the generated password.
  6. Set CMS_TYPE=wordpress, CMS_URL=https://yourdomain.com, CMS_USERNAME=your-username, and CMS_API_KEY=the-copied-password.

Ghost

  1. Log in to your Ghost Admin panel.
  2. Go to Settings -> Integrations (under Developer section).
  3. Click Add custom integration.
  4. Name it (e.g., "MCP Server").
  5. Copy the Admin API Key (e.g., 5c51c098...:a2a900b...) and the API URL.
  6. Set CMS_TYPE=ghost, CMS_URL=your-ghost-api-url, and CMS_API_KEY=your-admin-api-key.

MERN Stack (Custom Node/React App)

  1. Point CMS_URL to your backend's blog creation API endpoint (e.g., http://localhost:5000/api/posts or http://localhost:5000/api/blogs).
  2. Set CMS_TYPE=mern.
  3. Provide your authentication token in CMS_API_KEY (if your API requires JWT/token verification). The server automatically attaches this key to the header as Authorization: Bearer <key> and x-auth-token: <key>.
  4. Optionally specify CMS_AUTHOR to associate posts with a specific author string.