-
Notifications
You must be signed in to change notification settings - Fork 2
x mcp Filtering
Dipjyoti Metia edited this page May 17, 2026
·
1 revision
Not every operation in a spec should be exposed as an MCP tool. The x-mcp extension lets spec authors control which operations are generated, at three levels of precedence.
operation > path-item > document > CLI default
The most specific declaration wins. If an operation has x-mcp: true, it's always generated, regardless of the path's or document's setting.
By default, every operation is generated unless explicitly excluded with x-mcp: false.
Pass this flag to invert the default: nothing is generated unless explicitly opted in with x-mcp: true. Useful when only a small curated subset of a large API should be exposed to an LLM.
paths:
/admin:
x-mcp: false # exclude every operation under /admin …
delete:
operationId: purgeAll
get:
operationId: listAdmins
x-mcp: true # … except this oneopenapi-go-mcp -spec api.yaml -exclude-by-default \
-out gen/apimcp -package apimcp \
-client-import github.com/me/gen/apipaths:
/pets:
get:
operationId: listPets
x-mcp: true # generated
post:
operationId: createPet # not generated — no x-mcp: truex-mcp: false # nothing by default
paths:
/healthz:
get:
operationId: health
x-mcp: true # opted in- Excluded operations are reported as info diagnostics during generation.
-
Typos (
x-mcp: maybe,x-mcp: 1) become warnings — they don't slip past review. - Use
-warnings-as-errorsin CI to fail builds on typos.
Repo · Releases · Issues · Discussions · Apache 2.0
Get started
Modes
Features
Deploy
Reference
Project