chatgpt2md
把你的ChatGPT历史记录带到克劳德那里。包括全文搜索。
一个快速的CLI工具,可以将您的ChatGPT导出转换为有组织的Markdown文件,构建搜索索引,并提供MCP服务器,以便Claude可以本地搜索和读取您的对话历史记录。
主要特点:
- 将ChatGPT导出(ZIP或JSON)转换为干净的Markdown文件
- 内置全文搜索,由 坦提维
- MCP服务器,配备3个用于Claude集成的工具
- Claude Desktop和Claude Code的一个命令自动安装
- 适用于macOS和Windows
- 单一二进制文件,无运行时依赖关系
目录
快速开始
# Install
cargo install --git https://github.com/NextStat/chatgpt2md
# Convert your ChatGPT export
chatgpt2md export.zip
# Install MCP into Claude (auto-configures everything)
chatgpt2md install --index ./chatgpt_chats/.index --chats ./chatgpt_chats
# Restart Claude — done!步骤1:导出您的ChatGPT数据
- 首选 chatgpt.com
- 单击您的个人资料图标(左下角)> 设置
- 首选 数据控件
- 点击 导出数据 > 确认导出
- 等待OpenAI的电子邮件(通常在几分钟内到达)
- 从电子邮件中的链接下载ZIP文件
ZIP文件包含 conversations.json 您所有的聊天记录。
提示: 导出包括您的所有对话——如果您有数千个聊天记录,这可能需要一段时间。
步骤2:安装chatgpt2md
选项A:预构建二进制文件(推荐)
从以下网址下载适用于您平台的最新版本 发布页面:
| 平台 | 文件 |
|---|---|
| macOS(苹果硅) | chatgpt2md-aarch64-apple-darwin.tar.gz |
| macOS(英特尔) | chatgpt2md-x86_64-apple-darwin.tar.gz |
| 窗户 | chatgpt2md-x86_64-pc-windows-msvc.zip |
| Linux | chatgpt2md-x86_64-unknown-linux-gnu.tar.gz |
# macOS / Linux: extract and move to PATH
tar xzf chatgpt2md-*.tar.gz
sudo mv chatgpt2md /usr/local/bin/选项B:从源代码安装
需要 锈 1.85+:
cargo install --git https://github.com/NextStat/chatgpt2md选项C:在本地构建
git clone https://github.com/NextStat/chatgpt2md
cd chatgpt2md
cargo build --release
# Binary is at ./target/release/chatgpt2md步骤3:转换导出
# Basic usage — just pass the ZIP file
chatgpt2md export.zip这将:
- 提取
conversations.json从ZIP - 将每个对话转换为
.md文件 - 按年/月文件夹组织文件
- 构建全文搜索索引
输出转到 ./chatgpt_chats/ 默认情况下。您可以更改此设置:
# Custom output directory
chatgpt2md export.zip -o ~/Documents/my_chatgpt_history
# Flat structure (no year/month folders)
chatgpt2md export.zip --flat
# Include system/tool messages
chatgpt2md export.zip --include-system
# Skip search index (just convert to Markdown)
chatgpt2md export.zip --no-index预期产量:
Found 1847 conversations. Converting to Markdown...
████████████████████████████████████████ 1847/1847
Done!
Conversations converted: 1823
Conversations skipped (empty): 24
Total messages: 41562
Output directory: chatgpt_chats
Building search index...
Indexed 1823 conversations in chatgpt_chats/.index第四步:联系克劳德
自动(推荐)
chatgpt2md install --index ./chatgpt_chats/.index --chats ./chatgpt_chats这配置了两者 克劳德桌面版 和 克劳德代码 自动。
在运行安装之后, 重新启动克劳德桌面 以使更改生效。
选项:
# Only Claude Desktop
chatgpt2md install --index ./chatgpt_chats/.index --chats ./chatgpt_chats --desktop-only
# Only Claude Code
chatgpt2md install --index ./chatgpt_chats/.index --chats ./chatgpt_chats --code-only手动设置
看 手动MCP配置 如果您更喜欢手动配置,请参阅下面。
第五步:使用它!
连接后,您可以问Claude以下问题:
- *“搜索我的ChatGPT历史记录,了解有关Rust async的讨论”*
- *“查找我2024年以来关于机器学习的所有对话”*
- *“给我看看我的关于意大利面食谱的聊天”*
- *“我在2025年1月讨论了Docker什么?”*
- *“列出2024年3月以来的所有对话”*
Claude将自动使用MCP工具:
| 工具 | 它做什么 |
|---|---|
search_conversations | 按关键字对所有对话进行全文搜索 |
get_conversation | 阅读特定对话的完整文本 |
list_conversations | 按年份和/或月份浏览对话 |
Claude中的示例会话
你: 搜索我的ChatGPT历史记录,了解有关React性能优化的任何信息 克劳德: *(使用search_conversations)* 我找到了三个相关的对话: 1. React性能深度学习 (2024-09-15)-24条消息 1. 优化重新渲染 (2024-07-03)--18条消息 1. 虚拟DOM与信号 (2025-01-12)--32条消息 你想让我把这些全部读一遍吗? 你: 是的,给我看第一个 克劳德: *(使用get_versation)* 以下是完整的对话。..
命令参考
convert (默认)
将ChatGPT导出转换为Markdown文件。这是默认命令,您可以省略 convert.
chatgpt2md [convert] [OPTIONS]
Arguments:
Path to .zip export or conversations.json
Options:
-o, --output Output directory [default: chatgpt_chats]
--flat No year/month subdirectories
--include-system Include system/tool messages
--no-index Skip building search indexserve
启动MCP服务器(stdio传输)。这是Claude自动调用的,您不需要手动运行它。
chatgpt2md serve --index
--chats
install
自动配置克劳德桌面和/或克劳德代码。
chatgpt2md install --index
--chats
[--desktop-only] [--code-only]手动MCP配置
克劳德桌面版
编辑配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 窗户:
%APPDATA%\Claude\claude_desktop_config.json
添加 chatgpt-history 服务器:
{
"mcpServers": {
"chatgpt-history": {
"command": "/path/to/chatgpt2md",
"args": ["serve", "--index", "/path/to/chatgpt_chats/.index", "--chats", "/path/to/chatgpt_chats"]
}
}
}替换 /path/to/ 具有实际的绝对路径。
克劳德代码
claude mcp add --transport stdio --scope user chatgpt-history -- \
/path/to/chatgpt2md serve \
--index /path/to/chatgpt_chats/.index \
--chats /path/to/chatgpt_chats输出结构
chatgpt_chats/
├── .index/ # Tantivy search index (used by MCP server)
├── 2024/
│ ├── 01/
│ │ ├── 2024-01-15_My_first_chat.md
│ │ └── 2024-01-20_Debugging_Rust.md
│ ├── 02/
│ │ └── ...
│ └── 12/
│ └── ...
├── 2025/
│ └── ...
└── undated/
└── Untitled_conversation.md每 .md 文件有YAML frontmatter:
---
title: "My first chat"
source: chatgpt
created: 2024-01-15 10:30:00 UTC
updated: 2024-01-15 11:45:00 UTC
message_count: 12
---这些文件与Obsidian、VS Code或任何Markdown查看器配合使用都很好。
从源头构建
需要 锈 1.85或更高。
git clone https://github.com/NextStat/chatgpt2md
cd chatgpt2md
cargo build --release二进制文件将位于 ./target/release/chatgpt2md (6-7mb)。
许可证
麻省理工学院
