书签Geni MCP服务器
独立的MCP(模型上下文协议)服务器,用于处理本地浏览器书签,并使用自然语言轻松搜索url/书签。
连接到Claud桌面或Gemini CLI
特性
- 🔍 多浏览器支持:从Chrome、Edge、Firefox、Opera、ChatGPT Atlas和困惑彗星读取书签
- 📄 内容提取:从URL中获取HTML内容并提取文本进行语义搜索
- 🏷️ 元数据抽取:从HTML元数据标签(Open Graph、元描述、标题)中提取描述
- 📊 向量存储:使用句子转换器模型(全MiniLM-L6-v2)在ChromaDB中存储书签嵌入
- 🔎 RAG搜索:使用带有元数据过滤的自然语言查询书签
- 📦 可移植性:将嵌入导出到pickle文件或从pickle文件导入嵌入,以便于传输
- ⚡ 演出:具有并发性和缓存的批处理
安装
- 安装依赖项:
pip install -r requirements.txt- 通过编辑配置服务器
config.yaml(可选-提供默认值)
- 使启动脚本可执行:
chmod +x scripts/start_mcp_server.sh用法
服务器启动后,可以与任何MCP客户端一起使用。 要为所有浏览器书签建立索引并生成元数据,请运行以下命令:
"Generate metadata for chrome bookmarks"索引所有书签后,您可以使用以下命令查询它们:
"Query bookmarks for 'python'"独立MCP服务器
通过引用,服务器可以与任何MCP客户端独立使用 mcp.json:
# Start the server using the bash script
./scripts/start_mcp_server.sh使用Gemini CLI
使用以下命令将服务器连接到Gemini CLI:
# Add the server configuration to your Gemini CLI settings
# Edit ~/.gemini/settings.json and add the following to the "mcpServers" section:
{
"mcpServers": {
"bookmarkGeni": {
"command": "bash",
"args": ["/path/to/bookmark_geni_mcp/scripts/start_mcp_server.sh"],
"env": {
"PYTHON_PATH": "/path/to/your/python3"
}
}
}
}
# Or use the provided mcp.json as a reference for the configuration配备Calude桌面
通过在Calude Desktop设置中添加以下内容,将服务器连接到Calude桌面:
{
"mcpServers": {
"bookmarkGeni": {
"command": "bash",
"args": ["/path/to/bookmark_geni_mcp/scripts/start_mcp_server.sh"],
"env": {
"PYTHON_PATH": "/usr/bin/python3"
}
}
}
}备注:替换 /path/to/bookmark_geni_mcp 具有此存储库的实际路径,以及 /path/to/your/python3 使用Python解释器路径。
配置
服务器从以下位置读取配置 config.yaml 在MCP服务器根目录中。这包括:
- 浏览器启用/禁用设置
- ChromaDB路径(相对于MCP服务器根或绝对路径)
- 元数据JSONL路径(相对于MCP服务器根或绝对路径)
- URL处理限制(默认值:-1,表示处理所有URL)
- 调试模式
示例 config.yaml:
debug: false
browsers:
Chrome:
enabled: true
Edge:
enabled: true
# Optional: Override default path detection
# paths:
# - "/path/to/custom/Bookmarks"
chromaDbPath: ".chromadb"
metadataJsonlPath: "data/bookmarks_metadata.jsonl"
urlLimit: -1 # -1 means process all, set to positive number to limit服务器现在完全独立,不需要Gemini CLI扩展文件夹。
浏览器支持
服务器支持以下浏览器:
- 铬:Windows、macOS、Linux
- 边缘:Windows、macOS、Linux
- 火狐:Windows、macOS、Linux
- 歌剧:Windows、macOS、Linux
- ChatGPT图谱:macOS(基于Chromium)
- 困惑彗星:Windows、macOS、Linux(基于Chromium)
备注:不支持Safari,因为阅读 Bookmarks.plist 需要默认情况下未授予的特殊macOS权限。要使用Safari书签,您需要向Python解释器授予全磁盘访问权限,出于安全原因,不建议这样做。
工具
服务器提供以下MCP工具:
generate_bookmarks_metadata
- 扫描选定浏览器中的书签 - 获取HTML内容并生成元数据 - 创建嵌入并将其存储在ChromaDB中 - 参数: browsers (例如,“Chrome、Safari”或“全部”)
query_bookmarks
- 对存储的书签执行语义搜索 - 支持元数据过滤 - 参数: - query:搜索文本 - limit:最大结果(默认值10) - where:过滤字典(例如。, {"folder": "Work"})
list_browsers
- 列出已安装的浏览器及其检测到的书签文件路径 - 参数:无
get_stats
- 返回数据库统计信息(总计数、收集信息) - 参数:无
export_embeddings
- 将所有数据导出到pickle文件进行备份或传输 - 参数: pickle_path (可选)
import_embeddings
- 从pickle文件导入数据 - 参数: pickle_path (必填)
看 mcp.json 有关详细的模式定义。
工作流程
flowchart TD
%% Nodes
User([User / CLI])
Server[MCP Server]
Detector[Browser Detector]
Parser[Bookmark Parser]
Generator[Metadata Generator]
URLTracker[URL Tracker]
VectorStore[Bookmark Vector Store]
SearchModule[Semantic Search Module]
ChromaDB[(ChromaDB)]
JSONL[(JSONL Storage)]
%% Flow
User -->|generate| Server
Server -->|Get Paths| Detector
Detector -->|Browser Paths| Server
subgraph Processing [Processing Loop]
direction TB
Server -->|Parse File| Parser
Parser -->|Raw Bookmarks| Server
Server -->|Check Processed| URLTracker
URLTracker -->|Filter New| Server
Server -->|Batch Process| Generator
Generator -->|Fetch HTML| Generator
Generator -->|Extract Metadata| Generator
Generator -->|Enriched Bookmarks| Server
Server -->|Store| VectorStore
VectorStore -->|Generate Embeddings| SearchModule
SearchModule -->|Store Vectors| ChromaDB
Server -->|Write Metadata| JSONL
Server -->|Track URLs| URLTracker
end
Server -->|JSON Result| User
User -->|query| Server
Server -->|Search| VectorStore
VectorStore -->|Semantic Search| SearchModule
SearchModule -->|Query Vectors| ChromaDB
ChromaDB -->|Results| SearchModule
SearchModule -->|Ranked Results| VectorStore
VectorStore -->|Bookmarks| Server
Server -->|JSON Results| User
%% Styling
style User fill:#ff9999,stroke:#333,stroke-width:2px
style Server fill:#99ccff,stroke:#333,stroke-width:2px
style Detector fill:#99ff99,stroke:#333,stroke-width:2px
style Parser fill:#ffff99,stroke:#333,stroke-width:2px
style Generator fill:#ffcc99,stroke:#333,stroke-width:2px
style VectorStore fill:#cc99ff,stroke:#333,stroke-width:2px
style SearchModule fill:#ff99cc,stroke:#333,stroke-width:2px
style URLTracker fill:#99ffcc,stroke:#333,stroke-width:2px
style ChromaDB fill:#9999ff,stroke:#333,stroke-width:2px
style JSONL fill:#cccc99,stroke:#333,stroke-width:2px
style Processing fill:#f9f9f9,stroke:#666,stroke-dasharray: 5 5结构
bookmark_geni_mcp/
├── config.yaml # Server configuration file
├── mcp.json # MCP server configuration
├── pyproject.toml # Project configuration
├── requirements.txt # Python dependencies
├── servers/
│ └── bookmark_server.py # MCP server implementation
├── scripts/
│ └── start_mcp_server.sh # Bash start script
└── src/
├── browser_detector.py # Browser path detection
├── bookmark_parser.py # Bookmark file parsing
├── metadata_generator.py # HTML content and metadata extraction
├── bookmark_vector_store.py # Bookmark-specific vector store wrapper
├── metadata_storage.py # JSONL file storage
├── config.py # Configuration management
└── search/ # Semantic search module
├── __init__.py
├── semantic_search.py
├── vector_store.py
├── embeddings.py
└── config.py