home / mcp / discourse mcp server
Provides programmatic access to Discourse forum capabilities for AI agents, including read and write operations with guarded security.
Configuration
View docs{
"mcpServers": {
"king-of-the-grackles-discourse-mcp": {
"command": "npx",
"args": [
"-y",
"@discourse/mcp@latest"
],
"env": {
"DISCOURSE_API_KEY": "<redacted>",
"DISCOURSE_USER_API_KEY": "<user_key>"
}
}
}
}You can run a Discourse MCP server locally to access Discourse forum capabilities as programmable tools for AI agents. This server supports read‑only by default, with optional guarded write operations, and can be tethered to a specific site or discover sites at runtime. It exposes a practical set of tools for searching, reading, drafting, and managing topics, posts, categories, and users within Discourse.
Start with a read‑only setup to explore the available tools and confirm connectivity to a Discourse site. You can tether to a single site at startup or select a site at runtime. Writes are opt‑in and rate limited, so begin by enumerating data and building confidence before enabling any modifications.
To use the server with an MCP client, run it through the standard MCP command path and connect your client to the server. You can either launch the server from an inline command (via npx) or install a global binary and invoke it directly. When you start the server, you can choose a site or let the client select one. If you start with a specific site using a startup flag, the site selector is hidden and all calls target that site.
From your MCP client, call tools such as discourse_search to locate topics, discourse_read_topic to examine topic contents, or discourse_read_post to fetch individual posts. If you need drafts, you can work with discourse_list_drafts, discourse_get_draft, and other read‑only tooling. When you are ready to write, enable writes and provide appropriate authentication so you can create posts, topics, categories, or users.
Prerequisites you need before getting started:
Install the package and run the server in a read‑only mode first to verify connectivity and tool availability.
pnpm install -g @discourse/mcp
npx @discourse/mcp@latestThe server exposes tools under the MCP server name corresponding to the package. You can either select a site at runtime or tether to a single site at startup. Writes are disabled by default and become enabled only when you provide proper authentication and the --allow_writes flag.
Common startup patterns include using npx for quick experiments or running a global binary if you prefer a persistent command.
Key startup options to be aware of include:
If you want the server to connect to a site at startup, you can pass --site <url> and the discourse_select_site tool will be hidden. If you prefer dynamic site selection, omit --site and call discourse_select_site after startup.
You can run the MCP server with the built‑in quick start patterns. The following commands demonstrate read‑only startup and a write‑enabled startup using an API key.
# Read‑only start (recommended to begin)
npx -y @discourse/mcp@latest# Enable writes (opt‑in, safe guarded)
npx -y @discourse/mcp@latest --allow_writes --read_only=false --auth_pairs '[{"site":"https://try.discourse.org","api_key":"<REDACTED>","api_username":"system"}]'Searches Discourse for topics matching a query and returns a text summary with a compact JSON footer containing results.
Reads the content of a topic by its ID, with an optional limit on the number of posts returned.
Fetches a single post by its post_id.
Lists all categories available in the current site.
Lists all tags used across topics.
Retrieves user information for a given username.
Filters topics based on complex criteria including tags, status, and date ranges.
Lists public chat channels visible to the authenticated user.
Lists chat channels for the current user, including direct messages and membership information.
Retrieves a draft by its key and optional sequence.
Lists all drafts for the current user with preview content.
Saves or updates a draft for a new topic, reply, or private message when writes are enabled.
Deletes a draft by its key and sequence number.
Creates a new post in an existing topic with the provided raw content.
Creates a new topic with a title, raw content, and optional category and tags.
Creates a new Discourse user with username, email, and profile details when allowed by permissions.
Creates a new category with name and optional color, hierarchy, and description.