update_virtual_key
Update a virtual key's name, secret, note, or limits. Changes apply immediately to downstream prompts and configs.
Instructions
Update a virtual key's name, secret, note, or limits. Rotating the key takes effect immediately, and limit changes apply to downstream prompts and configs using this slug. Returns the updated name, slug, and status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | The slug of the virtual key to update | |
| name | No | New display name for the key | |
| key | No | New provider API key value | |
| note | No | New note or description | |
| credit_limit | No | New credit limit for usage | |
| alert_threshold | No | New alert threshold percentage (0-100) | |
| rate_limit_rpm | No | New rate limit in requests per minute |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the tool call succeeded and returned structured data | |
| data | No | Structured success payload when ok is true | |
| error | No | Structured error payload when ok is false |
Implementation Reference
- src/tools/keys.tools.ts:349-384 (handler)The MCP tool handler for 'update_virtual_key'. Receives params (slug, name, key, note, credit_limit, alert_threshold, rate_limit_rpm), calls service.keys.updateVirtualKey, and returns the updated key's name, slug, and status.
// Phase 2: Update virtual key tool server.tool( "update_virtual_key", "Update a virtual key's name, secret, note, or limits. Rotating the key takes effect immediately, and limit changes apply to downstream prompts and configs using this slug. Returns the updated name, slug, and status.", KEYS_TOOL_SCHEMAS.updateVirtualKey, async (params) => { const result = await service.keys.updateVirtualKey(params.slug, { name: params.name, key: params.key, note: params.note, usage_limits: buildUsageLimits({ credit_limit: params.credit_limit, alert_threshold: params.alert_threshold, }), rate_limits: buildRateLimitsRpm(params.rate_limit_rpm), }); return { content: [ { type: "text", text: JSON.stringify( { message: `Successfully updated virtual key "${params.slug}"`, name: result.name, slug: result.slug, status: result.status, }, null, 2, ), }, ], }; }, ); - src/tools/keys.tools.ts:60-81 (schema)Input validation schema for update_virtual_key using Zod: slug (required), name, key, note, credit_limit, alert_threshold, rate_limit_rpm (all optional).
updateVirtualKey: { slug: z.string().describe("The slug of the virtual key to update"), name: z.string().optional().describe("New display name for the key"), key: z.string().optional().describe("New provider API key value"), note: z.string().optional().describe("New note or description"), credit_limit: z.coerce .number() .positive() .optional() .describe("New credit limit for usage"), alert_threshold: z.coerce .number() .min(0) .max(100) .optional() .describe("New alert threshold percentage (0-100)"), rate_limit_rpm: z.coerce .number() .positive() .optional() .describe("New rate limit in requests per minute"), }, - src/tools/keys.tools.ts:350-351 (registration)Registration of the tool name 'update_virtual_key' with its schema KEYS_TOOL_SCHEMAS.updateVirtualKey on the McpServer.
server.tool( "update_virtual_key", - src/services/keys.service.ts:168-176 (handler)Service method that performs an HTTP PUT to /virtual-keys/{slug} with the update payload. This is the actual backend implementation called by the tool handler.
async updateVirtualKey( slug: string, data: UpdateVirtualKeyRequest, ): Promise<VirtualKey> { return this.put<VirtualKey>( `/virtual-keys/${this.encodePathSegment(slug)}`, data, ); } - src/services/keys.service.ts:57-63 (helper)Type definition for UpdateVirtualKeyRequest: optional name, key, note, usage_limits, and rate_limits.
export interface UpdateVirtualKeyRequest { name?: string; key?: string; note?: string | null; usage_limits?: Partial<VirtualKeyUsageLimits>; rate_limits?: VirtualKeyRateLimit[]; }