list_configs
Retrieve all configurations in your Portkey organization, including their status and workspace associations.
Instructions
Retrieve all configurations in your Portkey organization, including their status and workspace associations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:191-222 (handler)The asynchronous handler function for the 'list_configs' MCP tool. It invokes PortkeyService.listConfigs() and formats the response data into a standardized MCP text content block with pretty-printed JSON.async () => { try { const configs = await portkeyService.listConfigs(); return { content: [{ type: "text", text: JSON.stringify({ success: configs.success, configurations: configs.data.map(config => ({ id: config.id, name: config.name, slug: config.slug, workspace_id: config.workspace_id, status: config.status, is_default: config.is_default, created_at: config.created_at, last_updated_at: config.last_updated_at, owner_id: config.owner_id, updated_by: config.updated_by })) }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching configurations: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } }
- Core helper method in PortkeyService that performs the HTTP GET request to the Portkey API endpoint '/configs' to retrieve the list of configurations, including error handling and type assertion.async listConfigs(): Promise<ListConfigsResponse> { try { const response = await fetch(`${this.baseUrl}/configs`, { method: 'GET', headers: { 'x-portkey-api-key': this.apiKey, 'Accept': 'application/json' } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return await response.json() as ListConfigsResponse; } catch (error) { console.error('PortkeyService Error:', error); throw new Error('Failed to fetch configurations from Portkey API'); } }
- TypeScript interface defining the expected response structure from the Portkey listConfigs API, consisting of a success flag and an array of Config objects.interface ListConfigsResponse { success: boolean; data: Config[]; }
- TypeScript interface defining the structure of individual configuration objects returned in the listConfigs response.interface Config { id: string; name: string; slug: string; organisation_id: string; workspace_id: string; is_default: number; status: string; owner_id: string; updated_by: string; created_at: string; last_updated_at: string; }
- src/index.ts:187-223 (registration)MCP server tool registration for 'list_configs', specifying the tool name, description, empty input schema (no parameters required), and references the handler function.server.tool( "list_configs", "Retrieve all configurations in your Portkey organization, including their status and workspace associations", {}, async () => { try { const configs = await portkeyService.listConfigs(); return { content: [{ type: "text", text: JSON.stringify({ success: configs.success, configurations: configs.data.map(config => ({ id: config.id, name: config.name, slug: config.slug, workspace_id: config.workspace_id, status: config.status, is_default: config.is_default, created_at: config.created_at, last_updated_at: config.last_updated_at, owner_id: config.owner_id, updated_by: config.updated_by })) }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching configurations: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } } );