list_comments
Retrieve and filter comments on Langfuse objects like traces, observations, sessions, or prompts by object type, ID, or author to analyze feedback and discussions.
Instructions
List comments with filtering options for objects and users.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination (starts at 1) | |
| limit | No | Maximum number of comments to return (max 100) | |
| objectType | No | Filter comments by object type | |
| objectId | No | Filter comments by specific object ID | |
| authorUserId | No | Filter comments by author user ID |
Input Schema (JSON Schema)
{
"properties": {
"authorUserId": {
"description": "Filter comments by author user ID",
"type": "string"
},
"limit": {
"description": "Maximum number of comments to return (max 100)",
"maximum": 100,
"minimum": 1,
"type": "number"
},
"objectId": {
"description": "Filter comments by specific object ID",
"type": "string"
},
"objectType": {
"description": "Filter comments by object type",
"enum": [
"trace",
"observation",
"session",
"prompt"
],
"type": "string"
},
"page": {
"description": "Page number for pagination (starts at 1)",
"type": "number"
}
},
"type": "object"
}
Implementation Reference
- src/tools/list-comments.ts:14-29 (handler)The main handler function for the 'list_comments' MCP tool. It calls the Langfuse client to fetch comments and returns a formatted JSON response or error.export async function listComments( client: LangfuseAnalyticsClient, args: ListCommentsArgs ) { try { const data = await client.listComments(args); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; } catch (error: any) { return { content: [{ type: 'text' as const, text: `Error listing comments: ${error.message}` }], isError: true, }; } }
- src/tools/list-comments.ts:4-10 (schema)Zod schema defining the input parameters for the list_comments tool, used for validation in the handler.export const listCommentsSchema = z.object({ page: z.number().int().positive().optional().describe('Page number for pagination (starts at 1)'), limit: z.number().int().min(1).max(100).optional().describe('Maximum number of comments to return (max 100)'), objectType: z.enum(['trace', 'observation', 'session', 'prompt']).optional().describe('Filter comments by object type'), objectId: z.string().optional().describe('Filter comments by specific object ID'), authorUserId: z.string().optional().describe('Filter comments by author user ID'), });
- src/index.ts:804-835 (registration)Tool definition registered in the server's listTools handler, providing name, description, and JSON Schema for MCP protocol compliance.{ name: 'list_comments', description: 'List comments with filtering options for objects and users.', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (starts at 1)', }, limit: { type: 'number', minimum: 1, maximum: 100, description: 'Maximum number of comments to return (max 100)', }, objectType: { type: 'string', enum: ['trace', 'observation', 'session', 'prompt'], description: 'Filter comments by object type', }, objectId: { type: 'string', description: 'Filter comments by specific object ID', }, authorUserId: { type: 'string', description: 'Filter comments by author user ID', }, }, }, },
- src/index.ts:1136-1139 (registration)Switch case in the callToolRequestSchema handler that dispatches list_comments tool calls by parsing arguments with the Zod schema and invoking the handler function.case 'list_comments': { const args = listCommentsSchema.parse(request.params.arguments); return await listComments(this.client, args); }