内容
# 进行中
一个灵活的系统,用于管理各种类型的来源(论文、书籍、网页等)并将其与知识图谱集成。
## 特性
### 核心特性
- 使用内部 UUID 系统进行通用来源识别
- 支持多种来源类型(论文、网页、书籍、视频、博客)
- 每个来源支持多个标识符(arxiv、DOI、semantic scholar、ISBN、URL)
- 结构化笔记记录,包含标题和内容
- 状态跟踪(未读、阅读中、已完成、已归档)
### 实体集成
- 将来源链接到知识图谱实体
- 跟踪来源与实体之间的关系
- 灵活的关系类型(讨论、介绍、扩展等)
- 与记忆图集成
## 先决条件
该系统与 [MCP Memory Server](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) 集成,以实现持久的知识图谱存储。
## 快速开始
1. 使用我们的模式创建一个新的 SQLite 数据库:
```bash
# 创建一个新的数据库
sqlite3 sources.db < create_sources_db.sql
```
2. 安装来源管理服务器:
```bash
# 为 Claude Desktop 安装,指定你的数据库路径
fastmcp install source-manager-server.py --name "Source Manager" -e SQLITE_DB_PATH=/path/to/sources.db
```
## 模式
### 核心表
```sql
-- 来源表
CREATE TABLE sources (
id UUID PRIMARY KEY,
title TEXT NOT NULL,
type TEXT CHECK(type IN ('paper', 'webpage', 'book', 'video', 'blog')) NOT NULL,
identifiers JSONB NOT NULL,
status TEXT CHECK(status IN ('unread', 'reading', 'completed', 'archived')) DEFAULT 'unread'
);
-- 来源笔记
CREATE TABLE source_notes (
source_id UUID REFERENCES sources(id),
note_title TEXT NOT NULL,
content TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (source_id, note_title)
);
-- 实体链接
CREATE TABLE source_entity_links (
source_id UUID REFERENCES sources(id),
entity_name TEXT,
relation_type TEXT CHECK(relation_type IN ('discusses', 'introduces', 'extends', 'evaluates', 'applies', 'critiques')),
notes TEXT,
PRIMARY KEY (source_id, entity_name)
);
```
## 使用示例
### 1. 管理来源
添加一篇具有多个标识符的论文:
```python
add_source(
title="Attention Is All You Need",
type="paper",
identifier_type="arxiv",
identifier_value="1706.03762",
initial_note={
"title": "Initial thoughts",
"content": "Groundbreaking paper introducing transformers..."
}
)
# 为同一篇论文添加另一个标识符
add_identifier(
title="Attention Is All You Need",
type="paper",
current_identifier_type="arxiv",
current_identifier_value="1706.03762",
new_identifier_type="semantic_scholar",
new_identifier_value="204e3073870fae3d05bcbc2f6a8e263d9b72e776"
)
```
添加一个网页:
```python
add_source(
title="Understanding Transformers",
type="webpage",
identifier_type="url",
identifier_value="https://example.com/transformers",
)
```
### 2. 笔记记录
为来源添加笔记:
```python
add_note(
title="Attention Is All You Need",
type="paper",
identifier_type="arxiv",
identifier_value="1706.03762",
note_title="Implementation details",
note_content="The paper describes the architecture..."
)
```
### 3. 实体链接
将来源链接到实体:
```python
link_to_entity(
title="Attention Is All You Need",
type="paper",
identifier_type="arxiv",
identifier_value="1706.03762",
entity_name="transformer",
relation_type="introduces",
notes="First paper to introduce the transformer architecture"
)
```
按实体查询来源:
```python
get_entity_sources(
entity_name="transformer",
type_filter="paper",
relation_filter="discusses"
)
```
## 最佳实践
1. 来源管理
- 在引用中使用一致的标题
- 尽可能提供多个标识符
- 保持笔记结构化,标题清晰
- 使用适当的来源类型
2. 实体链接
- 对关系类型要具体
- 为关系添加上下文笔记
- 验证实体名称与记忆图一致
- 保持实体关系的专注
## 技术细节
1. 来源识别
- 内部 UUID 系统以实现一致的引用
- 每个来源支持多个外部标识符
- 灵活的标识符类型(arxiv、doi、url 等)
- 基于标题和类型的模糊匹配
2. 数据组织
- 结构化的笔记,包含标题
- 清晰的来源类型分类
- 实体关系跟踪
- 状态管理
## 贡献
1. Fork 该仓库
2. 创建一个功能分支
3. 为新功能添加测试
4. 提交拉取请求