Skip to main content
Glama
therealsachin

Langfuse MCP Server

list_models

Retrieve available AI models in a Langfuse project to analyze usage, costs, and performance across different models.

Instructions

List all available AI models in the Langfuse project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of models to return (default: 50)
pageNoPage number for pagination

Implementation Reference

  • The main handler function that executes the list_models tool logic. It invokes the client's listModels method with provided arguments, formats the response as JSON text content, and handles errors appropriately.
    export async function listModels(
      client: LangfuseAnalyticsClient,
      args: ListModelsArgs = {}
    ) {
      try {
        const modelsData = await client.listModels(args);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(modelsData, null, 2),
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: 'text' as const,
              text: `Error listing models: ${errorMessage}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters for the list_models tool: optional limit and page for pagination.
    export const listModelsSchema = z.object({
      limit: z.number().optional().describe('Maximum number of models to return (default: 50)'),
      page: z.number().optional().describe('Page number for pagination'),
    });
  • src/index.ts:548-564 (registration)
    Tool registration in the allTools array used by listToolsRequestHandler, defining the name, description, and inputSchema for list_models.
    {
      name: 'list_models',
      description: 'List all available AI models in the Langfuse project.',
      inputSchema: {
        type: 'object',
        properties: {
          limit: {
            type: 'number',
            description: 'Maximum number of models to return (default: 50)',
          },
          page: {
            type: 'number',
            description: 'Page number for pagination',
          },
        },
      },
    },
  • src/index.ts:1072-1075 (registration)
    Dispatch case in the CallToolRequestSchema handler that parses arguments using the schema and invokes the listModels handler function.
    case 'list_models': {
      const args = listModelsSchema.parse(request.params.arguments);
      return await listModels(this.client, args);
    }
  • Underlying client method that makes the HTTP request to Langfuse API /api/public/models to fetch the list of models, used by the tool handler.
    async listModels(params: {
      limit?: number;
      page?: number;
    }): Promise<any> {
      const queryParams = new URLSearchParams();
    
      if (params.limit) queryParams.append('limit', params.limit.toString());
      if (params.page) queryParams.append('page', params.page.toString());
    
      const authHeader = 'Basic ' + Buffer.from(
        `${this.config.publicKey}:${this.config.secretKey}`
      ).toString('base64');
    
      const response = await fetch(`${this.config.baseUrl}/api/public/models?${queryParams}`, {
        headers: {
          'Authorization': authHeader,
        },
      });
    
      if (!response.ok) {
        await this.handleApiError(response, 'List Models');
      }
    
      return await response.json();
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states it's a list operation but doesn't mention whether it's read-only, safe, paginated (though implied by parameters), rate-limited, or requires authentication. This leaves significant behavioral gaps for the agent.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy for the agent to parse quickly.

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?

For a simple list tool with 2 parameters and 100% schema coverage, the description is minimally adequate. However, without annotations or output schema, it should ideally mention the return format (e.g., list of model objects) and any behavioral constraints to be more complete.

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 already fully documents both parameters (limit and page). The description adds no additional parameter information beyond what's in the schema, meeting the baseline for high coverage but not providing extra value.

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 ('all available AI models in the Langfuse project'), making the purpose immediately understandable. However, it doesn't distinguish this tool from similar sibling tools like 'get_model_detail' or 'usage_by_model', which prevents a perfect score.

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 when to choose 'list_models' over 'get_model_detail' for specific model information or 'usage_by_model' for usage statistics, leaving the agent without contextual usage instructions.

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