Skip to main content
Glama
z9905080

MCP Server for langfuse

by z9905080

query_llm_metrics

Retrieve LLM performance metrics from Langfuse workspaces by time range, user, tags, or environment for analysis and monitoring.

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

  • index.ts:97-118 (handler)
    Core handler function that constructs API query parameters and fetches LLM metrics data from the Langfuse API.
    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(); }
  • Tool dispatch handler in the CallToolRequest that invokes the metrics fetcher and formats the 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) }], }; }
  • TypeScript interface defining the structure of input arguments for the query_llm_metrics tool.
    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)
    Defines and registers the tool metadata including name, description, and detailed input schema for MCP compatibility.
    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:192-194 (registration)
    Registers the query_llm_metrics tool in the list exposed via ListToolsRequest handler.
    tools: [ queryLLMMetricsTool, ],
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