cnblogs-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cnblogs-mcpPublish a new blog post titled 'Getting Started with MCP' with markdown content."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
cnblogs MCP Server
Wraps the cnblogs Open API into tools callable by AI via the MCP (Model Context Protocol) protocol. Allows you to publish cnblogs posts directly using natural language in any MCP client (QwenPaw, Claude Desktop, Cline, etc.).
Features
✅
create_post— Publish Markdown blog posts to cnblogs✅ Token managed via
.env, no hardcoding✅ Supports integration with any MCP client
Related MCP server: blogger-cli-mcp
Table of Contents
Quick Start
1. Clone / Download the project
git clone https://github.com/你的用户名/cnblogs-mcp.git
cd cnblogs-mcp2. Create a virtual environment
python -m venv .venv
source .venv/bin/activate # macOS / Linux
# .venv\Scripts\activate # Windows3. Install dependencies
pip install -r requirements.txt4. Configure Token
cp .env.example .envEdit .env and fill in your cnblogs Personal Access Token:
CNBLOGS_TOKEN=your_token_here5. Run tests
# 验证 MCP 服务能正常启动
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}\n{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}\n' \
| python cnblogs_mcp.py 2>/dev/null | grep '"name"'Normal output:
{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"create_post",...}]}}Get Token
Log in to cnblogs
Go to Personal Settings → Security Settings → Personal Access Token
Click "Create Token", fill in the name and permissions (requires "Post Blog" permission)
Copy the generated Token and fill it into the
.envfile
⚠️ The Token is only displayed once, please save it properly.
Client Integration
1. QwenPaw
Find agent.json in the QwenPaw working directory and add the MCP client:
{
"mcp": {
"clients": {
"cnblogs": {
"name": "cnblogs",
"description": "博客园博文发布",
"enabled": true,
"transport": "stdio",
"command": "/absolute/path/to/cnblogs-mcp/.venv/bin/python",
"args": ["/absolute/path/to/cnblogs-mcp/cnblogs_mcp.py"],
"env": {
"DOTENV_PATH": "/absolute/path/to/cnblogs-mcp/.env"
}
}
}
}
}Restart QwenPaw:
qwenpaw daemon restart2. Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"cnblogs": {
"command": "/absolute/path/to/cnblogs-mcp/.venv/bin/python",
"args": ["/absolute/path/to/cnblogs-mcp/cnblogs_mcp.py"],
"env": {
"DOTENV_PATH": "/absolute/path/to/cnblogs-mcp/.env"
}
}
}
}Restart Claude Desktop.
3. Cline / Roo Code
Search for "MCP" in VS Code settings, find MCP Servers, and add:
{
"cnblogs": {
"command": "/absolute/path/to/cnblogs-mcp/.venv/bin/python",
"args": ["/absolute/path/to/cnblogs-mcp/cnblogs_mcp.py"],
"env": {
"DOTENV_PATH": "/absolute/path/to/cnblogs-mcp/.env"
}
}
}4. Other MCP Clients
General configuration template:
Parameter | Value |
|
|
|
|
| Absolute path to the |
💡 If the MCP client does not support
DOTENV_PATH, you can also pass the token directly usingenv.CNBLOGS_TOKEN.
Manual Testing
cd cnblogs-mcp
# 测试 1:初始化 + 工具列表
printf '...' | python cnblogs_mcp.py
# 测试 2:发布一篇博文
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}\n{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"create_post","arguments":{"title":"测试","body":"## 你好\n\n这是一篇测试文章。"}}}\n' | python cnblogs_mcp.py 2>/dev/nullNormal return:
{"success": true, "postId": 12345678, "postUrl": "https://www.cnblogs.com/你的博客名/p/12345678"}Error Handling
Error Message | Reason | Solution |
|
| Check if |
| Token invalid or expired | Re-create Token on cnblogs |
| Insufficient Token permissions | Ensure "Post Blog" is checked when creating the Token |
| Request format error | Check if title and body are empty |
| Network issue | Check network and retry |
Tool list empty after MCP connection |
| Ensure |
API Reference
Tool: create_post
Parameters:
Parameter | Type | Required | Description |
| string | ✅ | Blog post title |
| string | ✅ | Blog post body (Markdown format) |
Return Value:
{
"success": true,
"postId": 19246558,
"postUrl": "https://www.cnblogs.com/你的博客名/p/19246558"
}Or on error:
{
"success": false,
"error": "错误描述"
}Development
Project Structure
cnblogs-mcp/
├── cnblogs_mcp.py # MCP 服务主文件
├── requirements.txt # Python 依赖
├── .env.example # 环境变量模板(不含真实 Token)
├── .env # 你的本地配置(已在 .gitignore 中)
├── .gitignore
├── README.md
└── LICENSEDependencies
fastmcp>=3.0.0
python-dotenv>=1.0.0
requests>=2.31.0License
MIT — Stars, Forks, and PRs are welcome!
This server cannot be deployed
Maintenance
Related MCP Connectors
Publish and share access-controlled Markdown documents from any MCP-enabled AI tool.
Hosted MCP for BlogBat: read, write, generate, and publish blog articles and content.
Create, edit, organize, publish, and configure JustBlogged blogs from MCP clients.
Generate PDF, Word (.docx) and PowerPoint (.pptx) documents from Markdown over MCP.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceConverts Markdown to Feishu/Lark document format and provides an MCP service for integration with the Model Context Protocol.29MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for managing Blogger posts: create, update, retrieve posts, and upload images to GCS via natural language.2MIT
- AlicenseAqualityAmaintenanceEnables publishing local Markdown files to Velog with idempotent updates. Supports login, post management, and series operations through natural language.10MIT
- AlicenseAqualityCmaintenanceEnables publishing markdown blog posts directly to Dev.to as drafts or live articles through a single MCP tool, with support for tags, series, canonical URL, and cover image.1MIT