discourse-mcp

discourse-mcp

Enables interaction with Discourse forums, especially those behind Cloudflare, using browser impersonation and rate limiting.

Category
访问服务器

README

discourse-mcp (Cloudflare-friendly fork)

Fork of the official discourse/discourse-mcp that routes Discourse API traffic through impers (curl-impersonate / curl_cffi-style TLS fingerprints).

Use this when the target forum sits behind Cloudflare (or similar) and the stock MCP gets 403 Just a moment... from Node's native fetch.

Upstream @discourse/mcp This fork
HTTP fetch impers + browser impersonate
Default fingerprint — chrome120 (override with --impersonate / profile)
CF 403 fails immediately delayed retry (same profile, backoff)
Images markdown upload:// only discourse_read_image returns MCP image content (base64) for vision models
HTTP rate limit write tools ~1/s only Optional sliding window on all HTTP (rate_limit_* profile fields)
libcurl-impersonate — impers resolve order; if missing, gh download fallback

Requires Node.js >= 24.


Install in Grok Build

1. Profile (auth)

Create ~/.grok/discourse-profile.json (example for a User API key):

{
  "site": "https://www.example.com/",
  "impersonate": "chrome120",
  "auth_pairs": [
    {
      "site": "https://www.example.com/",
      "user_api_key": "YOUR_USER_API_KEY",
      "user_api_client_id": "discourse-mcp"
    }
  ],
  "read_only": false,
  "allow_writes": true,
  "log_level": "info",
  "rate_limit_max": 15,
  "rate_limit_window_ms": 60000,
  "rate_limit_min_interval_ms": 200
}

HTTP sliding-window rate limit

Measured on uscardforum (Cloudflare / edge):

Observation Value
Burst until first 429 ~20 sequential requests
Recovery after full burst ~40s of continued 429 on probes, then OK
Sustained 1 req / 0.8–1.2s Still hits 429 after ~20 → not pure RPS
Sustained 1 rps in earlier run Can stay green for short runs, but window still caps at ~20

So the dominant pattern is ~20 requests per rolling ~60s window, not a fixed RPS ceiling. Client-side limit should be a sliding window.

Profile / CLI:

Field Meaning
rate_limit_max Max requests in the window (0 = off, default)
rate_limit_window_ms Window length (default 60000)
rate_limit_min_interval_ms Optional min gap between requests

uscardforum-safe defaults used locally: 15 / 60s + 200ms min interval (margin under the ~20 hard edge).

Cross-process / all clients: when rate limiting is enabled, timestamps are stored under a shared cache directory (not ~/.grok):

Platform Default state dir
macOS / Linux ~/.cache/discourse-mcp/rate-limit (or $XDG_CACHE_HOME/discourse-mcp/rate-limit)
Windows %LOCALAPPDATA%/discourse-mcp/rate-limit

Override with profile rate_limit_state_dir or env DISCOURSE_MCP_RATE_LIMIT_DIR.
One file per site origin (sha1(origin).json) + .lock. Multiple Grok/Claude/Cursor MCP processes share the same window. If the file lock fails, the process falls back to in-memory limiting and logs an error.

Generate a User API key (no admin required):

npx -y github:Sakura-Byte/discourse-mcp generate-user-api-key \
  --site https://www.example.com/ \
  --save-to ~/.grok/discourse-profile.json

2. ~/.grok/config.toml

[mcp_servers.discourse]
command = "npx"
args = [
  "-y",
  "github:Sakura-Byte/discourse-mcp",
  "--profile",
  "/Users/YOU/.grok/discourse-profile.json",
]
enabled = true
startup_timeout_sec = 120

First launch may download npm deps and libcurl-impersonate (or use gh if GitHub API is rate-limited). Prefer a longer startup_timeout_sec.

3. Refresh MCP

  • New Grok session, or /mcps → r refresh
  • Check: grok mcp doctor discourse

Install in other MCP clients

Claude Desktop / Cursor-style JSON

{
  "mcpServers": {
    "discourse": {
      "command": "npx",
      "args": [
        "-y",
        "github:Sakura-Byte/discourse-mcp",
        "--profile",
        "/absolute/path/to/profile.json"
      ]
    }
  }
}

Local clone

git clone https://github.com/Sakura-Byte/discourse-mcp.git
cd discourse-mcp
npm install   # runs prepare → tsc build
node dist/index.js --profile /path/to/profile.json

Grok / client:

[mcp_servers.discourse]
command = "node"
args = ["/ABS/PATH/discourse-mcp/dist/index.js", "--profile", "/path/to/profile.json"]
enabled = true
startup_timeout_sec = 60

libcurl-impersonate

Resolution order (impers native):

  1. LIBCURL_IMPERSONATE_PATH
  2. LIBCURL_PATH
  3. Common install paths
  4. GitHub download into ~/.cache/impers/libcurl-impersonate/{platform}-{arch}/
  5. System libcurl (no impersonate)

If step 4 fails (e.g. API rate limit), this fork tries gh:

Situation Behaviour
gh installed + logged in gh release download into the same cache dir
gh installed, not logged in Interactive gh auth login if TTY; else print instructions
no gh Install/login hints + manual extract path
brew install gh && gh auth login   # recommended once

Override: DISCOURSE_MCP_REQUIRE_IMPERSONATE=0 allows starting without impersonate (CF sites will usually fail).


CLI / profile flags (same as upstream + extras)

Flag / field Meaning
--profile path.json Load config from file
--site URL Tether to one site
--auth_pairs '[...]' Per-site API / User API keys
--allow_writes --read_only=false Enable write tools
--impersonate chrome120 Browser fingerprint (also in profile)
--log_level debug Verbose HTTP

Reading images (for vision models)

MCP tools should return images as Image Content blocks (not only a base64 string inside JSON text):

{
  "content": [
    { "type": "text", "text": "{...metadata...}" },
    { "type": "image", "data": "<base64>", "mimeType": "image/jpeg" }
  ]
}

Use discourse_read_image:

{ "post_id": 8564338, "max_images": 2 }
{ "url": "upload://q9cFN6AzFPTkcn4CVcNmkuXNDTi.jpeg" }
{ "url": "https://asset-cdn.example.com/.../photo.jpeg" }

Typical flow: discourse_read_post → see ![alt](upload://...) in raw → discourse_read_image with post_id or that upload:// URL.

See upstream docs for the rest of the tool list (search, read topic/post, create post/topic, drafts, …).


Upstream

Based on discourse/discourse-mcp (MIT).
Cloudflare / impers / gh bootstrap changes live in this fork only.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选