An Emlog blog system integration service based on Model Context Protocol (MCP), allowing AI assistants to interact with Emlog blogs through standardized interfaces.
- Blog Articles (
emlog://articles
) - Get all blog article lists - Categories (
emlog://categories
) - Get all category information - Comments (
emlog://comments
) - Get comment lists (based on latest articles) - Micro Notes (
emlog://notes
) - Get micro note lists - Draft Articles (
emlog://drafts
) - Get all draft article lists - User Information (
emlog://user
) - Get current user information
- 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
- TypeScript - Type-safe JavaScript superset
- Node.js - JavaScript runtime environment
- MCP SDK - Model Context Protocol TypeScript SDK
- Axios - HTTP client library
- Zod - TypeScript-first schema validation library
- form-data - Multipart form data processing
Use emlog-mcp
directly in Claude Desktop configuration without local installation. Jump to MCP Client Configuration section.
git clone https://github.com/eraincc/emlog-mcp.git
cd emlog-mcp
npm install
Copy the example configuration file and edit:
cp .env.example .env
Set the following environment variables in the .env
file:
# Emlog API base URL (required)
EMLOG_API_URL=https://your-emlog-site.com
# Emlog API key (required)
EMLOG_API_KEY=your_api_key_here
Getting API Key:
- Log in to your Emlog backend management system
- Go to "Settings" → "API Interface"
- Enable API functionality and generate API key
- Copy the generated key to the
.env
file
npm run build
npm start
Or development mode:
npm run dev
Add to 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
, no local installation or compilation required. npx
will automatically download and run the latest version.
The project also provides an example configuration file claude-desktop-config.json
for reference.
For other MCP-supporting clients, please refer to their respective documentation for stdio transport configuration.
This service is built on Emlog's REST API, supporting the following main operations:
GET /api/article_list
- Get article listsGET /api/article_view
- Get specific article detailsPOST /api/article_save
- Create/update articlesPOST /api/article_like
- Like articles
GET /api/draft_list
- Get draft listsGET /api/draft_detail
- Get specific draft details
GET /api/sort_list
- Get category lists
GET /api/comment_list
- Get comment listsPOST /api/comment_save
- Publish comments
GET /api/note_list
- Get micro note listsPOST /api/note_save
- Publish micro notes
POST /api/upload
- Upload files
GET /api/userinfo
- Get user information
// Through MCP tool call
{
"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 containing keywords
{
"name": "search_articles",
"arguments": {
"keyword": "technology",
"page": 1,
"count": 10
}
}
// Through MCP resource access
{
"uri": "emlog://articles"
}
// Get draft list
{
"name": "get_draft_list",
"arguments": {
"count": 10
}
}
// Get detailed information of specific draft
{
"name": "get_draft_detail",
"arguments": {
"id": 123
}
}
// Upload image file
{
"name": "upload_file",
"arguments": {
"file_path": "/path/to/image.jpg"
}
}
// Publish micro note
{
"name": "create_note",
"arguments": {
"content": "This is a micro note",
"is_private": false
}
}
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
# Build project
npm run build
# Start service
npm start
# Development mode (auto restart)
npm run dev
# Watch mode (auto compile)
npm run watch
# Run tests
npm test
The service outputs runtime status information to stderr for debugging:
Emlog MCP server running on stdio
The project includes a simple test script test-server.js
to verify if the service is working properly:
node test-server.js
- 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
-
Connection Failure
- Check if
EMLOG_API_URL
is correct - Confirm Emlog site is accessible
- Check if
-
Authentication Failure
- Verify if
EMLOG_API_KEY
is valid - Check API key permissions
- Verify if
-
Tool Call Failure
- Check specific reasons in error messages
- Confirm parameter format is correct
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
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
MIT License