Official Substack MCP Server

Integrations

  • Retrieves and caches blog posts from Medium, enabling semantic search across content and reference to individual essays

  • Uses RSS feeds to retrieve content from Substack and Medium blogs

  • Fetches and caches blog posts from Substack, making them available for semantic search and analysis

克劳德的作家语境工具

开源模型上下文协议 (MCP) 实现将 Claude 连接到您的 Substack 和 Medium 写作。

这是什么?

Writer Context Tool 是一个 MCP 服务器,允许 Claude 访问和分析您在 Substack 和 Medium 等平台上的写作。借助此工具,Claude 可以了解您发布内容的背景,从而为您的写作提供更个性化的帮助。

特征

  • 🔍 从 Substack 和 Medium 检索并永久缓存您的博客文章
  • 🔎 使用嵌入根据您的查询查找最相关的文章
  • 📚 将个人论文作为单独的资源提供给 Claude
  • 🧠 对您的写作进行语义搜索
  • ⚡ 在启动时预加载所有内容并生成嵌入

工作原理

该工具通过 RSS 源连接到您的 Substack/Medium 博客,获取您的帖子并将其永久缓存在本地。它还会为每篇帖子生成嵌入,从而支持语义搜索根据您的查询找到最相关的文章。

当您向克劳德询问您的写作情况时,它可以使用这些单独的文章资源来提供见解或帮助您根据现有内容开发新的想法。

设置说明(分步说明)

先决条件

  • Python 3.10 或更高版本
  • Claude 桌面(最新版本)
  • 已发布内容的 Substack 或 Medium 帐户

1. 克隆此存储库

git clone https://github.com/yourusername/writer-context-tool.git cd writer-context-tool

2. 设置 Python 环境

使用 uv(推荐):

# Install uv if you don't have it curl -LsSf https://astral.sh/uv/install.sh | sh # Create virtual environment and install dependencies uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate uv pip install -r requirements.txt

或者使用标准 pip:

python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -r requirements.txt

3. 配置您的博客

  1. 复制示例配置文件:
    cp config.example.json config.json
  2. 使用您的 Substack/Medium URL 编辑config.json
    { "platforms": [ { "type": "substack", "url": "https://yourusername.substack.com", "name": "My Substack Blog" }, { "type": "medium", "url": "https://medium.com/@yourusername", "name": "My Medium Blog" } ], "max_posts": 100, "cache_duration_minutes": 10080, "similar_posts_count": 10 }
    • max_posts :从每个平台获取的最大帖子数(默认值:100)
    • cache_duration_minutes :刷新前缓存内容的时间(默认值:1 周或 10080 分钟)
    • similar_posts_count :搜索时返回的最相关帖子数量(默认值:10)

4. 连接 Claude Desktop

  1. 创建 Claude Desktop 配置目录:
    # On macOS mkdir -p ~/Library/Application\ Support/Claude/
  2. 创建配置文件:
    # Get the absolute path to your uv command UV_PATH=$(which uv) # Create the configuration cat > ~/Library/Application\ Support/Claude/claude_desktop_config.json << EOF { "mcpServers": { "writer-tool": { "command": "${UV_PATH}", "args": [ "--directory", "$(pwd)", "run", "writer_tool.py" ] } } } EOF

    **注意:**如果您在使用uv命令时遇到问题,您可以使用附带的 shell 脚本替代方法:

    1. 使脚本可执行: chmod +x run_writer_tool.sh
    2. 更新您的 Claude Desktop 配置以使用脚本:
    { "mcpServers": { "writer-tool": { "command": "/absolute/path/to/run_writer_tool.sh", "args": [] } } }
  3. 重启Claude桌面

与 Claude 一起使用工具

设置完成后,您将在 Claude Desktop 中看到可作为资源使用的单篇论文。您可以:

  1. 搜索你的写作:请克劳德找到相关内容
    • “查找我讨论[特定主题]的文章”
    • “我写了哪些关于[主题]的内容?”
  2. 参考特定论文:在搜索结果中列出时,通过点击访问个别论文
    • “显示[文章标题]的全文”
  3. 刷新内容:强制刷新您的内容
    • “刷新我的写作内容”

可用的工具和资源

Writer Context Tool 提供:

  1. 个人论文资源:你的每篇论文都成为可选资源
  2. search_writing :一种语义搜索工具,使用嵌入查找最相关的文章
  3. refresh_content :刷新并重新缓存所有已配置平台的内容

缓存的工作原理

该工具通过以下功能实现永久缓存:

  1. 磁盘缓存:所有内容都存储在磁盘上,因此在会话之间仍然存在
  2. 嵌入:每篇文章都转换为嵌入,以进行语义搜索
  3. 选择性刷新:该工具仅根据您的缓存设置,在需要时刷新内容
  4. 预加载:所有内容都会自动刷新,并在启动时生成嵌入

故障排除

如果您遇到问题:

  1. 工具没有出现在 Claude Desktop 中:
    • 检查你的 Claude Desktop 配置文件是否正确
    • 验证配置中的所有路径都是绝对路径
    • 确保您的 Python 环境具有所有必需的包
    • 重启Claude桌面
  2. 没有出现任何内容:
    • 在 config.json 中验证你的 Substack/Medium URL
    • 尝试使用“refresh_content”工具
    • 检查你的博客是否公开且已发布帖子
  3. uv 命令错误:
    • 尝试使用 shell 脚本方法
    • 验证 uv 命令是否已安装并位于您的 PATH 中
  4. 嵌入问题:
    • 如果您看到有关嵌入模型的错误,请确保您有足够的磁盘空间
    • 如果嵌入无法正常工作,请考虑重新运行全新安装

执照

该项目可在 MIT 许可下使用。

ID: oqh0j6n6w3