Substack MCP Server

Substack MCP Server

Enables interaction with Substack publications through natural conversation, allowing users to create posts with cover images, publish notes, manage content, and retrieve profile information.

Category
访问服务器

README

Substack MCP Server

License: MIT TypeScript

An MCP (Model Context Protocol) server that allows Claude Desktop and Claude Code to interact with your Substack publication. Create posts with cover images, publish notes, manage your content, and more - all through natural conversation with Claude.

Features

  • Post Management: Create full blog posts with cover images
  • Notes: Create short-form Substack notes
  • Profile Access: Get your own profile and other users' profiles
  • Content Retrieval: Fetch posts, notes, and comments
  • Image Upload: Native Substack image upload (v2.3.0) - no third-party dependencies
  • Draft Mode: Create drafts for review before publishing

Version 2.3.0 - What's New

This version replaces Imgur with Substack's native image upload:

  • Native Integration: Direct upload to Substack's CDN (Amazon S3)
  • Data URI Format: Images encoded as base64 data URIs
  • Automatic MIME Detection: Supports PNG, JPG, JPEG, GIF, WEBP
  • Post Association: Images properly linked to posts via postId
  • More Reliable: No third-party API dependencies

Prerequisites

  • Node.js 18+ installed on your system
  • Substack account with publication access
  • Substack API Key (connect.sid cookie value)

Getting Your Substack API Key

The Substack API uses cookie-based authentication:

  1. Login to Substack in your browser
  2. Open Developer Tools (F12 or Right-click → Inspect)
  3. Go to Application/Storage tab → Cookieshttps://substack.com
  4. Find the connect.sid cookie and copy its value
  5. This value is your SUBSTACK_API_KEY

⚠️ Important: Keep this cookie value private. Do not commit it to version control.

Cookie Extraction Tools

The tools/ directory contains utility scripts to help extract your Substack cookie:

  • extract-cookie.js - Manual cookie extraction tool
  • extract-cookie-auto.js - Automated cookie extraction

To use these tools, save your cookie value to tools/cookie.txt (this file is git-ignored for security).

Installation

Building the MCP Server

# Clone or download this repository
cd substack-mcp

# Install dependencies
npm install

# Build the TypeScript code
npm run build

For Claude Desktop

  1. Open your Claude Desktop configuration file:

    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. Add the Substack MCP server configuration:

{
  "mcpServers": {
    "substack": {
      "command": "node",
      "args": ["C:\\mcp-servers\\substack-mcp\\dist\\mcp-server.js"],
      "env": {
        "SUBSTACK_API_KEY": "your-connect-sid-cookie-value-here",
        "SUBSTACK_HOSTNAME": "yoursite.substack.com"
      }
    }
  }
}
  1. Replace your-connect-sid-cookie-value-here with your actual cookie value
  2. Replace yoursite.substack.com with your Substack hostname
  3. Restart Claude Desktop

For Claude Code

Add to your Claude Code MCP configuration or use:

claude mcp add substack-mcp

Available Tools

mcp__substack__create_post

Create a full blog post with optional cover image

Parameters:

  • title (required): Post title
  • body (required): Post content (supports markdown)
  • subtitle (optional): Post subtitle
  • cover_image (optional): Path to cover image file
  • draft (optional): Create as draft (default: true)

Example:

{
  title: "My Amazing Post",
  body: "This is the content of my post...",
  cover_image: "c:/temp/cover-image.png",
  draft: true
}

mcp__substack__create_note

Create a new Substack note (short-form post)

Parameters:

  • text (required): Note content

mcp__substack__create_note_with_link

Create a note with a link attachment

Parameters:

  • text (required): Note content
  • link (required): URL to attach

mcp__substack__get_own_profile

Get your own Substack profile information

Returns: name, slug, handle, bio, follower count, photo URL

mcp__substack__get_profile_posts

Get your recent posts

Parameters:

  • limit (optional): Number of posts to retrieve (default: 10)

mcp__substack__get_post

Get a specific post by ID with full content

Parameters:

  • post_id (required): The post ID

mcp__substack__get_post_comments

Get comments for a specific post

Parameters:

  • post_id (required): The post ID
  • limit (optional): Number of comments (default: 20)

mcp__substack__get_notes

Get your recent notes

Parameters:

  • limit (optional): Number of notes (default: 10)

Usage Examples

With Claude Desktop/Code

Once configured, you can have natural conversations with Claude:

"Create a new blog post titled 'Why I Love Programming' with this content..."

"Create a draft post with the article from article.md and use cover.png as the cover image"

"Get my recent posts from the last week"

"Create a note saying 'New post just published!'"

Claude will automatically use the appropriate MCP tools to fulfill your requests.

Environment Variables

  • SUBSTACK_API_KEY (required): Your connect.sid cookie value
  • SUBSTACK_HOSTNAME (required): Your Substack hostname (e.g., "yourname.substack.com")

Workflow Example

Here's a typical workflow for creating a post with cover image:

  1. Write your article in markdown format
  2. Create or generate a cover image
  3. Tell Claude: "Create a draft post with article.md and cover.png"
  4. Claude will:
    • Read the markdown file
    • Upload the cover image to Substack's CDN
    • Create the draft post with both
    • Return the draft URL for review

Documentation

  • CLAUDE.md - Development guidelines for Claude Code

Troubleshooting

"SUBSTACK_API_KEY environment variable is required"

Make sure you've added the SUBSTACK_API_KEY to the env section of your MCP configuration.

"Failed to connect"

  1. Verify your connect.sid cookie value is correct and hasn't expired
  2. Check that you're logged into Substack in your browser
  3. Try getting a fresh cookie value by logging out and back in

MCP server not appearing in Claude Desktop

  1. Check that the path to mcp-server.js is correct
  2. Ensure Node.js 18+ is installed: node --version
  3. Run npm run build to compile the TypeScript
  4. Restart Claude Desktop after configuration changes

Image upload fails

  1. Ensure the image file exists and is readable
  2. Check that the file format is supported (PNG, JPG, JPEG, GIF, WEBP)
  3. Verify your Substack API key is valid

Development

To extend the MCP server:

  1. Edit src/mcp-server.ts to add new tools
  2. Run npm run build to compile TypeScript
  3. Restart Claude Desktop/Code to load changes

Testing

npm test              # Run all tests
npm run test:unit     # Unit tests only
npm run lint          # Check code style
npm run format        # Format code

Security Notes

  • Never commit your connect.sid cookie value to version control
  • Store your API key securely using environment variables
  • The cookie value gives full access to your Substack account
  • Regularly refresh your cookie value for security

Version History

  • v2.3.0 (Nov 2025): Native Substack image upload, replaces Imgur
  • v2.2.0: Added Imgur-based cover image upload
  • v2.1.0: Added create_post tool with ProseMirror support
  • v2.0.0: Initial MCP server implementation

License

MIT - See LICENSE file for details

Credits

Built on top of the substack-api TypeScript client.

MCP server and image upload implementation by Daniel Simon Jr.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选