Skip to main content
Glama
ahnmichael

GitLab Forum MCP

by ahnmichael

Read Post

discourse_read_post

Read a specific forum post to access detailed discussions about GitLab CI/CD troubleshooting and feature explanations.

Instructions

Read a specific post.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYes

Implementation Reference

  • Executes the tool logic: fetches post data from Discourse API using the post_id, extracts username, created date, raw content, truncates if over limit, constructs a formatted text response with link, 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 parameter: post_id as a positive integer.
    const schema = z.object({
      post_id: z.number().int().positive(),
    });
  • Registers the discourse_read_post tool with MCP server, providing 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 };
        }
      }
    );
  • Invokes registerReadPost to register the discourse_read_post tool during tools initialization, with writes disabled.
    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' but doesn't clarify if this is a safe read operation, what permissions are required, what data is returned (e.g., content, author, timestamps), or any rate limits. This leaves significant gaps for a tool that likely interacts with user data.

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. Every part of the sentence directly contributes to the tool's purpose, making it efficient and 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 complexity (a read operation with 1 parameter), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like safety or permissions, parameter details, or return values, leaving the agent with insufficient context to use the tool effectively.

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

Parameters2/5

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

The schema description coverage is 0%, and the description adds no meaning beyond what the schema provides. It doesn't explain what 'post_id' represents (e.g., a numeric identifier, where to find it, or its format), failing to compensate for the lack of schema documentation. With 1 parameter, this is a notable oversight.

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 verb ('Read') and resource ('post'), but it's vague about what 'read' entails (e.g., retrieving content, metadata, or both) and doesn't distinguish it from sibling tools like 'discourse_read_topic'. It avoids tautology by not merely restating the name/title.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid post_id), exclusions, or comparisons to siblings like 'discourse_read_topic' or 'discourse_search', leaving the agent to infer usage from context alone.

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/ahnmichael/gitlab-forum-mcp'

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