Get a dataset item by id
getDatasetItemRetrieve a specific dataset item using its unique ID to access detailed information from Langfuse.
Instructions
Fetch a single dataset item by id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| itemId | Yes |
Implementation Reference
- src/tools.ts:231-239 (registration)Registers the 'getDatasetItem' tool with the MCP server, defining its title, description, input schema (itemId required), and handler that calls GET /api/public/dataset-items/{itemId}.
server.registerTool( "getDatasetItem", { title: "Get a dataset item by id", description: "Fetch a single dataset item by id.", inputSchema: { itemId: z.string().min(1) }, }, async ({ itemId }) => asJson(await client.get(`/api/public/dataset-items/${enc(itemId)}`)), ); - src/tools.ts:238-239 (handler)The handler for 'getDatasetItem': takes an itemId, URL-encodes it, and fetches from the Langfuse API endpoint /api/public/dataset-items/{itemId}. Results are returned as JSON text.
async ({ itemId }) => asJson(await client.get(`/api/public/dataset-items/${enc(itemId)}`)), ); - src/tools.ts:236-237 (schema)The input schema for 'getDatasetItem': a single required field 'itemId' validated as a non-empty string via Zod's z.string().min(1).
inputSchema: { itemId: z.string().min(1) }, }, - src/tools.ts:6-10 (helper)Helper functions used by the getDatasetItem handler: asJson() wraps data into MCP content format, and enc() is URL-encoding (encodeURIComponent).
const asJson = (data: unknown) => ({ content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }); const enc = encodeURIComponent; - src/tools.ts:408-420 (helper)The type-level registration of 'getDatasetItem' in a const array (for TypeScript type safety) listing all tool names.
"getDatasetItem", "listDatasetRuns", "getDatasetRun", "getMetrics", "getDailyMetrics", "listModels", "getModel", "listProjects", "listComments", "getComment", "getMedia", "getHealth", ] as const;