Input Parameters
| Field | Type | Required / Default | Description & Constraints |
|---|---|---|---|
spec |
any |
Required | OpenAPI 3.0/3.1 or Swagger 2.0 specification provided as either a parsed JSON object or a serialized JSON string (up to 5 MiB). |
query |
string |
Optional | Natural-language task intent (e.g. 'create credit note and refund invoice') scored via Okapi BM25 plus boosted matches on operationId, summary, tags, and path segments. (maxLength: 500) |
operationIds |
array |
Optional | Explicit operationId values to extract (case-insensitive). (maxItems: 50) |
pathPatterns |
array |
Optional | Explicit path templates or 'METHOD /v1/path/*' glob patterns to extract (e.g. 'POST /v1/invoices/*/refund'). (maxItems: 50) |
methods |
array |
Optional | Optional HTTP method allowlist. (maxItems: 8) |
maxOperations |
integer |
Default: 5 |
Maximum number of matched operations to retain in the sliced OpenAPI spec. (min: 1, max: 50) |
compactDescriptions |
boolean |
Default: false |
Strip verbose prose descriptions, examples, and externalDocs while keeping spec-valid response descriptions. |
includeSnippets |
boolean |
Default: true |
Generate ready-to-use curl and TypeScript fetch code snippets for each selected operation. |
REST Example (curl)
curl -X POST "https://spec-slice.apikeg.com/v1/slice-openapi-spec" \
-H "Content-Type: application/json" \
-d '{
"query": "create credit note and refund invoice",
"maxOperations": 2,
"compactDescriptions": true,
"includeSnippets": true,
"spec": {
"openapi": "3.1.0",
"info": {
"title": "Billing API",
"version": "2.4.0"
},
"servers": [
{
"url": "https://api.billing.example.com"
}
],
"paths": {
"/v1/invoices/{invoiceId}/refunds": {
"post": {
"operationId": "refundInvoice",
"summary": "Refund an invoice",
"tags": [
"Invoices"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RefundRequest"
}
}
}
},
"responses": {
"200": {
"description": "Refund created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Refund"
}
}
}
}
}
}
},
"/v1/warehouses": {
"get": {
"operationId": "listWarehouses",
"summary": "List inventory warehouses",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Warehouse"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"RefundRequest": {
"type": "object",
"required": [
"amountCents"
],
"properties": {
"amountCents": {
"type": "integer"
}
}
},
"Refund": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"Warehouse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"location": {
"type": "string"
}
}
}
}
}
}
}'
MCP tools/call Payload
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "slice_openapi_spec",
"arguments": {
"query": "create credit note and refund invoice",
"maxOperations": 2,
"compactDescriptions": true,
"includeSnippets": true,
"spec": {
"openapi": "3.1.0",
"info": {
"title": "Billing API",
"version": "2.4.0"
},
"servers": [
{
"url": "https://api.billing.example.com"
}
],
"paths": {
"/v1/invoices/{invoiceId}/refunds": {
"post": {
"operationId": "refundInvoice",
"summary": "Refund an invoice",
"tags": [
"Invoices"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RefundRequest"
}
}
}
},
"responses": {
"200": {
"description": "Refund created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Refund"
}
}
}
}
}
}
},
"/v1/warehouses": {
"get": {
"operationId": "listWarehouses",
"summary": "List inventory warehouses",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Warehouse"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"RefundRequest": {
"type": "object",
"required": [
"amountCents"
],
"properties": {
"amountCents": {
"type": "integer"
}
}
},
"Refund": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"Warehouse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"location": {
"type": "string"
}
}
}
}
}
}
}
}
}