article
README
id: abc123-def456 title: "Code Review Discussion" created_at: 2024-01-15T10:00:00.000Z source_app: Claude tags: ["code-review", "python"]
Code Review Discussion
A discussion about Python best practices
Conversation
User (1/15/2024, 10:00:00 AM)
Can you review this Python function?
Assistant (1/15/2024, 10:00:05 AM)
Sure! Here are my suggestions...
#### JSON
生成结构化的 JSON 文件:
```json
{
"id": "abc123-def456",
"metadata": {
"title": "Code Review Discussion",
"sourceApp": "Claude",
"createdAt": "2024-01-15T10:00:00.000Z",
"tags": ["code-review", "python"]
},
"messages": [
{
"role": "user",
"content": "Can you review this Python function?",
"timestamp": "2024-01-15T10:00:00.000Z"
}
]
}
远程服务器 API
使用远程存储时,服务器应实现以下端点:
POST /conversations
创建新对话。
请求体:
{
"id": "string",
"title": "string",
"content": "string (formatted content)",
"format": "markdown | json",
"metadata": { ... }
}
响应:
{
"url": "https://your-server.com/conversations/id"
}
GET /conversations
列出所有对话。
GET /conversations/:id
获取特定对话。
PUT /conversations/:id
更新对话(用于 update_thread)。
DELETE /conversations/:id
删除对话。
🔧 技术细节
开发
先决条件
- Node.js 22+
- npm
安装依赖
npm install
构建项目
npm run build
运行测试
npm test # 运行所有测试
npm run test:watch # 监听模式
npm run test:coverage # 生成覆盖率报告
开发服务器
npm run dev
代码检查与格式化
npm run lint # ESLint 检查
npm run format # Prettier 格式化
npm run format:check # 检查格式化
npm run typecheck # TypeScript 类型检查
项目结构
thread-mcp/
├── src/
│ ├── index.ts # 入口文件
│ ├── server.ts # MCP 服务器设置
│ ├── types.ts # TypeScript 类型和 Zod 模式
│ ├── tools/ # MCP 工具实现
│ │ ├── save-thread.ts # 保存新线程
│ │ ├── find-threads.ts # 搜索/列出/获取线程
│ │ ├── update-thread.ts # 更新现有线程
│ │ ├── delete-thread.ts # 删除线程
│ │ └── resume-thread.ts # 加载线程以继续对话
│ ├── formatters/ # 输出格式化器
│ │ ├── markdown.ts
│ │ └── json.ts
│ └── storage/ # 存储提供程序
│ ├── local.ts
│ └── remote.ts
├── tests/
│ ├── unit/ # 单元测试
│ └── e2e/ # 端到端测试
├── package.json
├── tsconfig.json
└── vitest.config.ts
Scan to join WeChat group