refactor(mcp): generate the tool definitions from the spec

Produced by k8s-platform/tools/generate-mcp-tools.py: deck file openapi2mcp
does the conversion, and the wrapper re-injects the five things Kong's
generator cannot emit — per-tool ACLs, the MCP behavioural annotations, the
response schemas the plugin uses for structuredOutput, the real upstream host,
and JSON-only request bodies. Each is a documented gap; see
k8s-platform/MCP-TOOL-GENERATION.md.

tools-policy.yaml carries the ACLs and doubles as the allow-list: an operation
becomes a tool only if the policy names it. Kong would otherwise expose every
operation in the spec, DELETE included, and can express no authorization at all
from a bearer-token spec — silently, exit 0, no warning.

Same tools as before, same ACLs. What changed: query parameters are now
declared and callable, each tool carries its response schema so calls return
structured content instead of raw JSON, and request bodies are no longer
tripled across three identical content types.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Stéphane Tailland
2026-08-29 08:48:42 +02:00
parent 482cd2e81f
commit 5ffd0837e1
2 changed files with 557 additions and 178 deletions
+529 -178
View File
@@ -1,3 +1,10 @@
# GENERATED — do not edit. Edit openapi.yaml or tools-policy.yaml, then:
# k8s-platform/tools/generate-mcp-tools.py <this domain>
#
# Produced by `deck file openapi2mcp`, then post-processed to add the ACLs,
# the MCP behavioural annotations, the response schemas, the real upstream
# host and the JSON-only bodies that Kong's generator does not emit. Each of
# those is a documented gap — see k8s-platform/MCP-TOOL-GENERATION.md.
apiVersion: configuration.konghq.com/v1 apiVersion: configuration.konghq.com/v1
kind: KongPlugin kind: KongPlugin
metadata: metadata:
@@ -8,216 +15,560 @@ config:
mode: conversion-listener mode: conversion-listener
include_consumer_groups: true include_consumer_groups: true
tools: tools:
- name: list-orders - annotations:
description: Retrieves a paginated list of orders in the classic-models CRM. title: List all orders
annotations: read_only_hint: true
title: List all orders idempotent_hint: true
read_only_hint: true destructive_hint: false
idempotent_hint: true open_world_hint: false
destructive_hint: false description: Retrieve a paginated list of all customer orders with their status and details.
open_world_hint: false method: GET
acl: name: list-orders
allow: parameters:
- admin - description: A page number within the paginated result set.
- read_only in: query
- product_manager name: page
- customer required: false
- support schema:
method: GET type: integer
scheme: http - description: Number of results to return per page.
host: ${REST_HOSTNAME} in: query
path: /sales/v1/orders/ name: page_size
- name: get-order required: false
description: Retrieves a single order by order number. schema:
annotations: type: integer
title: Get an order path: /sales/v1/orders/
read_only_hint: true acl:
idempotent_hint: true allow:
destructive_hint: false - admin
open_world_hint: false - read_only
acl: - product_manager
allow: - customer
- admin - support
- read_only scheme: http
- product_manager host: ${REST_HOSTNAME}
- customer responses:
- support '200':
method: GET
scheme: http
host: ${REST_HOSTNAME}
path: /sales/v1/orders/{ordernumber}/
parameters:
- name: ordernumber
in: path
required: true
description: The order's unique number.
schema: {}
- name: get-order-orderdetails
description: Retrieves all line items for a specific order.
annotations:
title: Get order line items
read_only_hint: true
idempotent_hint: true
destructive_hint: false
open_world_hint: false
acl:
allow:
- admin
- read_only
- product_manager
- customer
- support
method: GET
scheme: http
host: ${REST_HOSTNAME}
path: /sales/v1/orders/{ordernumber}/order-details/
parameters:
- name: ordernumber
in: path
required: true
description: The order's unique number.
schema: {}
- name: create-order
description: Creates a new order in the CRM.
annotations:
title: Create an order
read_only_hint: false
idempotent_hint: false
destructive_hint: false
open_world_hint: false
# Verified against OrderPermission.check() (authentication/permissions.py):
# admin always passes; customer passes if get_customer_number(user) is
# not None; support passes unconditionally at this class-level check
# (object-level restricts support to status-only on *existing* orders,
# which doesn't apply to create — no object yet). read_only/
# product_manager only pass for SAFE_METHODS, excluded here.
acl:
allow:
- admin
- customer
- support
method: POST
scheme: http
host: ${REST_HOSTNAME}
path: /sales/v1/orders/
request_body:
required: true
content: content:
application/json: application/json:
schema: schema:
type: object type: object
properties:
count:
type: integer
example: 123
next:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=4
previous:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=2
results:
type: array
items:
type: object
description: Customer order information
properties:
ordernumber:
type: integer
maximum: 2147483647
minimum: -2147483648
orderdate:
type: string
format: date
requireddate:
type: string
format: date
shippeddate:
type: string
format: date
nullable: true
status:
type: string
maxLength: 15
comments:
type: string
nullable: true
customernumber:
type: integer
maximum: 2147483647
minimum: -2147483648
required:
- customernumber
- orderdate
- ordernumber
- requireddate
- status
- annotations:
title: Get a specific order
read_only_hint: true
idempotent_hint: true
destructive_hint: false
open_world_hint: false
description: Retrieve detailed information about a specific order by its order number.
method: GET
name: get-order
parameters:
- description: A unique value identifying this order.
in: path
name: ordernumber
required: true
schema:
type: integer
path: /sales/v1/orders/{ordernumber}/
acl:
allow:
- admin
- read_only
- product_manager
- customer
- support
scheme: http
host: ${REST_HOSTNAME}
responses:
'200':
content:
application/json:
schema:
type: object
description: Customer order information
properties: properties:
ordernumber: ordernumber:
type: integer type: integer
maximum: 2147483647
minimum: -2147483648
orderdate: orderdate:
type: string type: string
format: date
requireddate: requireddate:
type: string type: string
format: date
shippeddate: shippeddate:
type: string type: string
format: date
nullable: true
status: status:
type: string type: string
maxLength: 15
comments: comments:
type: string type: string
nullable: true
customernumber: customernumber:
type: integer type: integer
maximum: 2147483647
minimum: -2147483648
required: required:
- ordernumber - customernumber
- orderdate - orderdate
- requireddate - ordernumber
- status - requireddate
- customernumber - status
- name: list-orderdetails - annotations:
description: Retrieves a paginated list of order line items in the classic-models CRM. title: Get order details by order
annotations: read_only_hint: true
title: List all order line items idempotent_hint: true
read_only_hint: true destructive_hint: false
idempotent_hint: true open_world_hint: false
destructive_hint: false description: Retrieve all line items for a specific order. This endpoint supports order fulfillment
open_world_hint: false and invoice generation.
acl: method: GET
allow: name: get-order-order-details
- admin parameters:
- read_only - description: The order number
- product_manager in: path
- customer name: ordernumber
- support required: true
method: GET schema:
scheme: http type: integer
host: ${REST_HOSTNAME} - description: A page number within the paginated result set.
path: /sales/v1/orderdetails/ in: query
- name: get-orderdetail name: page
description: Retrieves a single order line item by order number and product code. required: false
annotations: schema:
title: Get an order line item type: integer
read_only_hint: true - description: Number of results to return per page.
idempotent_hint: true in: query
destructive_hint: false name: page_size
open_world_hint: false required: false
acl: schema:
allow: type: integer
- admin path: /sales/v1/orders/{ordernumber}/order-details/
- read_only acl:
- product_manager allow:
- customer - admin
- support - read_only
method: GET - product_manager
scheme: http - customer
host: ${REST_HOSTNAME} - support
path: /sales/v1/orderdetails/{ordernumber}/{productcode}/ scheme: http
parameters: host: ${REST_HOSTNAME}
- name: ordernumber responses:
in: path '200':
required: true
description: The order's unique number.
schema: {}
- name: productcode
in: path
required: true
description: The product's unique code.
schema: {}
- name: create-orderdetail
description: Adds a new line item to an order.
annotations:
title: Create an order line item
read_only_hint: false
idempotent_hint: false
destructive_hint: false
open_world_hint: false
# Verified against OrderScopedPermission.check() (Orderdetail's base
# permission class) — same shape as create-order above: admin,
# customer (if get_customer_number is not None), support (class-level
# unconditional pass) allowed; read_only/product_manager excluded
# (SAFE_METHODS only).
acl:
allow:
- admin
- customer
- support
method: POST
scheme: http
host: ${REST_HOSTNAME}
path: /sales/v1/orderdetails/
request_body:
required: true
content: content:
application/json: application/json:
schema: schema:
type: object type: object
properties:
count:
type: integer
example: 123
next:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=4
previous:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=2
results:
type: array
items:
type: object
description: Order line items with product details
properties:
id:
type: integer
readOnly: true
quantityordered:
type: integer
maximum: 2147483647
minimum: -2147483648
priceeach:
type: string
format: decimal
pattern: ^-?\d{0,8}(?:\.\d{0,2})?$
orderlinenumber:
type: integer
maximum: 32767
minimum: -32768
ordernumber:
type: integer
maximum: 2147483647
minimum: -2147483648
productcode:
type: string
required:
- id
- orderlinenumber
- ordernumber
- priceeach
- productcode
- quantityordered
- annotations:
title: Create a new order
read_only_hint: false
idempotent_hint: false
destructive_hint: false
open_world_hint: false
description: Create a new customer order with order date, required date, and status information.
method: POST
name: create-order
path: /sales/v1/orders/
request_body:
content:
application/json:
schema:
properties:
comments:
type: string
customernumber:
type: integer
orderdate:
type: string
ordernumber:
type: integer
requireddate:
type: string
shippeddate:
type: string
status:
type: string
required:
- customernumber
- orderdate
- ordernumber
- requireddate
- status
type: object
required: true
acl:
allow:
- admin
- customer
- support
scheme: http
host: ${REST_HOSTNAME}
responses:
'201':
content:
application/json:
schema:
type: object
description: Customer order information
properties: properties:
ordernumber: ordernumber:
type: integer type: integer
productcode: maximum: 2147483647
minimum: -2147483648
orderdate:
type: string type: string
format: date
requireddate:
type: string
format: date
shippeddate:
type: string
format: date
nullable: true
status:
type: string
maxLength: 15
comments:
type: string
nullable: true
customernumber:
type: integer
maximum: 2147483647
minimum: -2147483648
required:
- customernumber
- orderdate
- ordernumber
- requireddate
- status
- annotations:
title: List all order details
read_only_hint: true
idempotent_hint: true
destructive_hint: false
open_world_hint: false
description: Retrieve a paginated list of all order line items with product and quantity information.
method: GET
name: list-order-details
parameters:
- description: A page number within the paginated result set.
in: query
name: page
required: false
schema:
type: integer
- description: Number of results to return per page.
in: query
name: page_size
required: false
schema:
type: integer
path: /sales/v1/orderdetails/
acl:
allow:
- admin
- read_only
- product_manager
- customer
- support
scheme: http
host: ${REST_HOSTNAME}
responses:
'200':
content:
application/json:
schema:
type: object
properties:
count:
type: integer
example: 123
next:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=4
previous:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=2
results:
type: array
items:
type: object
description: Order line items with product details
properties:
id:
type: integer
readOnly: true
quantityordered:
type: integer
maximum: 2147483647
minimum: -2147483648
priceeach:
type: string
format: decimal
pattern: ^-?\d{0,8}(?:\.\d{0,2})?$
orderlinenumber:
type: integer
maximum: 32767
minimum: -32768
ordernumber:
type: integer
maximum: 2147483647
minimum: -2147483648
productcode:
type: string
required:
- id
- orderlinenumber
- ordernumber
- priceeach
- productcode
- quantityordered
- annotations:
title: Get a specific order detail
read_only_hint: true
idempotent_hint: true
destructive_hint: false
open_world_hint: false
description: Retrieve a specific line item from an order using the composite key (orderNumber, productCode).
method: GET
name: get-order-detail
parameters:
- description: The order number
in: path
name: ordernumber
required: true
schema:
type: integer
- description: The product code
in: path
name: productcode
required: true
schema:
type: string
path: /sales/v1/orderdetails/{ordernumber}/{productcode}/
acl:
allow:
- admin
- read_only
- product_manager
- customer
- support
scheme: http
host: ${REST_HOSTNAME}
responses:
'200':
content:
application/json:
schema:
type: object
description: Order line items with product details
properties:
id:
type: integer
readOnly: true
quantityordered: quantityordered:
type: integer type: integer
maximum: 2147483647
minimum: -2147483648
priceeach: priceeach:
type: string type: string
format: decimal
pattern: ^-?\d{0,8}(?:\.\d{0,2})?$
orderlinenumber: orderlinenumber:
type: integer type: integer
maximum: 32767
minimum: -32768
ordernumber:
type: integer
maximum: 2147483647
minimum: -2147483648
productcode:
type: string
required: required:
- ordernumber - id
- productcode - orderlinenumber
- quantityordered - ordernumber
- priceeach - priceeach
- orderlinenumber - productcode
- quantityordered
- annotations:
title: Create a new order detail
read_only_hint: false
idempotent_hint: false
destructive_hint: false
open_world_hint: false
description: Add a new line item to an existing order with product code, quantity, and price.
method: POST
name: create-order-detail
path: /sales/v1/orderdetails/
request_body:
content:
application/json:
schema:
properties:
orderlinenumber:
type: integer
ordernumber:
type: integer
priceeach:
type: string
productcode:
type: string
quantityordered:
type: integer
required:
- orderlinenumber
- ordernumber
- priceeach
- productcode
- quantityordered
type: object
required: true
acl:
allow:
- admin
- customer
- support
scheme: http
host: ${REST_HOSTNAME}
responses:
'201':
content:
application/json:
schema:
type: object
description: Order line items with product details
properties:
id:
type: integer
readOnly: true
quantityordered:
type: integer
maximum: 2147483647
minimum: -2147483648
priceeach:
type: string
format: decimal
pattern: ^-?\d{0,8}(?:\.\d{0,2})?$
orderlinenumber:
type: integer
maximum: 32767
minimum: -32768
ordernumber:
type: integer
maximum: 2147483647
minimum: -2147483648
productcode:
type: string
required:
- id
- orderlinenumber
- ordernumber
- priceeach
- productcode
- quantityordered
+28
View File
@@ -0,0 +1,28 @@
# Which operations of openapi.yaml become MCP tools, and who may call each.
#
# This file is the allow-list as well as the ACL: an operation that is not
# named here does not become a tool. Kong's generator exposes every operation
# it finds and can express no authorization at all from a bearer-token spec —
# see k8s-platform/MCP-TOOL-GENERATION.md, limits 1 and 5.
#
# `allow` lists consumer groups, which come from realm_access.roles in the end
# user's own token. Kong applies them at tools/list, so a caller never sees a
# tool it may not call.
mcp_name: sales-mcp
tools:
list-orders:
allow: [admin, read_only, product_manager, customer, support]
get-order:
allow: [admin, read_only, product_manager, customer, support]
get-order-order-details:
allow: [admin, read_only, product_manager, customer, support]
create-order:
allow: [admin, customer, support]
list-order-details:
allow: [admin, read_only, product_manager, customer, support]
get-order-detail:
allow: [admin, read_only, product_manager, customer, support]
create-order-detail:
allow: [admin, customer, support]