slice_openapi_spec — Slice OpenAPI 3.0/3.1 or Swagger 2.0 Specification

Scores OpenAPI/Swagger endpoints against a natural-language `query` (BM25 + boosted `operationId`, `summary`, `tags`, and path tokens) or explicit `operationIds`/`pathPatterns`, walks every reachable JSON Pointer `$ref` with cycle protection, prunes unused paths/components, and emits ready-to-use `curl` + TypeScript `fetch` snippets.

Why buy vs. DIY: Saves 50,000-250,000 prompt tokens per large enterprise OpenAPI spec ($0.15+ LLM input cost) while guaranteeing zero broken `#/components/...` `$ref` links or recursive schema crashes.

Pricing: $0.001 USD per OpenAPI/Swagger subgraph slice (x402 instant micropayment) · REST: POST https://spec-slice.apikeg.com/v1/slice-openapi-spec · MCP: https://spec-slice.apikeg.com/mcp

Input Parameters

FieldTypeRequired / DefaultDescription & 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"
                }
              }
            }
          }
        }
      }
    }
  }
}