Skip to main content
Glama
z9905080

MCP Server for langfuse

by z9905080

query_llm_metrics

Query LLM metrics from Langfuse by time range with filters for trace name, user ID, tags, and environment. Retrieve paginated results to monitor and analyze LLM performance.

Instructions

Query LLM metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromTimestampNoStart timestamp in ISO 8601 format
toTimestampNoEnd timestamp in ISO 8601 format
pageNoPage number (default 1)
limitNolimit (default 100)
traceNameNoTrace name
userIdNoUser ID, it's can filter by user
tagsNoTags
environmentNoEnvironment

Implementation Reference

  • Interface defining the input arguments for query_llm_metrics tool (fromTimestamp, toTimestamp, page, limit, traceName, userId, tags, environment).
    interface QueryLLMMetricsArgs {
      fromTimestamp: string; // ISO 8601 format
      toTimestamp: string; // ISO 8601 format
      page?: number; // default 1
      limit?: number; // default 100
      traceName?: string;
      userId?: string;
      tags?: string[];
      environment?: string[];
    }
  • index.ts:26-74 (registration)
    Tool definition object for 'query_llm_metrics' including name, description, and inputSchema with property definitions.
    const queryLLMMetricsTool: Tool = {
      name: "query_llm_metrics",
      description: "Query LLM metrics",
      inputSchema: {
        type: "object",
        properties: {
          fromTimestamp: {
            type: "string",
            description: "Start timestamp in ISO 8601 format",
          },
          toTimestamp: {
            type: "string",
            description: "End timestamp in ISO 8601 format",
          },
          page: {
            type: "number",
            description: "Page number (default 1)",
            default: 1,
          },
          limit: {
            type: "number",
            description: "limit (default 100)",
            default: 100,
          },
          traceName: {
            type: "string",
            description: "Trace name",
          },
          userId: {
            type: "string",
            description: "User ID, it's can filter by user",
          },
          tags: {
            type: "array",
            items: {
              type: "string",
            },
            description: "Tags",
          },
          environment: {
            type: "array",
            items: {
              type: "string",
            },
            description: "Environment",
          },
        },
      },
    };
  • index.ts:97-118 (handler)
    Handler method 'getLLMMetricsByTimeRange' on LanfuseClient class that performs the actual API call to /api/public/metrics/daily with query parameters.
    async getLLMMetricsByTimeRange(payload: QueryLLMMetricsArgs): Promise<any> {
      const params = new URLSearchParams({
        fromTimestamp: payload.fromTimestamp,
        toTimestamp: payload.toTimestamp,
        page: payload.page?.toString() || '1',
        limit: payload.limit?.toString() || '100',
        traceName: payload.traceName || '',
        userId: payload.userId || '',
        tags: payload.tags?.join(',') || '',
        environment: payload.environment?.join(',') || '',
      });
    
      const response = await fetch(
        `${this.domain}/api/public/metrics/daily?${params}`,
        {
          headers: this.apiHeader,
          method: 'GET'
        }
      );
    
      return response.json();
    }
  • Case handler in the CallToolRequest switch that dispatches 'query_llm_metrics', casts arguments, calls getLLMMetricsByTimeRange, and returns JSON response.
    case "query_llm_metrics": {
      const args = request.params
        .arguments as unknown as QueryLLMMetricsArgs;
      const response = await slackClient.getLLMMetricsByTimeRange(
        args,
      );
      return {
        content: [{ type: "text", text: JSON.stringify(response) }],
      };
    }
  • index.ts:189-196 (registration)
    ListToolsRequest handler that registers queryLLMMetricsTool in the list of available tools returned to the client.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      console.error("Received ListToolsRequest");
      return {
        tools: [
          queryLLMMetricsTool,
        ],
      };
    });
Behavior2/5

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

No annotations exist, and the description does not disclose any behavioral traits such as side effects, permissions, rate limits, or data scope. It merely describes a query, which implies a read-only operation but does not explicitly confirm safety or other constraints.

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

Conciseness2/5

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

The description is extremely short (3 words) but underspecified for a tool with 8 parameters. It lacks necessary detail and is not front-loaded with critical information. Conciseness should not sacrifice completeness.

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 complexity of 8 parameters, no annotations, and no output schema, the description is insufficient. It does not explain what the metrics represent, how results are returned, or any context for interpreting the data. The agent is left without enough information to effectively use the tool.

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 coverage is 100%, so the baseline is 3. The description adds no meaning beyond the schema's parameter descriptions. It does not explain how to use parameters together or provide context that helps the agent understand parameter relationships.

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?

Description states 'Query LLM metrics' which clearly identifies the verb and resource. It is a simple, direct statement of the tool's purpose, though it lacks specificity about which metrics. It is not a tautology and distinguishes the tool as a query operation.

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?

No guidance provided on when to use this tool, what scenarios it is suited for, or any alternatives. The description gives no context for appropriate usage, leaving the agent without decision-making information.

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

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