使用说明
MCP内容库
一个模型上下文协议(MCP)服务器,用于管理写作内容、片段,并为人工智能辅助写作构建即时上下文。
🚀 快速启动(一个命令)
git clone https://github.com/check-the-vibe/mcp-content-library.git
cd mcp-content-library
./bootstrap.sh
引导脚本将:
- ✅ 设置Python虚拟环境
- ✅ 安装所有依赖项
- ✅ 安装Claude CLI(如果可用)
- ✅ 配置MCP连接
- ✅ 提供Codex和OpenCode的设置说明
就是这样! 服务器将准备运行。
其他安装方法
🐳 Docker Compose (Recommended for Production)
# Build and start the service
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the service
docker-compose down
服务器运行于 http://localhost:8000/
⚙️ Systemd Service (Linux Auto-Start)
# Run bootstrap first
./bootstrap.sh
# Install systemd service
./install-systemd.sh
# Service commands
sudo systemctl status mcp-content-library@$USER
sudo systemctl restart mcp-content-library@$USER
sudo journalctl -u mcp-content-library@$USER -f
该服务将在启动时自动启动,并在出现故障时重新启动。
📝 Manual Installation
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -e .
pip install -r requirements.txt
# Create storage directory
mkdir -p ~/.mcp_snippets
# Run server
python server_http.py
🌐 访问服务器
运行后,服务器提供多个端点:
| 端点 | 目的 | URL |
|---|---|---|
| 网页用户界面 | 带有设置说明的友好仪表板 | http://localhost:8000/ |
| MCP协议 | 在此处连接AI客户端 | http://localhost:8000/mcp |
| 健康检查 | 监控服务器状态 | http://localhost:8000/health |
公共访问(GitHub代码空间/云)
在代码空间或云环境中运行时:
# Get your public URL
./get-public-url.sh
重要提示: 确保在“代码空间端口”面板中将端口8000设置为“公共”可见性。
web UI位于 / 自动检测并显示您的公共URL!
🤖 连接AI客户端
Claude CLI(推荐)
运行后 ./bootstrap.sh,Claude CLI会自动配置:
# Start the MCP server
./start.sh
# In another terminal, use Claude
export CLAUDE_MCP_CONFIG=.claude/mcp_config.json
claude chat
Claude CLI手动安装:
# Via npm (recommended)
npm install -g @anthropic-ai/claude-cli
# Or via pip
pip install claude-cli
克劳德桌面和VS代码
添加到MCP配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
窗户: %APPDATA%/Claude/claude_desktop_config.json
VS代码: .vscode/mcp.json
{
"mcpServers": {
"content-library": {
"type": "http",
"url": "http://localhost:8000/mcp"
}
}
}
对于 远程/云服务器,替换 localhost:8000 使用您的公共URL。
配置后重新启动Claude Desktop或重新加载VS Code。
OpenAI 代码克斯
# Install OpenAI Python library
pip install openai
# Set your API key
export OPENAI_API_KEY='your-api-key-here'
# Use in your Python code
import openai
# Configure to use your MCP endpoint
文档: https://platform.openai.com/docs/guides/code
Qwen2.5编码器(开放式代码)
# Install dependencies
pip install transformers torch
# Download and use model
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct")
文档: https://github.com/QwenLM/Qwen2.5-Coder
✨ 特性
- 内容管理:存储和组织从推文到完整章节的内容
- 图表关系:使用类型化关系将代码段链接到父内容
- 元数据:标签、作者、写作风格和源URL跟踪
- 全文检索:TF-IDF搜索,具有高级过滤和排序功能
- 内容提取:用多种策略将长表单分解为片段
- 社交媒体工具:提取平台优化的片段(推特、领英、Instagram)
- 链接跟踪:将URL与内容关联以进行源归因
连接到克劳德
🌟 新访问Web UI
只需打开 http://localhost:8000/ 在您的浏览器中!
登录页面包括:
- ✅ 服务器状态和健康检查
- 📊 内容统计
- 🔗 所有端点URL(自动检测公共URL)
- 📖 Claude、Codex和OpenCode的快速设置指南
- 💻 复制粘贴配置片段
这在通过代码空间或云托管公开共享服务器时特别有用。
详细的Claude设置(遗留文档)
选项1:Claude CLI(建议用于此项目)
Claude CLI允许您从命令行使用MCP服务器。
A.本地配置(项目特定)
在此项目中创建Claude配置文件:
# Create config directory
mkdir -p .claude
# Create the MCP configuration
cat > .claude/mcp_config.json << 'EOF'
{
"mcpServers": {
"content-library": {
"type": "http",
"url": "http://localhost:8000/mcp"
}
}
}
EOF
用途:
# Start the server
./start.sh
# In another terminal, use Claude CLI with the local config
export CLAUDE_MCP_CONFIG=.claude/mcp_config.json
claude chat
# Or specify it per-command
claude chat --mcp-config .claude/mcp_config.json
B.全局配置(所有项目)
添加到您的全局Claude配置 ~/.config/claude/mcp_config.json:
对于当地发展:
{
"mcpServers": {
"content-library": {
"type": "http",
"url": "http://localhost:8000/mcp"
}
}
}
对于GitHub代码空间(公共URL):
{
"mcpServers": {
"content-library": {
"type": "http",
"url": "https://ominous-rotary-phone-p7jgg5vq9rh465-8000.app.github.dev/mcp"
}
}
}
注: 要获取当前的公共URL,请运行
./get-public-url.sh
用途:
# Just use Claude CLI normally - MCP server is auto-loaded
claude chat
选项2:克劳德桌面
Claude Desktop是macOS和Windows的原生应用程序。
配置
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
窗户: %APPDATA%/Claude/claude_desktop_config.json
对于本地服务器:
{
"mcpServers": {
"content-library": {
"type": "http",
"url": "http://localhost:8000/mcp"
}
}
}
对于GitHub代码空间(如果服务器正在那里运行):
{
"mcpServers": {
"content-library": {
"type": "http",
"url": "https://ominous-rotary-phone-p7jgg5vq9rh465-8000.app.github.dev/mcp"
}
}
}
⚠️ 重要提示: 要使代码空间URL工作,您必须:
- 确保服务器正在运行:
./start.sh- 打开 港口 VS代码中的面板(视图→ 港口)
- 右键单击端口8000→ 港口可见性 → 公共
激活服务器
- 保存配置文件
- 完全重新启动克劳德桌面 (退出并重新打开)
- 寻找🔌 UI中的插件图标-这表示MCP服务器已加载
- 内容库工具将自动出现在您的对话中
选项3:Claude.ai网站
⚠️ 注: claude.ai网站 不 目前支持自定义MCP服务器。MCP服务器必须在本地运行,并通过Claude Desktop或Claude CLI连接。
如果你想在claude.ai中使用它,你需要使用以下变通方法之一:
- 使用 克劳德桌面 相反(相同的web界面,但本机应用程序)
- 使用 Claude CLI 用于基于终端的访问
- 等待Anthropic为claude.ai添加自定义MCP支持
验证
配置后,验证连接:
Claude CLI
# List available MCP servers
claude mcp list-servers
# List tools from the content library
claude mcp list-tools content-library
# Test adding content
claude mcp call content-library tool_add_content \
--content "Test snippet" \
--style '["snippet"]' \
--tags '["test"]'
克劳德桌面
- 打开克劳德桌面
- 开始新的对话
- 寻找🔌 图标(表示已加载MCP服务器)
- 试着问:“你能用标签'test'将测试片段添加到我的内容库中吗?”
- 克劳德应该使用
tool_add_content工具自动
获取您的公共URL
如果你在GitHub Codespace中运行并且需要公共URL:
./get-public-url.sh
这将显示您当前的公共URL,您可以在任何Claude客户端配置中使用。
故障排除
Claude CLI找不到服务器:
- 验证配置文件位置:
cat ~/.config/claude/mcp_config.json - 检查服务器是否正在运行:
curl http://localhost:8000/mcp - 尝试使用本地配置:
claude chat --mcp-config .claude/mcp_config.json
Claude Desktop未显示工具:
- 完全重新启动克劳德桌面
- 检查配置文件中的JSON语法(使用JSON验证器)
- 确保URL正确且服务器可访问
- 在Claude Desktop的日志中查找错误消息
公共URL不起作用:
- 确保服务器正在运行:
lsof -i :8000 - 检查Codespace中的端口可见性是否设置为“Public”
- 测试URL:
curl https://your-url/mcp
文档
有关完整的设置说明、所有提供程序的配置(VS Code、Claude CLI、ClaudeDesktop、Cline)、API参考和使用示例,请参阅:
📖 CLAUDE.md-完整安装指南
本指南包括:
- GitHub代码空间设置(自动)
- 当地开发设置
- VS代码、Claude CLI、Claude Desktop、Cline的配置
- 所有可用的工具和参数
- 使用示例和工作流程
- 架构和故障排除
GitHub代码空间
此项目针对代码空间进行了优化,并自动执行以下操作:
- 依赖项安装
- 端口转发(端口8000)
- 环境配置
只需创建一个代码空间并运行 python server_http.py!
项目结构
├── server.py # STDIO server
├── server_http.py # HTTP server
├── storage.py # File-based storage
├── schemas.py # Data models
├── search.py # Full-text search
├── content_tools.py # Content extraction
├── .vscode/mcp.json # VS Code configuration
└── CLAUDE.md # Complete documentation
可用工具(预览)
- 内容:
add_content,get_node,search - 链接:
add_link,link_url - 提取:
extract_by_paragraph,extract_for_social_media,extract_similar_sections - 关系:
link_relates,link_tag,link_author - 公用事业:
reindex,combine_related_snippets
看 CLAUDE.md 获取完整文档。
许可证
MIT许可证-有关详细信息,请参阅许可证文件