list_prompts
Retrieve prompt templates from Langfuse projects with filtering and pagination options to manage AI workflows.
Instructions
List all prompt templates in the Langfuse project.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of prompts to return (default: 50) | |
| page | No | Page number for pagination | |
| name | No | Filter by prompt name (substring match) |
Input Schema (JSON Schema)
{
"properties": {
"limit": {
"description": "Maximum number of prompts to return (default: 50)",
"type": "number"
},
"name": {
"description": "Filter by prompt name (substring match)",
"type": "string"
},
"page": {
"description": "Page number for pagination",
"type": "number"
}
},
"type": "object"
}
Implementation Reference
- src/tools/list-prompts.ts:12-39 (handler)The main handler function that executes the list_prompts tool logic, calling the client and formatting the response as MCP content.export async function listPrompts( client: LangfuseAnalyticsClient, args: ListPromptsArgs = {} ) { try { const promptsData = await client.listPrompts(args); return { content: [ { type: 'text' as const, text: JSON.stringify(promptsData, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text' as const, text: `Error listing prompts: ${errorMessage}`, }, ], isError: true, }; } }
- src/tools/list-prompts.ts:4-10 (schema)Zod schema for input validation of list_prompts tool arguments.export const listPromptsSchema = z.object({ limit: z.number().optional().describe('Maximum number of prompts to return (default: 50)'), page: z.number().optional().describe('Page number for pagination'), name: z.string().optional().describe('Filter by prompt name (substring match)'), }); export type ListPromptsArgs = z.infer<typeof listPromptsSchema>;
- src/index.ts:579-599 (registration)Registration of the list_prompts tool in the allTools array, including name, description, and input schema for MCP listTools request.{ name: 'list_prompts', description: 'List all prompt templates in the Langfuse project.', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum number of prompts to return (default: 50)', }, page: { type: 'number', description: 'Page number for pagination', }, name: { type: 'string', description: 'Filter by prompt name (substring match)', }, }, }, },
- src/langfuse-client.ts:332-358 (helper)Helper method in LangfuseAnalyticsClient that performs the actual API call to list prompts from Langfuse backend.async listPrompts(params: { limit?: number; page?: number; name?: string; }): Promise<any> { const queryParams = new URLSearchParams(); if (params.limit) queryParams.append('limit', params.limit.toString()); if (params.page) queryParams.append('page', params.page.toString()); if (params.name) queryParams.append('name', params.name); const authHeader = 'Basic ' + Buffer.from( `${this.config.publicKey}:${this.config.secretKey}` ).toString('base64'); const response = await fetch(`${this.config.baseUrl}/api/public/v2/prompts?${queryParams}`, { headers: { 'Authorization': authHeader, }, }); if (!response.ok) { await this.handleApiError(response, 'List Prompts'); } return await response.json(); }