get_post_comments
Retrieve comments from a Substack post, including commenter name, body, date, and reaction counts. Specify the post ID and optionally limit results.
Instructions
Get comments on a published post. Returns commenter name, comment body, date, and reaction counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| post_id | Yes | The post ID to get comments for | |
| limit | No | Max comments to return (default 20) |
Implementation Reference
- src/server.ts:142-163 (handler)Tool registration for 'get_post_comments' — defines the schema (post_id required, limit optional) and handler logic that calls client.getPostComments() and maps results to a summary with id, name, body, date, reactions, and replies.
server.tool( "get_post_comments", "Get comments on a published post. Returns commenter name, comment body, date, and reaction counts.", { post_id: z.number().describe("The post ID to get comments for"), limit: z.number().optional().default(20).describe("Max comments to return (default 20)"), }, async ({ post_id, limit }) => { const comments = await client.getPostComments(post_id, limit); const summary = comments.map((c) => ({ id: c.id, name: c.name, body: c.body, date: c.date, reactions: c.reactions, replies: c.children_count, })); return { content: [{ type: "text", text: JSON.stringify(summary, null, 2) }], }; }, ); - src/server.ts:145-148 (schema)Input schema for get_post_comments: post_id (number, required) and limit (number, optional, default 20).
{ post_id: z.number().describe("The post ID to get comments for"), limit: z.number().optional().default(20).describe("Max comments to return (default 20)"), }, - src/server.ts:142-163 (registration)Registration of the 'get_post_comments' tool on the McpServer via server.tool().
server.tool( "get_post_comments", "Get comments on a published post. Returns commenter name, comment body, date, and reaction counts.", { post_id: z.number().describe("The post ID to get comments for"), limit: z.number().optional().default(20).describe("Max comments to return (default 20)"), }, async ({ post_id, limit }) => { const comments = await client.getPostComments(post_id, limit); const summary = comments.map((c) => ({ id: c.id, name: c.name, body: c.body, date: c.date, reactions: c.reactions, replies: c.children_count, })); return { content: [{ type: "text", text: JSON.stringify(summary, null, 2) }], }; }, ); - src/api/client.ts:171-180 (helper)Client method getPostComments() — makes HTTP GET request to /api/v1/post/{postId}/comments and returns up to `limit` comments as SubstackComment[] objects.
async getPostComments( postId: number, limit = 20, ): Promise<SubstackComment[]> { const data = await this.request<{ comments: SubstackComment[] }>( `${this.publicationUrl}/api/v1/post/${postId}/comments`, ); const comments = data.comments || []; return comments.slice(0, limit); } - src/api/types.ts:81-91 (schema)SubstackComment interface — defines the shape of comment data: id, body, name, date, user_id, reactions, children_count.
export interface SubstackComment { id: number; body: string; body_json?: unknown; name: string; date: string; user_id: number; author_is_admin?: boolean; reactions?: Record<string, number>; children_count?: number; }