get_config
Retrieve detailed configuration settings including cache, retry policies, and routing strategy by providing a unique configuration identifier.
Instructions
Retrieve detailed information about a specific configuration, including cache settings, retry policies, and routing strategy
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | The unique identifier (slug) of the configuration to retrieve. This can be found in the configuration's URL or from the list_configs tool response |
Implementation Reference
- src/index.ts:339-375 (handler)The MCP tool handler function that executes the get_config logic: fetches config via service, extracts and formats key details (cache, retry, strategy, targets), returns structured text response, handles errors.async (params) => { try { const config = await portkeyService.getConfig(params.slug); return { content: [{ type: "text", text: JSON.stringify({ success: config.success, config: { cache: config.data?.config?.cache && { mode: config.data.config.cache.mode, max_age: config.data.config.cache.max_age }, retry: config.data?.config?.retry && { attempts: config.data.config.retry.attempts, on_status_codes: config.data.config.retry.on_status_codes }, strategy: config.data?.config?.strategy && { mode: config.data.config.strategy.mode }, targets: config.data?.config?.targets?.map(target => ({ provider: target.provider, virtual_key: target.virtual_key })) } }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching configuration details: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } }
- src/index.ts:330-376 (registration)Registration of the 'get_config' tool on the MCP server, specifying name, description, input schema, and inline handler.server.tool( "get_config", "Retrieve detailed information about a specific configuration, including cache settings, retry policies, and routing strategy", { slug: z.string().describe( "The unique identifier (slug) of the configuration to retrieve. " + "This can be found in the configuration's URL or from the list_configs tool response" ) }, async (params) => { try { const config = await portkeyService.getConfig(params.slug); return { content: [{ type: "text", text: JSON.stringify({ success: config.success, config: { cache: config.data?.config?.cache && { mode: config.data.config.cache.mode, max_age: config.data.config.cache.max_age }, retry: config.data?.config?.retry && { attempts: config.data.config.retry.attempts, on_status_codes: config.data.config.retry.on_status_codes }, strategy: config.data?.config?.strategy && { mode: config.data.config.strategy.mode }, targets: config.data?.config?.targets?.map(target => ({ provider: target.provider, virtual_key: target.virtual_key })) } }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error fetching configuration details: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } } );
- src/index.ts:333-338 (schema)Input schema for the get_config tool using Zod, requiring a single 'slug' string parameter with description.{ slug: z.string().describe( "The unique identifier (slug) of the configuration to retrieve. " + "This can be found in the configuration's URL or from the list_configs tool response" ) },
- Helper method in PortkeyService that performs the actual API call to retrieve configuration details by slug from Portkey.ai.async getConfig(slug: string): Promise<GetConfigResponse> { try { const response = await fetch(`${this.baseUrl}/configs/${slug}`, { method: 'GET', headers: { 'x-portkey-api-key': this.apiKey, 'Accept': 'application/json' } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { console.error('PortkeyService Error:', error); throw new Error('Failed to fetch configuration details from Portkey API'); } }
- TypeScript interface defining the expected response structure from the getConfig API call.interface GetConfigResponse { success?: boolean; data?: { config?: ConfigDetails; }; }