From 528e0fdc0c00cd86237d24ce44b0428ae245ccff Mon Sep 17 00:00:00 2001 From: "siva.durga" Date: Mon, 10 Aug 2026 20:09:05 +0530 Subject: [PATCH] chore: added mcp openapi spec --- openapi.yaml | 99 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 15 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index ad2be0fb..32427214 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -19152,7 +19152,14 @@ paths: required: false schema: type: string - enum: [rpm, rph, rpd] + enum: [rpm, rph, rpd, rpw] + - name: target + in: query + description: Filter by target resource + required: false + schema: + type: string + enum: [llm, mcp_tools] - $ref: '#/components/parameters/PageSize' - $ref: '#/components/parameters/CurrentPage' responses: @@ -36559,16 +36566,42 @@ components: key: type: string description: | - Condition key. Valid values: - - `api_key` - Apply to a specific API key - - `organisation_id` - Apply to an organization - - `workspace_id` - Apply to a workspace - - `metadata.*` - Apply based on custom metadata fields (e.g., `metadata.user_id`, `metadata.team`) - example: workspace_id + Condition key. Valid keys depend on the policy target: + + **LLM policies (target: llm):** + - `api_key` - Match by API key ID + - `virtual_key` - Match by virtual key slug + - `provider` - Match by provider (e.g., `openai`, `anthropic`, `azure-openai`) + - `config` - Match by config slug + - `prompt` - Match by prompt slug + - `model` - Match by model (supports wildcards, e.g., `@openai/gpt-4o`, `@anthropic/*`) + - `endpoint_type` - Match by endpoint type (e.g., `chatComplete`, `embed`, `imageGenerate`) — rate limit policies only + - `metadata.*` - Match by request metadata (e.g., `metadata._user`, `metadata.team`) + + **MCP policies (target: mcp_tools):** + - `api_key` - Match by API key ID + - `workspace_id` - Match by workspace ID + - `mcp_server` - Match by MCP server name + - `mcp_tool` - Match by MCP tool name + - `metadata.*` - Match by request metadata + example: api_key value: - type: string - description: Condition value - example: workspace-123 + oneOf: + - type: string + - type: array + items: + type: string + description: | + Value(s) to match. Use `"*"` for wildcard matching. + Can be a single string or an array of strings (OR logic for arrays). + example: "*" + excludes: + oneOf: + - type: string + - type: array + items: + type: string + description: Value(s) to exclude from matching. GroupBy: type: object @@ -36578,10 +36611,23 @@ components: key: type: string description: | - Group by key. Valid values: + Group by key. Each unique combination of group_by values gets its own counter. + + **LLM policies (target: llm):** + - `api_key` - Group by API key + - `workspace_id` - Group by workspace + - `virtual_key` - Group by virtual key + - `provider` - Group by provider + - `config` - Group by config + - `prompt` - Group by prompt + - `model` - Group by model (uses request model name) + - `metadata.*` - Group by custom metadata fields (e.g., `metadata._user`) + + **MCP policies (target: mcp_tools):** - `api_key` - Group by API key - - `organisation_id` - Group by organization - `workspace_id` - Group by workspace + - `mcp_server` - Group by MCP server name + - `mcp_tool` - Group by MCP tool name - `metadata.*` - Group by custom metadata fields example: api_key @@ -36693,15 +36739,24 @@ components: description: Policy type unit: type: string - enum: [rpm, rph, rpd] + enum: [rpm, rph, rpd, rpw] description: | Rate unit: - `rpm` - Requests/Tokens per minute - `rph` - Requests/Tokens per hour - `rpd` - Requests/Tokens per day + - `rpw` - Requests/Tokens per week value: type: number description: Rate limit value + target: + type: string + enum: [llm, mcp_tools] + default: llm + description: | + The target resource for rate limiting: + - `llm` - Apply rate limit to LLM requests (default) + - `mcp_tools` - Apply rate limit to MCP tool calls workspace_id: type: string description: Workspace ID or slug. Required if not using API key authentication. @@ -36719,11 +36774,17 @@ components: description: Policy name unit: type: string - enum: [rpm, rph, rpd] + enum: [rpm, rph, rpd, rpw] description: Rate unit value: type: number description: Rate limit value + conditions: + type: array + minItems: 1 + items: + $ref: '#/components/schemas/Condition' + description: Array of conditions that define which requests the policy applies to UsageLimitsPolicy: type: object @@ -36866,7 +36927,7 @@ components: description: Policy type unit: type: string - enum: [rpm, rph, rpd] + enum: [rpm, rph, rpd, rpw] description: Rate unit value: type: number @@ -36891,6 +36952,14 @@ components: type: string format: date-time description: Last update timestamp + target: + type: string + enum: [llm, mcp_tools] + default: llm + description: | + The target resource for rate limiting: + - `llm` - Apply rate limit to LLM requests (default) + - `mcp_tools` - Apply rate limit to MCP tool calls CreatePolicyResponse: type: object