README
🚀 orly-mcp
orly-mcp 是一个 MCP(模型上下文协议)服务器,用于生成 O'RLY?(对 O'Reilly 的模仿)风格的书籍封面,这些封面可直接在 Claude Desktop 应用程序中显示。
项目徽章
项目演示

🚀 快速开始
在 MCP 服务器上安装
只需将以下内容添加到您的 MCP 配置中:
// ... 其他 MCP 服务器 ...
"mcp-orly": {
"command": "uvx",
"args": [
"orly-mcp@latest"
]
}
// ... 其他 MCP 服务器 ...
本地开发
# 克隆仓库
git clone [your-repo-url]
cd orly-mcp
# 创建虚拟环境并安装依赖
uv venv .venv
uv pip install -r requirements.txt
# 测试示例图像生成
uv run python test_mcp.py
# 运行综合测试
uv run python test_comprehensive.py
# 启动 MCP 开发服务器
python start_server.py
📚 详细文档
Claude Desktop 配置
将此 MCP 服务器添加到您的 Claude Desktop 配置文件(claude_desktop_config.json)中:
推荐配置
{
"mcpServers": {
"orly-local": {
"command": "uv",
"args": [
"run",
"--with", "fastmcp",
"--with", "pillow",
"--with", "fonttools",
"--with", "requests",
"python",
"/path/to/your/orly-mcp/orly_mcp/server.py"
],
"cwd": "/path/to/your/orly-mcp"
}
}
}
重要提示:请将 /path/to/your/orly-mcp 替换为您实际的项目路径。
替代方案:包安装
# 以可编辑模式安装
uv pip install -e .
# Claude Desktop 配置
{
"mcpServers": {
"orly-local": {
"command": "uvx",
"args": ["--from", "/your/path/to/orly-mcp", "orly-mcp"]
}
}
}
故障排除
"ModuleNotFoundError: No module named 'mcp'" 错误
如果您看到此错误,说明 MCP 依赖项不可用:
cd /path/to/your/orly-mcp
uv pip install -r requirements.txt
请确保您的 Claude Desktop 配置通过 --with 标志包含所有必需的依赖项。
"ModuleNotFoundError: No module named 'fontTools'" 错误
确保所有依赖项都在您的 Claude Desktop 配置中指定:
"args": [
"run",
"--with", "fastmcp",
"--with", "pillow",
"--with", "fonttools",
"--with", "requests",
"python",
"/your/path/to/orly_mcp/server.py"
]
测试您的设置
运行综合测试以验证一切是否正常:
uv run python test_comprehensive.py
在 Claude 中使用 ORLY 工具
配置完成后,您可以要求 Claude 生成 O'RLY 书籍封面,例如:
- "Create an O'RLY book cover with the title 'Advanced Debugging' and author 'Jane Developer'"(创建一个标题为 'Advanced Debugging' 且作者为 'Jane Developer' 的 O'RLY 书籍封面)
- "Generate a book cover titled 'Machine Learning Mistakes' with subtitle 'What Could Go Wrong?' by 'AI Enthusiast'"(生成一个标题为 'Machine Learning Mistakes'、副标题为 'What Could Go Wrong?' 且作者为 'AI Enthusiast' 的书籍封面)
- "Make an O'RLY cover for 'CSS Grid Mastery' with theme 7 and image 15"(为 'CSS Grid Mastery' 创建一个主题为 7 且图片编号为 15 的 O'RLY 封面)
✨ 生成的书籍封面图像将直接显示在聊天中!
该工具支持以下参数:
- title(必需):书籍主标题
- subtitle(可选):封面顶部的文本
- author(可选):作者姓名(右下角)
- image_code(可选):动物/物体图像编号 1 - 40(未指定则随机)
- theme(可选):颜色主题编号 0 - 16(未指定则随机)
- guide_text_placement(可选):引导文本的位置 - 'top_left'、'top_right'、'bottom_left'、'bottom_right'
- guide_text(可选):自定义引导文本(默认为 "The Definitive Guide")
📄 许可证
本项目采用 MIT 许可证 - 详情请参阅 LICENSE.txt 文件。
orly_generator/ 目录中的原始 O'RLY 书籍封面生成代码基于 Charles Berlin(2016 年)的工作,同样采用 MIT 许可证 - 详情请参阅 orly_generator/LICENSE.txt 文件。
🙏 致谢
本项目基于 Charles Berlin 的优秀工作构建。orly_generator/ 目录中的核心图像生成代码改编自他的原始 O-RLY-Book-Generator 仓库,并进行了更新以支持 Python 3,同时集成到 MCP 工具中,以便与 Claude Desktop 等 MCP 客户端一起使用。
🚀 发布
(主要针对作者 Chris,因为他不常用 Python 可能会忘记这些步骤)
您可以使用 twine 快速发布新版本:
uv run twine upload dist/*
系统会提示您输入 PyPI API 令牌。
您也可以按照以下步骤操作:
# 安装开发依赖(包括 build 和 twine)
uv sync --group dev
# 构建包
uv run python -m build
# 检查构建的包
uv run twine check dist/*
# 先发布到 TestPyPI 进行测试(可选)
uv run twine upload --repository testpypi dist/*
# 发布到 PyPI
uv run twine upload dist/*
请确保:
- 更新
pyproject.toml中的版本号 - 使用
uv run python test_comprehensive.py在本地测试包 - 构建并发布
进行身份验证时,您需要在 ~/.pypirc 文件中配置 PyPI API 令牌或将其设置为环境变量。
微信扫一扫