๐ Emlog MCP Server
An Emlog blog system integration service based on Model Context Protocol (MCP), allowing AI assistants to interact with Emlog blogs through standardized interfaces.
โจ Features
Resources
- Blog Articles (
emlog://articles) - Retrieve all blog article lists.
- Categories (
emlog://categories) - Obtain all category information.
- Comments (
emlog://comments) - Fetch comment lists (based on latest articles).
- Micro Notes (
emlog://notes) - Get micro note lists.
- Draft Articles (
emlog://drafts) - Retrieve all draft article lists.
- User Information (
emlog://user) - Obtain current user information.
Tools
- create_article - Create new blog articles.
- update_article - Update existing blog articles.
- get_article - Get specific article details.
- search_articles - Search articles (supports keyword, tag, category filtering).
- like_article - Like articles.
- add_comment - Add comments.
- get_comments - Get comment lists for specific articles.
- create_note - Create micro notes.
- upload_file - Upload files (images and other media resources).
- get_user_info - Get user information.
- get_draft_list - Get draft article lists.
- get_draft_detail - Get detailed information of specific drafts.
๐ง Technical Details
- TypeScript - A type-safe JavaScript superset.
- Node.js - A JavaScript runtime environment.
- MCP SDK - Model Context Protocol TypeScript SDK.
- Axios - An HTTP client library.
- Zod - A TypeScript-first schema validation library.
- form-data - Multipart form data processing.
๐ฆ Installation and Configuration
Method 1: Direct Use (Recommended)
Use emlog-mcp directly in Claude Desktop configuration without local installation. Jump to the MCP Client Configuration section.
Method 2: Local Development Installation
1. Clone the Project
git clone https://github.com/eraincc/emlog-mcp.git
cd emlog-mcp
2. Install Dependencies
npm install
3. Environment Variable Configuration
Copy the example configuration file and edit:
cp .env.example .env
Set the following environment variables in the .env file:
EMLOG_API_URL=https://your-emlog-site.com
EMLOG_API_KEY=your_api_key_here
Getting API Key:
- Log in to your Emlog backend management system.
- Navigate to "Settings" โ "API Interface".
- Enable API functionality and generate an API key.
- Copy the generated key to the
.env file.
4. Build Project
npm run build
5. Run Service
npm start
Or use development mode:
npm run dev
๐ MCP Client Configuration
Claude Desktop Configuration
Add to the Claude Desktop configuration file (usually located at ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"emlog": {
"command": "npx",
"args": ["emlog-mcp"],
"env": {
"EMLOG_API_URL": "https://your-emlog-site.com",
"EMLOG_API_KEY": "your_api_key_here"
}
}
}
}
Note: The configuration now directly uses the published npm package emlog-mcp, eliminating the need for local installation or compilation. npx will automatically download and run the latest version.
The project also provides an example configuration file claude-desktop-config.json for reference.
Other MCP Clients
For other MCP-supporting clients, refer to their respective documentation for stdio transport configuration.
๐ API Documentation
This service is built on Emlog's REST API, supporting the following main operations:
Article Management
GET /api/article_list - Retrieve article lists.
GET /api/article_view - Get specific article details.
POST /api/article_save - Create/update articles.
POST /api/article_like - Like articles.
Draft Management
GET /api/draft_list - Retrieve draft lists.
GET /api/draft_detail - Get specific draft details.
Category Management
GET /api/sort_list - Obtain category lists.
Comment Management
GET /api/comment_list - Retrieve comment lists.
POST /api/comment_save - Publish comments.
Micro Notes
GET /api/note_list - Get micro note lists.
POST /api/note_save - Publish micro notes.
File Upload
POST /api/upload - Upload files.
User Management
GET /api/userinfo - Obtain user information.
๐ป Usage Examples
Create Blog Article
{
"name": "create_article",
"arguments": {
"title": "My New Article",
"content": "This is the article content, supporting HTML and Markdown formats.",
"sort_id": 1,
"tag": "technology,programming,MCP",
"is_private": "n",
"allow_comment": "y"
}
}
Search Articles
{
"name": "search_articles",
"arguments": {
"keyword": "technology",
"page": 1,
"count": 10
}
}
Get Article List
{
"uri": "emlog://articles"
}
Get Draft List
{
"name": "get_draft_list",
"arguments": {
"count": 10
}
}
Get Draft Details
{
"name": "get_draft_detail",
"arguments": {
"id": 123
}
}
Upload File
{
"name": "upload_file",
"arguments": {
"file_path": "/path/to/image.jpg"
}
}
Create Micro Note
{
"name": "create_note",
"arguments": {
"content": "This is a micro note",
"is_private": false
}
}
โ ๏ธ Error Handling
The service includes comprehensive error handling mechanisms:
- Network Errors - Automatic retry and timeout handling.
- API Errors - Detailed error information return.
- Authentication Errors - API key validation failure prompts.
- Parameter Errors - Input parameter validation and prompts.
๐ ๏ธ Development and Debugging
Available Scripts
npm run build
npm start
npm run dev
npm run watch
npm test
Log Output
The service outputs runtime status information to stderr for debugging:
Emlog MCP server running on stdio
Test Service
The project includes a simple test script test-server.js to verify if the service is working properly:
node test-server.js
๐ Security Considerations
- API Key Protection - Ensure API keys are not leaked, use environment variables for storage.
- HTTPS Connection - Recommend using HTTPS connection to Emlog API in production.
- Permission Control - Ensure API keys have appropriate permission scope.
- Input Validation - All user inputs are validated and sanitized.
๐ Troubleshooting
Common Issues
-
Connection Failure
- Check if
EMLOG_API_URL is correct.
- Confirm Emlog site is accessible.
-
Authentication Failure
- Verify if
EMLOG_API_KEY is valid.
- Check API key permissions.
-
Tool Call Failure
- Check specific reasons in error messages.
- Confirm parameter format is correct.
๐ Project Structure
emlog-mcp/
โโโ src/ # Source code directory
โ โโโ index.ts # MCP service main entry
โ โโโ emlog-client.ts # Emlog API client
โโโ dist/ # Compiled output directory
โโโ docs/ # Documentation directory
โ โโโ api_doc.md # Detailed Emlog API documentation
โโโ .env.example # Environment variable example file
โโโ .gitignore # Git ignore file configuration
โโโ claude-desktop-config.json # Claude Desktop configuration example
โโโ test-server.js # Test script
โโโ package.json # Project configuration and dependencies
โโโ tsconfig.json # TypeScript configuration
โโโ README.md # Project documentation
๐ค Contributing
Welcome to submit Issues and Pull Requests to improve this project. Before submitting code, please ensure:
- Code passes TypeScript compilation checks.
- Follows project code style.
- Adds appropriate error handling.
- Updates relevant documentation.
๐ License
MIT License
๐ Related Links