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
| Name | Required | Description | Default |
|---|---|---|---|
| post_id | Yes |
Implementation Reference
- src/tools/builtin/read_post.ts:16-34 (handler)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 }; } }
- src/tools/builtin/read_post.ts:5-7 (schema)Zod schema defining the input parameter: post_id as a positive integer.const schema = z.object({ post_id: z.number().int().positive(), });
- src/tools/builtin/read_post.ts:9-35 (registration)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 }; } } );
- src/tools/registry.ts:42-42 (registration)Invokes registerReadPost to register the discourse_read_post tool during tools initialization, with writes disabled.registerReadPost(server, ctx, { allowWrites: false });