Skip to main content
Glama

list_dataset_items

Retrieve dataset items with filtering by name, trace ID, or observation ID, and pagination controls for efficient data access.

Instructions

List items in datasets with filtering and pagination.

Input Schema

NameRequiredDescriptionDefault
datasetNameNoFilter by dataset name
sourceTraceIdNoFilter by source trace ID
sourceObservationIdNoFilter by source observation ID
pageNoPage number for pagination (starts at 1)
limitNoMaximum number of items to return (default: 50)

Input Schema (JSON Schema)

{ "properties": { "datasetName": { "description": "Filter by dataset name", "type": "string" }, "limit": { "description": "Maximum number of items to return (default: 50)", "type": "number" }, "page": { "description": "Page number for pagination (starts at 1)", "type": "number" }, "sourceObservationId": { "description": "Filter by source observation ID", "type": "string" }, "sourceTraceId": { "description": "Filter by source trace ID", "type": "string" } }, "type": "object" }

Implementation Reference

  • The core handler function that executes the tool logic for list_dataset_items. It calls the Langfuse client method, formats the JSON response, and handles errors by returning MCP-formatted error content.
    export async function listDatasetItems( client: LangfuseAnalyticsClient, args: ListDatasetItemsArgs = {} ) { try { const data = await client.listDatasetItems(args); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text' as const, text: `Error: ${errorMessage}` }], isError: true, }; } }
  • Zod schema defining the input parameters and validation for the list_dataset_items tool, including optional filters and pagination.
    export const listDatasetItemsSchema = z.object({ datasetName: z.string().optional().describe('Filter by dataset name'), sourceTraceId: z.string().optional().describe('Filter by source trace ID'), sourceObservationId: z.string().optional().describe('Filter by source observation ID'), page: z.number().min(1).optional().describe('Page number for pagination (starts at 1)'), limit: z.number().min(1).max(100).optional().describe('Maximum number of items to return (default: 50)'), }); export type ListDatasetItemsArgs = z.infer<typeof listDatasetItemsSchema>;
  • src/index.ts:715-743 (registration)
    Registration of the list_dataset_items tool in the MCP server's list of tools, including name, description, and input schema specification.
    { name: 'list_dataset_items', description: 'List items in datasets with filtering and pagination.', inputSchema: { type: 'object', properties: { datasetName: { type: 'string', description: 'Filter by dataset name', }, sourceTraceId: { type: 'string', description: 'Filter by source trace ID', }, sourceObservationId: { type: 'string', description: 'Filter by source observation ID', }, page: { type: 'number', description: 'Page number for pagination (starts at 1)', }, limit: { type: 'number', description: 'Maximum number of items to return (default: 50)', }, }, }, },
  • MCP server dispatcher case that parses arguments using the schema and invokes the list_dataset_items handler function.
    case 'list_dataset_items': { const args = listDatasetItemsSchema.parse(request.params.arguments); return await listDatasetItems(this.client, args); }
  • LangfuseAnalyticsClient helper method that makes the HTTP GET request to the Langfuse API endpoint /api/public/dataset-items to retrieve dataset items.
    async listDatasetItems(params: { datasetName?: string; sourceTraceId?: string; sourceObservationId?: string; page?: number; limit?: number; } = {}): Promise<any> { const queryParams = new URLSearchParams(); if (params.datasetName) queryParams.append('datasetName', params.datasetName); if (params.sourceTraceId) queryParams.append('sourceTraceId', params.sourceTraceId); if (params.sourceObservationId) queryParams.append('sourceObservationId', params.sourceObservationId); if (params.page) queryParams.append('page', params.page.toString()); if (params.limit) queryParams.append('limit', params.limit.toString()); const authHeader = 'Basic ' + Buffer.from( `${this.config.publicKey}:${this.config.secretKey}` ).toString('base64'); const response = await fetch(`${this.config.baseUrl}/api/public/dataset-items?${queryParams}`, { headers: { 'Authorization': authHeader, }, }); if (!response.ok) { await this.handleApiError(response, 'List Dataset Items'); } return await response.json(); }

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/therealsachin/langfuse-mcp-server'

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