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
| Name | Required | Description | Default |
|---|---|---|---|
| fromTimestamp | No | Start timestamp in ISO 8601 format | |
| toTimestamp | No | End timestamp in ISO 8601 format | |
| page | No | Page number (default 1) | |
| limit | No | limit (default 100) | |
| traceName | No | Trace name | |
| userId | No | User ID, it's can filter by user | |
| tags | No | Tags | |
| environment | No | Environment |
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(); }
- index.ts:160-169 (handler)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) }], }; }
- index.ts:14-23 (schema)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, ],