Discourse MCP

Discourse MCP

Enables AI agents to interact with Discourse forums through search, reading topics/posts, browsing categories and tags, and creating posts. Supports both read-only public access and authenticated operations with configurable write permissions.

Category
访问服务器

README

Discourse MCP

A Model Context Protocol (MCP) stdio server that exposes Discourse forum capabilities as tools for AI agents.

  • Entry point: src/index.ts → compiled to dist/index.js (binary name: discourse-mcp)
  • SDK: @modelcontextprotocol/sdk
  • Node: >= 18

TL;DR: Configure and run

  • Install and build
pnpm install
pnpm build
  • Run locally (read‑only, recommended to start):
node dist/index.js

Then, in your MCP client, call the discourse_select_site tool with { "site": "https://try.discourse.org" } to choose a site.

  • Enable writes (opt‑in, safe‑guarded):
node dist/index.js --allow_writes --read_only=false --auth_pairs '[{"site":"https://try.discourse.org","api_key":"'$DISCOURSE_API_KEY'","api_username":"system"}]'
  • Use in an MCP client (example: Claude Desktop) — local build:
{
  "mcpServers": {
    "discourse": {
      "command": "node",
      "args": ["/absolute/path/to/dist/index.js"],
      "env": {}
    }
  }
}
  • Use in an MCP client — if installed globally (after publishing or npm -g):
{
  "mcpServers": {
    "discourse": {
      "command": "discourse-mcp",
      "args": []
    }
  }
}

Configuration

The server registers tools under the MCP server name @discourse/mcp. You select the target Discourse site at runtime using the discourse_select_site tool, which validates the site via /about.json.

  • Auth

    • None by default.
    • --auth_pairs '[{"site":"https://example.com","api_key":"...","api_username":"system"}]': Per‑site API key overrides. You can include multiple entries; the matching entry is used for the selected site.
  • Write safety

    • Writes are disabled by default.
    • The tool discourse.create_post is only registered when all are true:
      • --allow_writes AND not --read_only AND some auth is configured (either default flags or a matching auth_pairs entry).
    • A ~1 req/sec rate limit is enforced for create_post.
  • Flags & defaults

    • --read_only (default: true)
    • --allow_writes (default: false)
    • --timeout_ms <number> (default: 15000)
    • --concurrency <number> (default: 4)
    • --log_level <silent|error|info|debug> (default: info)
    • --tools_mode <auto|discourse_api_only|tool_exec_api> (default: auto)
    • --cache_dir <path> (reserved)
    • --profile <path.json> (see below)
  • Profile file (keep secrets off the command line)

{
  "auth_pairs": [
    { "site": "https://try.discourse.org", "api_key": "<redacted>", "api_username": "system" }
  ],
  "read_only": false,
  "allow_writes": true,
  "log_level": "info",
  "tools_mode": "auto"
}

Run with:

node dist/index.js --profile /absolute/path/to/profile.json

Flags still override values from the profile.

  • Remote Tool Execution API (optional)

    • With tools_mode=auto (default) or tool_exec_api, the server discovers remote tools via GET /ai/tools after you select a site and registers them dynamically. Set --tools_mode=discourse_api_only to disable remote tool discovery.
  • Networking & resilience

    • Retries on 429/5xx with backoff (3 attempts).
    • Lightweight in‑memory GET cache for selected endpoints.
  • Privacy

    • Secrets are redacted in logs. Errors are returned as human‑readable messages to MCP clients.

Tools

Built‑in tools (always present unless noted):

  • discourse_search
    • Input: { query: string; with_private?: boolean; max_results?: number (1–50, default 10) }
    • Output: text summary plus a compact footer like:
      { "results": [{ "id": 123, "url": "https://…", "title": "…" }] }
      
  • discourse_read_topic
    • Input: { topic_id: number; post_limit?: number (1–20, default 5) }
  • discourse_read_post
    • Input: { post_id: number }
  • discourse_list_categories
    • Input: {}
  • discourse_list_tags
    • Input: {}
  • discourse_get_user
    • Input: { username: string }
  • discourse_create_post (only when writes enabled; see Write safety)
    • Input: { topic_id: number; raw: string (≤ 30k chars) }

Notes:

  • Outputs are human‑readable first. Where applicable, a compact JSON is embedded in fenced code blocks to ease structured extraction by agents.

Development

  • Requirements: Node >= 18, pnpm.

  • Install / Build / Typecheck / Test

pnpm install
pnpm typecheck
pnpm build
pnpm test
  • Run locally (with source maps)
pnpm build && pnpm dev
  • Project layout

    • Server & CLI: src/index.ts
    • HTTP client: src/http/client.ts
    • Tool registry: src/tools/registry.ts
    • Built‑in tools: src/tools/builtin/*
    • Remote tools: src/tools/remote/tool_exec_api.ts
    • Logging/redaction: src/util/logger.ts, src/util/redact.ts
  • Testing notes

    • Tests run with Node’s test runner against compiled artifacts (dist/test/**/*.js). Ensure pnpm build before pnpm test if invoking scripts individually.
  • Publishing (optional)

    • The package exposes a bin named discourse-mcp. After publishing or global install, MCP clients can invoke the binary directly without node dist/index.js.
  • Conventions

    • Focus on text‑oriented outputs; keep embedded JSON concise.
    • Be careful with write operations; keep them opt‑in and rate‑limited.

See AGENTS.md for additional guidance on using this server from agent frameworks.

Examples

  • Read‑only session against try.discourse.org:
node dist/index.js --log_level debug
# In client: call discourse_select_site with {"site":"https://try.discourse.org"}
  • Create a post (writes enabled):
node dist/index.js --allow_writes --read_only=false --auth_pairs '[{"site":"https://try.discourse.org","api_key":"'$DISCOURSE_API_KEY'","api_username":"system"}]'

FAQ

  • Why is create_post missing? You’re in read‑only mode. Enable writes as described above.
  • Can I disable remote tool discovery? Yes, run with --tools_mode=discourse_api_only.
  • Time outs or rate limits? Increase --timeout_ms, and note built‑in retry/backoff on 429/5xx.

推荐服务器

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

官方
精选