Skip to main content
Glama
therealsachin

Langfuse MCP Server

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

TableJSON 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)

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

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'filtering and pagination', which hints at read-only list behavior, but fails to describe key traits: whether this is a safe read operation (implied but not stated), what the return format looks like (e.g., array of items with metadata), default behaviors (e.g., sorting order), or any rate limits. For a list tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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

Conciseness4/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 items in datasets') and adds key features ('with filtering and pagination'). There's no wasted verbiage or redundancy. However, it could be slightly more structured by explicitly separating purpose from capabilities (e.g., with a colon or bullet points), but this is minor.

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

Completeness2/5

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

Given the tool's complexity (5 parameters, list operation with filtering/pagination), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'items' are (e.g., data records, observations), how results are structured, pagination details (e.g., total count, next page tokens), or error conditions. For a list tool with multiple filters and no structured output, more context is needed to use it effectively.

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 schema fully documents all 5 parameters (datasetName, sourceTraceId, sourceObservationId, page, limit). The description adds no parameter-specific details beyond what's in the schema—it only generically mentions 'filtering and pagination', which the schema already covers with individual parameter descriptions. This meets the baseline of 3 for high schema coverage without additional value from the description.

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 'items in datasets', which is specific and actionable. It distinguishes from siblings like 'get_dataset' (single dataset) and 'list_datasets' (datasets themselves) by focusing on items within datasets. However, it doesn't explicitly differentiate from 'get_dataset_item' (single item) or 'get_observations' (related but different resource).

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 mentions 'filtering and pagination' but provides no explicit guidance on when to use this tool versus alternatives. For example, it doesn't specify when to prefer 'list_dataset_items' over 'get_observations' (which might overlap in data) or 'get_dataset_item' (for single items). There's no mention of prerequisites, exclusions, or typical use cases, leaving the agent to infer usage from context alone.

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