Astro Blog MCP Server
Enables automated blog post creation and management for Astro blogs deployed on Vercel through GitHub integration. Supports secure API-based operations with automatic deployment triggers and integration with automation tools like n8n.
README
Astro Blog MCP Server
MCP (Model Context Protocol) Server para automatizar la creación de posts en un blog Astro desplegado en Vercel.
🚀 Características
- ✅ Creación automática de posts vía API REST
- ✅ Integración directa con GitHub
- ✅ Validación y sanitización de inputs
- ✅ Seguridad con API Keys
- ✅ Rate limiting
- ✅ Trigger automático de deployments en Vercel
- ✅ Compatible con n8n y otras herramientas de automatización
📦 Instalación
1. Clona el repositorio
git clone <tu-repo>
cd astro-blog-mcp
2. Instala dependencias
pnpm install
3. Configura variables de entorno
Copia .env.example a .env y completa los valores:
cp .env.example .env
Variables requeridas:
GITHUB_TOKEN: Personal Access Token de GitHub con permisos derepoGITHUB_OWNER: Tu usuario de GitHubGITHUB_REPO: Nombre del repositorio de tu blogGITHUB_BRANCH: Branch a usar (default:main)API_SECRET_KEY: Una clave secreta aleatoria de al menos 32 caracteresMCP_PORT: Puerto del servidor (default:3000)DEPLOY_HOOK: (Opcional) Deploy Hook de Vercel
4. Compila el proyecto
pnpm build
🎯 Uso
Iniciar el servidor
Modo desarrollo:
pnpm dev
Modo producción:
pnpm start
Probar la API
pnpm test
🔑 Configuración de GitHub Token
- Ve a GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Genera un nuevo token con estos permisos:
repo(acceso completo)
- Copia el token y agrégalo a tu
.env
🔗 Configuración de Vercel Deploy Hook
- En tu proyecto de Vercel, ve a Settings → Git
- En la sección "Deploy Hooks", crea un nuevo hook
- Copia la URL y agrégala a
DEPLOY_HOOKen tu.env
📡 API Endpoints
Health Check
GET /health
Validar configuración
GET /api/validate
Headers: x-api-key: YOUR_API_KEY
Crear un post
POST /api/posts
Headers:
Content-Type: application/json
x-api-key: YOUR_API_KEY
Body:
{
"title": "Mi Nuevo Post",
"description": "Descripción del post",
"tags": ["astro", "blog"],
"category": "Tutorial",
"draft": false,
"content": "# Contenido del post\n\nTexto aquí..."
}
Actualizar un post
PUT /api/posts/:fileName
Headers:
Content-Type: application/json
x-api-key: YOUR_API_KEY
Body: (mismo formato que crear)
🔌 Integración con n8n
Paso 1: Añadir Credentials
En n8n:
- Ve a Credentials → New
- Selecciona Header Auth
- Configura:
- Name:
Astro Blog MCP - Header Name:
x-api-key - Value: Tu
API_SECRET_KEY
- Name:
Paso 2: Crear Workflow
- Añade un nodo HTTP Request
- Configura:
- Method:
POST - URL:
http://tu-servidor:3000/api/posts - Authentication: Selecciona las credentials creadas
- Body Content Type:
JSON - Body:
{ "title": "{{ $json.title }}", "description": "{{ $json.description }}", "tags": {{ $json.tags }}, "category": "{{ $json.category }}", "content": "{{ $json.content }}" } - Method:
Ejemplo de Workflow n8n
{
"nodes": [
{
"parameters": {
"method": "POST",
"url": "http://localhost:3000/api/posts",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "headerAuth",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "title",
"value": "Nuevo Post desde n8n"
},
{
"name": "description",
"value": "Post creado automáticamente"
},
{
"name": "tags",
"value": ["automation", "n8n"]
},
{
"name": "category",
"value": "Automation"
},
{
"name": "content",
"value": "# Hola Mundo\n\nEste post fue creado por n8n"
}
]
}
},
"name": "Create Blog Post",
"type": "n8n-nodes-base.httpRequest",
"position": [250, 300]
}
]
}
🐳 Deploy con Docker
docker build -t astro-blog-mcp .
docker run -p 3000:3000 --env-file .env astro-blog-mcp
🔒 Seguridad
- ✅ Autenticación con API Key
- ✅ Rate limiting (20 req/min)
- ✅ Validación de nombres de archivo (previene path traversal)
- ✅ Sanitización de inputs con Zod
- ✅ Timing-safe comparison para API keys
- ✅ CORS configurado
🧪 Testing
El proyecto incluye un script de prueba completo:
pnpm test
Esto probará:
- Health check
- Validación de acceso a GitHub
- Creación de un post de prueba
📝 Formato de Posts
Los posts se crean con este front-matter:
---
title: Título del Post
published: 2025-10-25
description: "Descripción corta"
image: ""
tags: ["tag1", "tag2"]
category: "Categoría"
draft: false
---
Contenido del post aquí...
🛠️ Troubleshooting
Error: "Failed to validate GitHub access"
- Verifica que tu
GITHUB_TOKENsea válido - Confirma que el token tenga permisos de
repo - Verifica que
GITHUB_OWNERyGITHUB_REPOsean correctos
Error: "File already exists"
- El archivo ya existe en el repositorio
- Usa un nombre diferente o el endpoint PUT para actualizar
Error: "API key is required"
- Asegúrate de incluir el header
x-api-keyen tus requests - Verifica que la API key coincida con
API_SECRET_KEY
📚 Recursos
📄 Licencia
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.