Skip to main content
Glama

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

NameRequiredDescriptionDefault
limitNoMaximum number of prompts to return (default: 50)
pageNoPage number for pagination
nameNoFilter 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

  • 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, }; } }
  • 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)', }, }, }, },
  • 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(); }

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/therealsachin/langfuse-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server