Skip to main content
Glama

list_datasets

Retrieve datasets from Langfuse projects with pagination to manage and analyze data efficiently.

Instructions

List all datasets in the project with pagination support.

Input Schema

NameRequiredDescriptionDefault
pageNoPage number for pagination (starts at 1)
limitNoMaximum number of datasets to return (default: 50)

Input Schema (JSON Schema)

{ "properties": { "limit": { "description": "Maximum number of datasets to return (default: 50)", "type": "number" }, "page": { "description": "Page number for pagination (starts at 1)", "type": "number" } }, "type": "object" }

Implementation Reference

  • The main handler function for the list_datasets tool. It invokes the Langfuse client to list datasets and returns the JSON-formatted result or error.
    export async function listDatasets( client: LangfuseAnalyticsClient, args: ListDatasetsArgs = {} ) { try { const data = await client.listDatasets(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 for the list_datasets tool: page and limit.
    export const listDatasetsSchema = z.object({ 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 datasets to return (default: 50)'), });
  • src/index.ts:645-661 (registration)
    Registers the list_datasets tool in the MCP server's tool list, providing name, description, and input schema.
    { name: 'list_datasets', description: 'List all datasets in the project with pagination support.', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (starts at 1)', }, limit: { type: 'number', description: 'Maximum number of datasets to return (default: 50)', }, }, }, },
  • src/index.ts:1098-1101 (registration)
    Switch case in the call tool handler that parses arguments using the schema and invokes the listDatasets handler.
    case 'list_datasets': { const args = listDatasetsSchema.parse(request.params.arguments); return await listDatasets(this.client, args); }
  • LangfuseAnalyticsClient method that performs the actual API request to list datasets from the Langfuse server.
    async listDatasets(params: { page?: number; limit?: number; } = {}): Promise<any> { const queryParams = new URLSearchParams(); 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/v2/datasets?${queryParams}`, { headers: { 'Authorization': authHeader, }, }); if (!response.ok) { await this.handleApiError(response, 'List Datasets'); } 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