Skip to main content
Glama
discourse

Discourse MCP

Official
by discourse

Read Post

discourse_read_post

Retrieve a specific post from a Discourse forum by providing its unique post ID for reading content and accessing information.

Instructions

Read a specific post.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYes

Implementation Reference

  • Executes the tool logic: fetches post data from Discourse API via cached GET to /posts/{post_id}.json?include_raw=true, extracts username, created_at, raw content, limits to maxReadLength, builds formatted text with link, returns as text content block or error.
    async ({ post_id }, _extra: any) => {
      try {
        const { base, client } = ctx.siteState.ensureSelectedSite();
        // Prefer raw by asking API for include_raw
        const data = (await client.getCached(`/posts/${post_id}.json?include_raw=true`, 10000)) as any;
        const username = data?.username || data?.user_id || "user";
        const created = data?.created_at || "";
        const raw: string = data?.raw || data?.cooked || "";
        const limit = Number.isFinite(ctx.maxReadLength) ? ctx.maxReadLength : 50000;
        const content = raw.slice(0, limit);
        const url = data?.topic_slug && data?.topic_id
          ? `${base}/t/${data.topic_slug}/${data.topic_id}/${data.post_number}`
          : `${base}/posts/${post_id}`;
        const text = `Post by @${username} (${created})\n\n${content}${raw.length > content.length ? `\n… (+${raw.length - content.length} more)` : ""}\n\nLink: ${url}`;
        return { content: [{ type: "text", text }] };
      } catch (e: any) {
        return { content: [{ type: "text", text: `Failed to read post ${post_id}: ${e?.message || String(e)}` }], isError: true };
      }
    }
  • Zod schema defining input: post_id as positive integer.
    const schema = z.object({
      post_id: z.number().int().positive(),
    });
  • Registers the discourse_read_post tool with MCP server, providing name, metadata (title, description), input schema, and inline handler function.
    server.registerTool(
      "discourse_read_post",
      {
        title: "Read Post",
        description: "Read a specific post.",
        inputSchema: schema.shape,
      },
      async ({ post_id }, _extra: any) => {
        try {
          const { base, client } = ctx.siteState.ensureSelectedSite();
          // Prefer raw by asking API for include_raw
          const data = (await client.getCached(`/posts/${post_id}.json?include_raw=true`, 10000)) as any;
          const username = data?.username || data?.user_id || "user";
          const created = data?.created_at || "";
          const raw: string = data?.raw || data?.cooked || "";
          const limit = Number.isFinite(ctx.maxReadLength) ? ctx.maxReadLength : 50000;
          const content = raw.slice(0, limit);
          const url = data?.topic_slug && data?.topic_id
            ? `${base}/t/${data.topic_slug}/${data.topic_id}/${data.post_number}`
            : `${base}/posts/${post_id}`;
          const text = `Post by @${username} (${created})\n\n${content}${raw.length > content.length ? `\n… (+${raw.length - content.length} more)` : ""}\n\nLink: ${url}`;
          return { content: [{ type: "text", text }] };
        } catch (e: any) {
          return { content: [{ type: "text", text: `Failed to read post ${post_id}: ${e?.message || String(e)}` }], isError: true };
        }
      }
    );
  • Invokes registerReadPost during registerAllTools to add the tool to the MCP server.
    registerReadPost(server, ctx, { allowWrites: false });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'Read a specific post,' which implies a read-only operation but does not specify details like authentication requirements, rate limits, error handling, or what data is returned (e.g., content, author, timestamps). This leaves significant gaps for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence ('Read a specific post.'), which is front-loaded and wastes no words. It efficiently conveys the core action without unnecessary elaboration, making it easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter, no annotations, no output schema), the description is incomplete. It does not explain what 'reading' entails (e.g., output format), potential errors, or usage context. For a tool with no structured support, more detail is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has one parameter (post_id) with 0% description coverage, so the schema provides no semantic details. The description adds no information about the parameter, such as what post_id represents or how to obtain it. However, with only one parameter and a straightforward tool, the baseline is 3 as the schema minimally defines the requirement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the basic action ('Read') and resource ('a specific post'), which is clear but minimal. It distinguishes from siblings like 'discourse_read_topic' by specifying 'post' rather than 'topic', but lacks detail on what reading entails (e.g., retrieving content, metadata). The purpose is vague beyond the basic verb-noun pairing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It does not mention prerequisites (e.g., needing a valid post_id), exclusions, or comparisons to siblings like 'discourse_read_topic' or 'discourse_list_user_posts'. The description offers no contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/discourse/discourse-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server