Skip to main content
Glama
therealsachin

Langfuse MCP Server

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

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

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();
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'pagination support', which is useful context beyond basic listing, but doesn't cover other important aspects like rate limits, authentication requirements, error handling, or what the output looks like (e.g., format, fields).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('List all datasets in the project') and adds a key behavioral trait ('with pagination support') without any wasted words. Every element earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (listing with pagination), no annotations, and no output schema, the description is minimally adequate. It covers the basic action and pagination but lacks details on output format, error cases, or integration with sibling tools, leaving gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema fully documents both parameters (page and limit). The description adds no additional parameter semantics beyond what's in the schema, maintaining the baseline score of 3 for adequate but not enhanced documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('list') and resource ('datasets in the project'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_projects' or 'list_models', which would require mentioning it's specifically about datasets rather than other project resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention siblings like 'get_dataset' (for single dataset details) or 'list_dataset_items' (for items within datasets), nor does it specify prerequisites or contextual triggers for listing datasets.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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'

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