📚 绅士书MCP服务器
Give AI assistants direct access to the Gentleman Programming Book
Features • Installation • Configuration • Usage • Español
______________________________________________________________________
这是什么?
这是一个 MCP(模型上下文协议)服务器 它允许像克劳德这样的人工智能助手阅读、搜索和理解来自 绅士编程书.
可以把它看作是让你的人工智能助手直接了解18章的软件架构知识、最佳实践和开发智慧。
特性
🔧 第一级:基本工具
| 工具 | 说明 |
|---|---|
list_chapters | 列出所有18章及其元数据 |
read_chapter | 阅读任何章节或特定部分 |
search_book | 所有内容的基于关键字的搜索 |
get_book_index | 完整目录 |
📦 第二级:资源和提示
| 类型 | 名称 | 描述 |
|---|---|---|
| 资源 | book://index/es | 西班牙语目录 |
| 资源 | book://index/en | 英文目录 |
| 提示 | explain_concept | 解释书中的任何概念 |
| 提示 | compare_patterns | 比较架构模式 |
| 提示 | summarize_chapter | 获取章节摘要 |
🧠 第三级:语义搜索(人工智能驱动)
| 工具 | 说明 |
|---|---|
semantic_search | 使用嵌入的自然语言搜索 |
build_semantic_index | 构建向量索引 |
semantic_status | 检查语义引擎状态 |
同时支持OpenAI和Olama 用于嵌入生成。
安装
先决条件
- 达到1.21或更高
- 这 绅士编程书 本地克隆
从源代码构建
# Clone this repository
git clone https://github.com/Alan-TheGentleman/gentleman-book-mcp.git
cd gentleman-book-mcp
# Build the binary
go build -o bin/gentleman-book-mcp ./cmd/server
# The binary is now at ./bin/gentleman-book-mcp验证安装
./bin/gentleman-book-mcp --help配置
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
BOOK_PATH | 预订MDX文件的路径 | ~/work/gentleman-programming-book/src/data/book |
OPENAI_API_KEY | OpenAI API密钥(用于语义搜索) | - |
OLLAMA_BASE_URL | Ollama服务器URL | http://localhost:11434 |
OLLAMA_EMBEDDING_MODEL | Ollama嵌入模型 | nomic-embed-text |
Claude桌面设置
添加 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"gentleman-book": {
"command": "/absolute/path/to/gentleman-book-mcp",
"env": {
"BOOK_PATH": "/path/to/gentleman-programming-book/src/data/book"
}
}
}
}使用OpenAI(用于语义搜索)
{
"mcpServers": {
"gentleman-book": {
"command": "/absolute/path/to/gentleman-book-mcp",
"env": {
"BOOK_PATH": "/path/to/gentleman-programming-book/src/data/book",
"OPENAI_API_KEY": "sk-..."
}
}
}
}与Ollama(免费,本地)
- 安装 奥拉玛
- 拉动嵌入模型:
ollama pull nomic-embed-text - 启动Ollama:
ollama serve - 使用标准配置(Ollama自动检测)
用法
配置后,重新启动Claude Desktop并开始聊天!
示例对话
列出章节:
You: What chapters are in the Gentleman Programming Book?
Claude: [Uses list_chapters] The book has 18 chapters covering...阅读具体内容:
You: Read me the chapter about hexagonal architecture
Claude: [Uses read_chapter] Here's the hexagonal architecture chapter...搜索主题:
You: Find information about TDD in the book
Claude: [Uses search_book] I found several mentions of TDD...语义搜索(如果已配置):
You: How should I structure a React application for maintainability?
Claude: [Uses semantic_search] Based on the book's recommendations...使用提示:
You: Explain clean architecture according to the book
Claude: [Uses explain_concept prompt] According to the Gentleman Programming Book...书籍内容
服务器提供访问 18章 英语和西班牙语:
| # | 章节 | 主题 |
|---|---|---|
| 1 | 清洁敏捷 | 敏捷、瀑布式、XP、TDD |
| 2 | 沟通 | 远程工作,团队动态 |
| 3 | 六边形架构 | 端口、适配器、域 |
| 4 | GoLang | Go基础 |
| 5 | NVIM指南 | Neovim设置和使用 |
| 6 | 算法 | 大O,搜索,排序 |
| 7 | 干净的架构 | 层、用例、领域 |
| 8 | 清洁架构前端 | 范围规则、前端模式 |
| 9 | 反应 | 钩子、状态、组合 |
| 10 | TypeScript | 类型、接口、模式 |
| 11 | 前端雷达 | 框架比较 |
| 12 | Angular | 组件、服务、测试 |
| 13 | 桶 | 模块组织 |
| 14 | 前端历史 | 网络发展 |
| 15 | 人工智能驱动开发 | 克劳德代码,人工智能工作流程 |
| 16 | 前端手册 | 测试、安全、性能 |
| 17 | 软技能 | 领导力、沟通 |
| 18 | 软件架构 | 微服务,模式 |
建筑
gentleman-book-mcp/
├── cmd/
│ └── server/
│ └── main.go # MCP server entry point
├── internal/
│ ├── book/
│ │ ├── models.go # Data structures
│ │ └── parser.go # MDX file parser
│ └── embeddings/
│ └── embeddings.go # Semantic search engine
├── go.mod
├── go.sum
├── README.md # English documentation
└── README.es.md # Spanish documentation发展
# Run in development mode
go run ./cmd/server
# Build
go build -o bin/gentleman-book-mcp ./cmd/server
# Test with MCP Inspector
npx @anthropic-ai/mcp-inspector ./bin/gentleman-book-mcp故障排除
“书本路径不存在”
确保 BOOK_PATH 环境变量指向书籍MDX文件的正确位置。
“语义搜索不可用”
任一组 OPENAI_API_KEY 或者确保Ollama在安装嵌入式模型的情况下运行。
服务器未响应
检查二进制文件是否具有执行权限: chmod +x ./bin/gentleman-book-mcp
贡献
欢迎投稿!请随意:
- 报告错误
- 建议新功能
- 提交拉取请求
许可证
MIT许可证-请参阅 许可证 了解详情。
相关项目
______________________________________________________________________
Made with ❤️ by Gentleman Programming
