- MCP Server (MCP Protocol Compliant)
MCP Server (MCP Protocol Compliant)
Content
MCP Server (MCP Protocol Compliant)
Overview
This server is now a standards-compliant Model Context Protocol (MCP) server. It exposes document generation as an MCP tool, allowing integration with AI hosts (e.g., Copilot, Cursor, Claude Desktop) via the MCP protocol.
MCP Features
- MCP Tool:
generateDocument— Generate PDF, DOCX, PPTX, or XLSX files from a prompt. - Transport: Stdio (local, default). SSE (network) can be added if needed.
- Schema Validation: Uses zod for input validation.
- Extensible: Add more tools/resources/prompts as needed.
Features
- Document Generation: Create PDF, Word, PowerPoint, and Excel files from AI-driven prompts.
- Image Embedding & Resizing: Insert and resize images in DOCX and PPTX files.
- Asynchronous Processing: Queue and process document generation jobs using BullMQ and Redis.
- Validation: Validate document layout by capturing and analyzing screenshots.
- API-First: RESTful endpoints for document generation, job status, and result retrieval.
- Extensible: Modular architecture for easy addition of new file types or tools.
Project Structure
src/
app.js
server.js
config/
controllers/
middleware/
public/
routes/
services/
utils/
workers/
temp_image/
validation-screenshots/
test-output/
Getting Started
Prerequisites
- Node.js (v14+ recommended)
- Redis server
Installation
- Clone the repository:
git clone <repository-url> cd mcp-server - Install dependencies:
npm install - Set up environment variables:
- Copy
.env.exampleto.envand fill in the required values.
- Copy
Running the Server
npm start
Running Tests
npx jest src/services/fileCreation.test.js --runInBand
API Endpoints
POST /documents/generate— Request document generation (PDF, DOCX, PPTX, XLSX)GET /documents/generate/status/:jobId— Check job statusGET /documents/generate/result/:jobId— Download generated file
File Generation & Validation
- Supports AI-driven content and layout via Gemini/OpenAI function calling.
- Image insertion with resizing is available for DOCX and PPTX.
- Layout validation uses screenshots (mocked or real, see
aiFileValidationService).
Example: Image Embedding & Resizing
- Place images in
temp_image/(e.g.,temp_image/blackboard-with-camera-leaf.jpg). - Use function calls like:
{ name: 'addImage', arguments: { path: 'temp_image/blackboard-with-camera-leaf.jpg', options: { width: 150, height: 150 } } }
Usage
Build and Start
npm run build
npm start
MCP Host Configuration Example (stdio)
Add to your host's mcp.json (e.g., for Cursor, VS Code, Claude Desktop):
{
"mcpServers": {
"document-server": {
"command": "/usr/local/bin/node",
"args": ["/absolute/path/to/build/index.js"]
}
}
}
Debugging with MCP Inspector
You can test this server using the official MCP Inspector:
npx @modelcontextprotocol/inspector node build/index.js
Extending
- Add more tools/resources in
src/index.tsusing the MCP SDK. - For SSE/network transport, see the MCP SDK docs and the guide.
Security & Best Practices
- Always validate and sanitize tool/resource inputs.
- Never expose sensitive data without user consent.
- For remote/SSE deployments, implement authentication and TLS.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
MIT
This project now follows the official MCP server standards for Node.js/Typescript.
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Tavily Mcp
DeepChatYour AI Partner on Desktop
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
CursorThe AI Code Editor
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Amap Maps高德地图官方 MCP Server
ChatWiseThe second fastest AI chatbot™
Serper MCP ServerA Serper MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题;
Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.