知识管理服务器

一个为Obsidian Second Brain提供智能知识管理的MCP服务器,具有自动标签、内容分析和语义搜索功能。

  • by jonhill90
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 jonhill90/Notebook-MCP

使用说明

个人笔记本MCP服务器

一个定制的模型上下文协议(MCP)服务器,为第二脑黑曜石库提供智能知识管理,并自动执行约定。

概述

此MCP服务器用一种专门的解决方案替换了基本内存,该解决方案:

  • 强制执行第二大脑惯例(14个字符ID、文件夹结构、前体格式)
  • 提供基于内容分析的自动标记
  • 当标签簇达到阈值时自动生成MOC
  • 整合向量搜索以发现语义知识
  • 使用智能路由处理收件箱项目

特性

第一阶段MVP

  • 公约执行:YYYYMMDDHHmmss ID,00-05文件夹结构,小写连字符标签
  • 保险库管理:带验证的CRUD操作
  • 自动标记:使用现有词汇表的基于内容的标签建议
  • 汽车MOC生成:当标签簇超过阈值时,自动创建内容映射
  • 矢量搜索:通过Qdrant进行语义搜索集成
  • 收件箱处理:收件箱项目的智能路由和标签建议

建筑

notebook-mcp/
├── src/
│   ├── server.py              # MCP server implementation
│   ├── models.py              # Pydantic models (NoteFrontmatter, etc.)
│   ├── vault/
│   │   ├── manager.py         # CRUD with convention enforcement
│   │   ├── tag_analyzer.py    # Auto-tagging logic
│   │   └── moc_generator.py   # MOC creation
│   ├── inbox/
│   │   ├── processor.py       # Inbox automation
│   │   └── router.py          # Smart routing logic
│   └── vector/
│       └── qdrant_client.py   # Vector storage/search
├── tests/                     # Unit and integration tests
├── config/                    # Configuration files
└── docker-compose.yml         # Docker services

需求

  • Python 3.12+
  • Docker&Docker编写
  • OpenAI API密钥(用于嵌入)
  • 第二脑黑曜石拱顶

安装

  1. 克隆存储库

  2. 复制 .env.example 到 .env 并配置:

    cp .env.example .env
    # Edit .env with your configuration
    
  3. 安装依赖项:

    pip install -e .
    
  4. 启动服务:

    docker-compose up -d
    

配置

环境变量

  • VAULT_PATH:第二大脑保险库的路径(默认值: ./repos/Second Brain)
  • QDRANT_URL:Qdrant服务URL(默认值: http://localhost:6333)
  • OPENAI_API_KEY:用于嵌入的OpenAI API密钥
  • MCP_PORT:MCP服务器端口(默认值: 8053)
  • LOG_LEVEL:日志记录级别(默认值: INFO)

第二大脑惯例

此服务器强制执行以下约定:

文件ID

  • 格式: YYYYMMDDHHmmss (14个字符)
  • 例子: 20251114020000

文件夹结构

  • 00 - Inbox:临时存储、处理队列
  • 01 - Notes:永久性注释、参考文献
  • 02 - MOCs:内容地图(主题聚合)
  • 03 - Projects:正在进行的项目
  • 04 - Areas:正在进行的责任领域
  • 05 - Resources:参考资料、剪报

前言

必填字段:

id: "20251114020000"
type: "note"
tags: ["knowledge-management", "automation"]
created: "2025-11-14T02:00:00"
updated: "2025-11-14T02:00:00"
permalink: "my-note-title"

标签

  • 格式:小写连字符
  • 有效期: knowledge-management, python-programming
  • 无效: Knowledge Management, Python_Programming

MCP工具

核心工具

  • write_note:使用惯例验证创建注释
  • read_note:按ID或永久链接阅读笔记
  • search_knowledge_base:基于向量的语义搜索
  • process_inbox_item:路由和标记收件箱项目
  • create_moc:为标签集群生成MOC
  • list_tags:获取现有标签词汇表
  • suggest_tags:获取内容的标签建议

发展

运行测试

# All tests with coverage
pytest --cov=src --cov-report=term-missing

# Unit tests only
pytest tests/unit/

# Integration tests
pytest tests/integration/

代码质量

# Linting
ruff check src/ tests/

# Type checking
mypy src/

# Format code
ruff format src/ tests/

部署

Docker Compose

docker-compose up --build -d

Claude桌面集成

增添 ~/.config/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "second-brain": {
      "command": "npx",
      "args": ["mcp-remote", "http://localhost:8053/mcp"]
    }
  }
}

成功标准

  • 创建了零个断开的链接
  • 100%前端验证合规性
  • 80%的自动标记准确率

  • 90%收件箱处理路由准确率

  • 85%的矢量搜索精度

  • MOC生成阈值(12+个音符)

许可证

私人项目-保留所有权利

参考文献

  • PRP: prps/INITIAL_personal_notebook_mcp.md
  • 基本存储器:参考MCP实施
  • RAG服务:矢量搜索基础设施
  • 第二大脑:黑曜石拱顶惯例