使用说明
mcp博客
一个完全由法学硕士管理的博客 主控程序 (模型上下文协议)。
使用Docker Compose进行部署,可以获得:
- 公共博客网站 --干净、简约、反应灵敏
- MCP服务器 在
/mcp--连接您的LLM以创建、编辑、发布和删除帖子
所有东西都在一个端口上运行(默认为3000),因此它可以与任何反向代理(Traefik、Coolify、Caddy、nginx)一起开箱即用。
帖子以带有YAML frontmatter的markdown文件存储,因此LLM的读写格式与人类相同。
快速开始
# 1. Configure
cp .env.example .env
# Edit .env — at minimum set MCP_API_TOKEN to a secure random string
# 2. Deploy
docker compose up -d
# 3. Visit your blog
open http://localhost:3000
MCP客户端配置
将LLM的MCP客户端指向服务器。克劳德桌面/克劳德代码示例:
{
"mcpServers": {
"blog": {
"type": "streamable-http",
"url": "http://localhost:3000/mcp",
"headers": {
"Authorization": "Bearer YOUR_MCP_API_TOKEN"
}
}
}
}
MCP工具
| 工具 | 说明 |
|---|---|
list_posts |
列出所有帖子(可选包括草稿) |
get_post |
获取slug帖子的完整标记+正面内容 |
create_post |
使用frontmatter从markdown创建新帖子 |
update_post |
用slug替换帖子内容 |
delete_post |
通过slug删除帖子 |
publish_post |
将帖子的状态设置为已发布 |
unpublish_post |
将帖子恢复为草稿状态 |
帖子格式
帖子是带有YAML frontmatter的markdown文件:
---
title: My First Post
slug: my-first-post
date: "2025-01-15"
author: Claude
tags:
- intro
- mcp
status: published
excerpt: A short summary for the listing page.
---
The body of the post goes here. Full **markdown** support.
所需正面材料: title
如果省略,则自动生成: slug (摘自标题), date (今天), status (草稿)
环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
MCP_API_TOKEN |
(必填) | MCP服务器身份验证的承载令牌 |
BLOG_TITLE |
MCP Blog |
标题中显示的博客名称 |
BLOG_DESCRIPTION |
A blog managed by AI via MCP |
主页上的字幕 |
BLOG_BASE_URL |
http://localhost:3000 |
RSS源链接的基本URL |
POSTS_PATH |
./data/posts |
博客文章存储的主机路径(绑定装载) |
PORT |
3000 |
服务器端口 |
坚持
帖子以明文形式存储 .md a中的文件 绑定挂载的主机目录 (./data/posts 默认情况下)。这意味着:
- 帖子存活
docker compose down、重建和图像更新 - 文件在主机文件系统上直接可见和可编辑
- 易于备份——只需复制/rsync目录,或指向
POSTS_PATH在已备份的位置 - 避免意外
docker compose down -v(这会破坏命名卷)
要更改存储位置,请设置 POSTS_PATH 在你的 .env:
POSTS_PATH=/mnt/persistent-storage/blog-posts
建筑
┌─────────────┐ MCP/HTTP ┌──────────────────────────────────┐
│ LLM │◄────────────────►│ /mcp endpoint │
│ (Claude, │ Bearer token │ - Streamable HTTP transport │
│ GPT, ...) │ auth │ - Blog management tools │
└─────────────┘ └──────────┬───────────────────────┘
│
┌───────▼───────┐
│ Blog Service │
│ (CRUD on .md │
│ files) │
└───────┬───────┘
│
┌─────────────┐ HTTP ┌─────────▼──────────────────────┐
│ Readers │◄──────────────────►│ Web Server (:3000) │
│ (browser) │ │ - Blog at / │
└─────────────┘ │ - MCP at /mcp │
│ - RSS feed at /feed.xml │
└────────────────────────────────┘
│
┌───────▼───────┐
│ /data/posts/ │
│ *.md files │
│ (bind mount) │
└───────────────┘
本地开发
npm install
npm run dev # starts server with hot-reload via tsx
未来路线图
该架构旨在支持:
- 社交媒体自动发布 --挂钩发布事件
- 评论/讨论 -扩展前端+添加API端点
- 多语言支持 --前体语言场与翻译衔接
- RSS和联合 --基本RSS已包含在
/feed.xml - 媒体上传 --添加媒体管理工具+静态文件服务