Skip to main content
Glama

Read Post

discourse_read_post

Retrieve content from a specific post in Discourse forums by providing its post ID for reading and analysis.

Instructions

Read a specific post.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYes

Implementation Reference

  • The asynchronous handler function that executes the tool logic: fetches the post data from Discourse API using the selected site's client, extracts relevant information like username, content, and URL, truncates if necessary, formats into a text response, and handles errors.
    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 the input parameters for the tool: a positive integer post_id.
    const schema = z.object({
      post_id: z.number().int().positive(),
    });
  • The server.registerTool call that registers the 'discourse_read_post' tool, specifying its name, metadata (title, description), input schema, and 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 };
        }
      }
    );
  • The call to registerReadPost during the initialization of all tools in the registry, passing server, context, and options.
    registerReadPost(server, ctx, { allowWrites: false });
Behavior2/5

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

With no annotations, the description carries full burden but only states 'Read a specific post', implying a safe read operation. It lacks details on permissions, rate limits, error handling, or response format, which are critical for a tool with no structured behavioral hints.

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, though this brevity contributes to gaps in other dimensions.

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 no annotations, no output schema, and low schema coverage, the description is incomplete. It doesn't explain what 'read' returns, error conditions, or behavioral traits, making it inadequate for a tool that likely involves data retrieval in a complex system like Discourse.

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 description adds no parameter information beyond the schema, which has 0% description coverage for the single parameter 'post_id'. However, with only one parameter and a simple integer type, the baseline is 3 as the schema minimally defines the input, but no additional semantics are provided.

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 'Read a specific post' clearly states the action (read) and resource (post), but it's vague about scope and doesn't distinguish from siblings like 'discourse_read_topic' or 'discourse_list_user_posts'. It lacks specificity about what 'read' entails beyond basic retrieval.

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 doesn't mention prerequisites, exclusions, or compare with sibling tools like 'discourse_read_topic' for topic-level reading or 'discourse_list_user_posts' for user-specific posts, leaving usage context ambiguous.

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/SamSaffron/discourse-mcp'

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