๐ Halo MCP Server
Integrate the Halo blogging system with AI assistants (such as Claude, Cursor, Qoder, Trae, etc.) seamlessly via MCP, making AI your blog management assistant.
๐ Quick Start
๐ Prerequisites
-
Python 3.10 or higher
python --version
-
A running Halo blog system
- Halo 2.21 or higher
- Record the server address (e.g.,
http://localhost:8091 or https://yourdomain.com)
-
Claude Desktop or other MCP-compatible clients
๐ฆ Installation
Method 1: Install from source code (for development)
git clone https://github.com/Huangwh826/halo-mcp-server.git
cd halo-mcp-server
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
pip install -e .
Method 2: Install using pip (recommended)
pip install halo-mcp-server
๐ง Configuration
Step 1: Get the Halo access token
- Log in to the Halo backend management system.
- Go to Personal Center โ Personal Tokens.
- Click Generate New Token.
- Set the token name (e.g., "MCP Server").
- Select permissions (it is recommended to check all content management permissions).
- Save and copy the generated token (it will only be displayed once).
Step 2: Configure Claude Desktop
Find and edit the Claude Desktop configuration file:
File location:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Linux:
~/.config/Claude/claude_desktop_config.json
Configuration content:
{
"mcpServers": {
"halo-mcp-server": {
"command": "python",
"args": [
"-m",
"halo_mcp_server"
],
"env": {
"HALO_BASE_URL": "your_halo_base_url_here",
"HALO_TOKEN": "your_halo_token_here"
}
}
}
}
๐ Configuration description:
| Configuration item |
Description |
Example |
command |
Path to the Python interpreter |
python or C:\\Python310\\python.exe |
HALO_BASE_URL |
Halo server address |
http://localhost:8091 or https://blog.example.com |
HALO_TOKEN |
API access token |
Token obtained from the Halo backend |
๐ก Tips:
-
When using a virtual environment, point command to the Python in the virtual environment:
"command": "D:\\Project\\halo-mcp\\venv\\Scripts\\python.exe"
-
Find the Python path:
where python
which python
-
For remote Halo services, make sure to use the full URL (including http:// or https://).
Step 3: Restart Claude Desktop
Completely close and restart Claude Desktop to load the new configuration.
โ
Verify the installation
Enter the following test command in Claude Desktop:
Please list all my blog posts
Expected results:
- Claude will call the Halo MCP Server.
- Return your list of articles.
- If there are no articles, it will prompt "No articles yet".
Success indicators:
- โ
No errors.
- โ
Returned a list of articles or a prompt message.
- โ
Claude understood the instruction "List articles".
โจ Features
๐ Article Management (9 tools)
| Operation Type |
Details |
| Basic Operations |
- โ
Create an article (supports Markdown) - โ
Edit an article (title, content, settings) - โ
Publish/Unpublish an article - โ
Delete an article (move to the recycle bin) - โ
List my articles (with pagination and filtering) |
| Advanced Features |
- โ
Draft management (view and edit drafts) - โ
Category and tag management - โ
Pin/Unpin an article - โ
Set a cover image - โ
Customize the URL alias |
๐ท๏ธ Category and Tag Management (13 tools)
| Management Type |
Details |
| Category Management (6 tools) |
- โ
List all categories - โ
Create a category (supports hierarchical structure) - โ
Update a category (name, description, cover) - โ
Delete a category - โ
Get category details - โ
View articles under a category |
| Tag Management (7 tools) |
- โ
List all tags - โ
Create a tag (supports colors) - โ
Update a tag (name, color) - โ
Delete a tag - โ
Get tag details - โ
View articles under a tag - โ
List console tags |
๐ Attachment Management (8 tools)
- โ
List attachments (supports filtering)
- โ
Upload a local file
- โ
Upload from a URL
- โ
Delete an attachment
- โ
Attachment group management
- โ
View attachment details
- โ
Create an attachment group
- โ
View storage policies
๐ค AI Writing Assistant (10 Prompts)
| Function Type |
Details |
| Content Creation |
- ๐จ Blog writing assistant - Generate high-quality articles - โจ Content optimizer - Improve readability and structure - ๐ฏ SEO optimizer - Improve search rankings - ๐ฐ Title generator - Create attractive titles - ๐ Summary generator - Automatically generate article summaries |
| Auxiliary Functions |
- ๐ท๏ธ Tag suggester - Intelligently recommend tags - ๐ Category suggester - Recommend appropriate categories - ๐ Content translator - Multi-language translation - โ๏ธ Content proofreader - Grammar and spelling check - ๐ Series planner - Plan a series of articles |
๐ป Usage Examples
๐ Complete example documentation: Check examples/README.md for 6 detailed examples and complete code.
๐ Quick start: quick_start_example.md - Get to know the basic usage in 5 minutes.
๐ Natural Language Interaction (Recommended)
The greatest advantage of the Halo MCP Server is that it supports natural language dialogue, eliminating the need to memorize complex commands:
๐ Article Creation
๐ค User: Write and publish a technical article about Python asynchronous programming for me.
๐ค Claude:
Sure! I'll help you create this article.
[Automatically trigger the halo_blog_writing_assistant Prompt]
โ Generate a 2000-word professional article
โ Recommended tags: Python, asynchronous programming, asyncio
โ Recommended category: Technical tutorials
โ Call create_post to create the article
โ Call publish_post to publish the article
โ The article "A Complete Guide to Python Asynchronous Programming" has been successfully created and published!
๐ Article Management
# View articles
Please show me the 5 most recently published articles.
# Search for articles
Search for articles whose titles contain "Python".
# Edit an article
Change the title of the article "Python Tutorial" to "Python Getting Started Guide".
# Delete an article
Delete the article named "test-post".
โจ Content Optimization
# Optimize an article
Please optimize the article "Python Tutorial" to make it more accessible.
# Generate titles
Generate 5 attractive titles for this article.
# SEO optimization
Help optimize the SEO of this article with the keywords: Python, tutorial, getting started.
๐ท๏ธ Category and Tag Management
# Create a category
Create a category named "Technical Tutorials" with the description "Articles on various technical tutorials".
# Create tags
Create tags: Python, JavaScript, TypeScript, and set the color to blue.
# Batch operations
Add tags: Python, programming, tutorial to the article "Python Tutorial".
๐ Attachment Management
# Upload an image
Upload this image as the article cover: https://example.com/image.jpg.
# View attachments
List all image attachments.
# Create a group
Create an attachment group named "Article illustrations".
๐ Complete Workflow Example
Scenario: Publish a technical blog from scratch
๐ค User: I want to write a technical article about Docker containerization.
๐ค Claude:
Sure! I'll help you complete the entire creation and publishing process.
Step 1: Content creation
[Trigger halo_blog_writing_assistant]
โ Generate a complete article (including an introduction, core concepts, practical examples, and a summary)
Step 2: Title optimization
[Trigger halo_title_generator]
โ Provide 5 title options for selection
Step 3: SEO optimization
[Trigger halo_seo_optimizer]
โ Optimize keyword layout
โ Generate a Meta description
Step 4: Category and tag management
[Trigger halo_tag_suggester]
โ Recommended tags: Docker, containerization, DevOps, cloud-native
[Trigger halo_category_suggester]
โ Recommended category: Cloud-native technology
Step 5: Create and publish
[Call create_post]
โ Create the article
[Call publish_post]
โ Publish the article
โ Done! The article "A Practical Guide to Docker Containerization" has been successfully published.
- Word count: 2000
- Tags: Docker, containerization, DevOps, cloud-native
- Category: Cloud-native technology
- Article link: https://yourblog.com/posts/docker-guide
๐ฏ Core Concepts
MCP Tools vs Prompts
The Halo MCP Server provides two different capabilities:
| Type |
Tools |
Prompts |
Comparison |
| Quantity |
30 |
10 |
Complementary |
| Purpose |
Perform specific operations (CRUD) |
Generate content guidance |
Tools execute; Prompts generate |
| Visibility |
โ
Visible in the tool list |
โ Automatically triggered in the background |
Explicit vs Implicit |
| Invocation |
Claude actively calls the API |
Automatically matched according to intent |
API vs Intelligent |
| Examples |
- create_post - Create an article - list_categories - List categories - upload_attachment - Upload an attachment |
- Blog writing assistant - Generate an article - SEO optimizer - Optimize content - Tag suggester - Recommend tags |
Operations vs Creation |
| Trigger Method |
Explicit operation instructions: "Create an article" "Upload an image" |
Descriptive requirements: "Write an article" "Optimize content" |
Commands vs Dialogue |
๐ก Actual workflow:
User: "Help me write a Python tutorial and publish it."
โ
Prompts: halo_blog_writing_assistant โ Generate article content
โ
Tools: create_post โ Create the article in Halo
โ
Tools: publish_post โ Publish the article
โ
Result: โ The article has been created and published successfully.
Why can't you see the Prompts?
This is an excellent design of MCP:
- โ
User-friendly - No need to memorize Prompt names.
- โ
Intelligent matching - AI automatically understands intent and selects the appropriate Prompt.
- โ
Seamless experience - Works automatically in the background, and users only need to describe their needs.
- โ
Flexibility - Can express the same requirement in various ways.
Comparison with traditional methods:
$ halo-cli create-post \
--title "Python Tutorial" \
--content-file article.md \
--tags "Python,tutorial" \
--category "Programming" \
--publish
Help me write a Python tutorial and publish it.
๐ Documentation
Core Documentation
| Document |
Description |
| Quick Start |
A 5-minute quick start guide |
| Design Document |
System architecture and design concepts |
| MCP Prompts Guide |
Detailed instructions for 10 writing assistants |
| Prompts vs Tools |
Differences and usage methods between the two |
| Usage Examples |
A complete set of usage examples |
API Documentation
| Document |
Description |
| API Compilation |
Compilation of Halo APIs |
| Console API |
Halo console API |
| Public API |
Halo public API |
| UC API |
Halo user content API |
| Extension API |
Halo extension API |
๐ Example Code
๐ก Complete example guide: Check examples/README.md for detailed example documentation and usage instructions.
๐ Example Directory Structure
examples/
โโโ README.md # ๐ Overview and detailed guide for examples
โโโ quick_start_example.md # โก Quick start (must-read)
โโโ usage_examples.md # ๐ Collection of usage examples
โโโ category_management_examples.py # ๐ท๏ธ Complete example of category management
โโโ tag_management_examples.py # ๐ Complete example of tag management
โโโ attachment_management_examples.py # ๐ Complete example of attachment management
โโโ mcp_prompts_examples.py # ๐ค Example of AI writing assistant
๐ Quick Start
Recommended path for beginners:
- ๐ Quick Start Example - Get to know the basic usage in 5 minutes.
- ๐ Collection of Usage Examples - Common scenarios and best practices.
- ๐ Complete Example Guide - Detailed documentation for all examples.
Learn by function:
| Example File |
Function |
Difficulty |
Description |
| quick_start_example.md |
Quick start |
โญ |
Actual invocation example, showing basic usage |
| usage_examples.md |
Comprehensive example |
โญโญ |
Covers usage scenarios of all tools |
| category_management_examples.py |
Category management |
โญโญ |
A 279-line complete code example |
| tag_management_examples.py |
Tag management |
โญโญ |
A 375-line complete code example |
| attachment_management_examples.py |
Attachment management |
โญโญโญ |
A 477-line complete code example |
| mcp_prompts_examples.py |
AI writing assistant |
โญโญโญ |
A 341-line example of using Prompts |
๐ก Usage Tips
- Markdown examples (
.md) - Suitable for reading and understanding, containing detailed explanations.
- Python examples (
.py) - Complete code that can be run directly, containing comments.
- From simple to complex - It is recommended to learn in the order shown in the table above to gradually master all functions.
Run Python examples:
export HALO_BASE_URL="your_url"
export HALO_TOKEN="your_token"
cd examples
python category_management_examples.py
๐ง Configuration Instructions
Environment Variables
Create a .env file or set the following in the Claude Desktop configuration:
# ========== Required Configuration ==========
HALO_BASE_URL=http://localhost:8091 # Halo server address
HALO_TOKEN=your_token_here # API access token
# ========== Optional Configuration ==========
MCP_LOG_LEVEL=INFO # Log level: DEBUG, INFO, WARNING, ERROR
MCP_TIMEOUT=30 # HTTP request timeout (seconds)
# ========== Feature Switches ==========
ENABLE_IMAGE_COMPRESSION=true # Enable image compression
IMAGE_MAX_WIDTH=1920 # Maximum width after compression (pixels)
IMAGE_QUALITY=85 # Image quality (1-100)
MAX_UPLOAD_SIZE_MB=10 # Maximum upload size (MB)
# ========== Advanced Configuration ==========
HTTP_POOL_SIZE=10 # HTTP connection pool size
MAX_RETRIES=3 # Number of request retries
ENABLE_CACHE=true # Enable caching
CACHE_TTL=300 # Cache expiration time (seconds)
Refer to .env.example for a complete configuration description.
๐ ๏ธ Troubleshooting
Common Issues
1. Claude cannot recognize Halo tools
Symptom: Claude does not respond to blog management commands.
Solution:
2. Authentication failure
Symptom: Error messages such as "Authentication failed" or "Invalid token".
Solution:
- Check if
HALO_TOKEN is correct (no extra spaces).
- Make sure the token has not expired.
- Verify that
HALO_BASE_URL is accessible.
- Test the network connection:
curl http://localhost:8091/apis/api.console.halo.run/v1alpha1/posts
3. Module import error
Symptom: "No module named 'halo-mcp-server'".
Solution:
pip install -e .
pip show halo-mcp-server
python -c "import halo-mcp-server; print(halo_mcp_server.__version__)"
4. Prompts do not work
Symptom: AI cannot automatically generate article content.
Explanation: Prompts are hidden and triggered by natural language.
Test method:
# โ
Correct way (will trigger the writing Prompt)
Help me write an article about Python.
# โ Incorrect understanding (not necessary)
Use halo_blog_writing_assistant to write an article.
Debugging Methods
View Logs
Set the debug level:
{
"mcpServers": {
"halo": {
"env": {
"MCP_LOG_LEVEL": "DEBUG"
}
}
}
}
Log locations:
- Claude Desktop logs: Help โ Developer Tools โ Console
- MCP service logs: Check the standard output
Manual Testing
Test authentication:
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8091/apis/uc.api.content.halo.run/v1alpha1/posts
Test the Python module:
python
>>> from halo_mcp_server.client import HaloClient
>>> import asyncio
>>> client = HaloClient()
>>> asyncio.run(client.authenticate())
>>> print("โ Authentication successful")
๐๏ธ Development
Development Environment Setup
git clone https://github.com/Huangwh826/halo_mcp_server.git
cd halo-mcp-server
python -m venv venv
source venv/bin/activate
pip install -e ".[dev]"
pre-commit install
Project Structure
halo-mcp-server/
โโโ src/halo-mcp-server/ # Source code
โ โโโ __init__.py
โ โโโ __main__.py # Entry file
โ โโโ config.py # Configuration management
โ โโโ server.py # MCP server
โ โโโ exceptions.py # Exception definitions
โ โโโ client/ # Halo API client
โ โ โโโ base.py
โ โ โโโ halo_client.py
โ โโโ tools/ # MCP Tools
โ โ โโโ post_tools.py
โ โ โโโ category_tools.py
โ โ โโโ tag_tools.py
โ โ โโโ attachment_tools.py
โ โโโ prompts/ # MCP Prompts
โ โ โโโ blog_prompts.py
โ โโโ utils/ # Utility functions
โ โโโ logger.py
โโโ tests/ # Unit tests
โโโ examples/ # Usage examples
โโโ halo_apis_docs/ # API documentation
โโโ debug_tests/ # Debugging scripts
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
Code Style
black src/ tests/
isort src/ tests/
mypy src/
ruff check src/ tests/
pytest tests/ -v --cov=halo-mcp-server
Add New Features
-
Add a new Tool:
from mcp.types import Tool
async def my_custom_tool(client, arguments):
"""Implement your tool logic"""
pass
MY_TOOLS = [
Tool(
name="my_tool",
description="Tool description",
inputSchema={...}
)
]
-
Add a new Prompt:
from mcp.types import Prompt, PromptArgument
CUSTOM_PROMPTS = [
Prompt(
name="my_prompt",
description="Prompt description",
arguments=[...]
)
]
-
Register with the Server:
from halo_mcp_server.tools.custom_tools import MY_TOOLS
from halo_mcp_server.prompts.custom_prompts import CUSTOM_PROMPTS
all_tools += MY_TOOLS
all_prompts += CUSTOM_PROMPTS
Contribution Guidelines
Contributions are welcome! Please check DEVELOPMENT.md for detailed information.
๐งช Testing
Quick Testing
The project provides a comprehensive test suite covering all 30 MCP tools:
cd tests
python run_comprehensive_test.py
Test Coverage
โ
Category Management (6 tools): create_category, list_categories, get_category, update_category, get_category_posts, delete_category
โ
Tag Management (7 tools): create_tag, list_tags, get_tag, update_tag, list_console_tags, get_tag_posts, delete_tag
โ
Attachment Management (8 tools): Upload, list, delete, group management, etc.
โ
Article Management (9 tools): Create, edit, publish, draft management, etc.
Test Details
Check tests/README.md for:
- ๐ Detailed test guide
- ๐ง Environment configuration instructions
- ๐ Troubleshooting methods
- ๐ Test report generation
๐ Feature Comparison Table
Complete Tool List (30 tools)
๐ Article Management Tools (9 tools)
| Tool Name |
Function Description |
Invocation Example |
list_my_posts |
List my articles |
"List all my articles" |
get_post |
Get article details |
"Show the details of post-xxx" |
create_post |
Create an article |
"Create an article" |
update_post |
Update an article |
"Update the article title" |
publish_post |
Publish an article |
"Publish this article" |
unpublish_post |
Unpublish an article |
"Take this article offline" |
delete_post |
Delete an article |
"Delete this article" |
get_post_draft |
Get a draft |
"View the draft content" |
update_post_draft |
Update a draft |
"Modify the draft" |
๐ท๏ธ Category Management Tools (6 tools)
| Tool Name |
Function Description |
Invocation Example |
list_categories |
List categories |
"List all categories" |
get_category |
Get category details |
"View category details" |
create_category |
Create a category |
"Create a technical category" |
update_category |
Update a category |
"Modify the category name" |
delete_category |
Delete a category |
"Delete this category" |
get_category_posts |
Get articles under a category |
"View articles under this category" |
๐ Tag Management Tools (7 tools)
| Tool Name |
Function Description |
Invocation Example |
list_tags |
List tags |
"List all tags" |
get_tag |
Get tag details |
"View tag details" |
create_tag |
Create a tag |
"Create a Python tag" |
update_tag |
Update a tag |
"Modify the tag color" |
delete_tag |
Delete a tag |
"Delete this tag" |
get_tag_posts |
Get articles under a tag |
"View articles under this tag" |
list_console_tags |
List console tags |
"View console tags" |
๐ Attachment Management Tools (8 tools)
| Tool Name |
Function Description |
Invocation Example |
list_attachments |
List attachments |
"List all attachments" |
get_attachment |
Get attachment details |
"View attachment details" |
upload_attachment |
Upload a file |
"Upload this file" |
upload_attachment_from_url |
Upload from a URL |
"Upload an image from a URL" |
delete_attachment |
Delete an attachment |
"Delete this attachment" |
list_attachment_groups |
List attachment groups |
"List attachment groups" |
create_attachment_group |
Create a group |
"Create an image group" |
get_attachment_policies |
Get storage policies |
"View storage policies" |
Complete Prompts List (10 Prompts)
๐ค Detailed Description of AI Writing Assistant
| Prompt Name |
Function Description |
Trigger Example |
Main Parameters |
halo_blog_writing_assistant |
Blog writing assistant |
"Write a Python article" |
topic, audience, type, word_count |
halo_content_optimizer |
Content optimizer |
"Optimize this article" |
content, focus, length |
halo_seo_optimizer |
SEO optimizer |
"Optimize SEO" |
title, content, keywords |
halo_title_generator |
Title generator |
"Generate 5 titles" |
content_summary, style, count |
halo_excerpt_generator |
Summary generator |
"Generate a summary" |
content, length, style |
halo_tag_suggester |
Tag suggester |
"Recommend tags" |
title, content, existing_tags |
halo_category_suggester |
Category suggester |
"Recommend a category" |
title, content, existing_categories |
halo_content_translator |
Content translator |
"Translate into English" |
content, target_language |
halo_content_proofreader |
Content proofreader |
"Proofread an article" |
content, language, focus |
halo_series_planner |
Series planner |
"Plan a series of articles" |
series_topic, audience, count |
๐ค Contribution
Contributions of code, issue reports, or suggestions are welcome!
Ways to Contribute
- Fork the project.
- Create a feature branch (
git checkout -b feature/AmazingFeature).
- Commit your changes (
git commit -m 'Add some AmazingFeature').
- Push to the branch (
git push origin feature/AmazingFeature).
- Open a Pull Request.
Contributors
Thank you to all developers who have contributed to the project!
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Halo - An excellent open-source blog system.
- Model Context Protocol - A powerful AI integration protocol.
- Claude - An intelligent AI assistant.
- All contributors and users.
๐ Contact Us
๐ Support the Project
If this project is helpful to you, you can support it in the following ways:
- โญ Give the project a Star.
- ๐ Submit an Issue or PR.
- ๐ฌ Share it with more people.
- โ Make a donation to the author.
Thank you for your support!
โญ If this project is helpful to you, please give it a Star!