Exposure¶
A spec usually holds more operations than the model should see. This guide covers choosing which operations the gateway exposes, which become resources, and when to put a large API behind search. Context Efficiency compares these levers with tool shaping.
Filtering Operations¶
policy keeps or drops operations by operationId or by method and path. This keeps GitHub's repository reads and drops its secrets:
servers:
- name: github
spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
policy:
allow: ["GET /repos/*"]
deny: ["GET /repos/*/actions/secrets*"]
To opt operations in from the spec instead, mark each with x-mcp-integration: {tool: {}} and set policy.annotated_only: true. Configuration gives the matching rules and the order the filters apply in.
Resource Exposure¶
A read-only GET fully identified by its URL suits an MCP resource, which the client or the user reads when they choose, better than a tool, which the model calls.
Set exposure.promote_resources: true and every eligible GET becomes a resource. Eligible means no required parameter outside the path. A required path parameter turns the operation into a resource template. Every PokéAPI operation is such a GET, so all 102 become resources with no spec edits. Each list becomes a resource, and each lookup by id a resource template. An operation with a required query parameter, or a method other than GET, stays a tool.
Warning
Resource support is uneven across MCP clients and agent frameworks. One that ignores resources never reaches a promoted operation. Leave promote_resources off when you target such a client.
Per-Operation Control¶
Each resource can take its own name, URI template, or MIME type, in either form Config and Spec Forms describes:
Declaring both tool and resource registers the operation on both surfaces, as pokemon_list does above. examples/pokeapi-override.yml is a runnable demo.
The gateway checks these declarations at startup.
- Config Entries: an unknown
operationId, a non-GETmethod, a required non-path parameter, or auri_templateoutside{name}://fails startup. So does aresourceentry withoutpromote_resources. - Spec Declarations: a spec-side
resourcewithoutpromote_resourcesonly logs a warning, and the operation stays a tool. - Subscriptions: not implemented, since REST has no native push.
Dynamic Exposure¶
exposure.style: dynamic puts a server's operations behind three meta-tools, which search, describe and call operations. It is set per server, so one process can serve GitHub dynamically beside a static PokéAPI. Dynamic Exposure explains the meta-tools and the ranking.
servers:
- name: github
spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
exposure:
style: dynamic
examples/github-dynamic.yml is a runnable config. exposure.promote_resources is refused under dynamic, where no operation becomes a resource. To have the model search before it calls, say so in the server's instructions, as Basics describes.
Tuning Search Weights¶
exposure.search.field_weights overrides the default weights per server, field by field. 0 leaves a field out of search:
servers:
- name: internal
spec: ./internal-api.yml
exposure:
style: dynamic
search:
field_weights:
# This spec's summaries are terse,
# and its descriptions say what each call does.
description: 2
Raise a field that describes operations well in your spec, and lower one that repeats boilerplate. To fix one operation that ranks poorly, rewrite its description through operations, since search reads the overridden text.
Searching by Meaning¶
exposure.search.semantic ranks by meaning rather than by shared words, through an embedding model. Install the embeddings extra, and set the provider's key in its usual variable, such as OPENAI_API_KEY:
servers:
- name: github
spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
exposure:
style: dynamic
search:
semantic:
# Or a local model, such as ollama:bge-m3.
model: openai:text-embedding-3-small
cache_directory: ~/.cache/openapi-mcp-gateway-embeddings
The model name, its key and the extra are checked at startup, and a problem fails startup. Keep the default retrieval: semantic unless users phrase requests in the spec's own words, and then set retrieval: hybrid, so exact word matches still count. Semantic Search explains when operations are embedded, how retrieval: hybrid merges rankings, and when search falls back to words.
The container image leaves the embeddings extra out, as Deployment notes.
Related¶
The concept page explains the meta-tools behind dynamic exposure, and the reference lists the per-operation resource keys.
- Concepts: Dynamic Exposure for the meta-tools and how search ranks operations and Search Ranking for how word search scores on literal and paraphrased requests
- Reference: Operation Fields for the
resourcekeys an override takes