List models
listModelsRetrieve models tracked in Langfuse for cost and token attribution, with pagination to manage result sets.
Instructions
List models known to Langfuse (for cost / token attribution).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number (default 1) | |
| limit | No | Items per page (default 50, max 100) |
Implementation Reference
- src/tools.ts:315-315 (handler)The handler function that executes the listModels tool logic - sends a GET request to /api/public/models endpoint and returns JSON results (line 315 is the handler, but the full registration spans 308-316).
async (args) => asJson(await client.get("/api/public/models", args)), - src/tools.ts:313-313 (schema)Input schema for listModels: uses paginationShape (page and limit) for pagination.
inputSchema: { ...paginationShape }, - src/tools.ts:308-316 (registration)Registration of the listModels tool via server.registerTool with title, description, input schema, and handler.
server.registerTool( "listModels", { title: "List models", description: "List models known to Langfuse (for cost / token attribution).", inputSchema: { ...paginationShape }, }, async (args) => asJson(await client.get("/api/public/models", args)), ); - src/schemas.ts:3-12 (helper)The paginationShape schema used as input schema for listModels, defining optional page and limit parameters.
export const paginationShape = { page: z.number().int().positive().optional().describe("Page number (default 1)"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Items per page (default 50, max 100)"), }; - src/tools.ts:6-8 (helper)The asJson helper used by the listModels handler to wrap API responses into MCP text content format.
const asJson = (data: unknown) => ({ content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], });