AI Development

How do you turn an existing REST API into an MCP server with OpenAPI? On 18 November 2026 a QUERY operation has to be its own tool

About 16 min read

On 18 November 2026, npm package mcp-from-openapi 2.10.0 started validating Swagger 2.0 and OpenAPI 3.0, 3.1, and 3.2 with the rules of the version a document declares, and emitting JSON Schema 2020-12. An OpenAPI 3.2 QUERY is a method with a body, not the query string after GET. The model fills one object. The host sends HTTP.

Before you read

Object Public fact When an agent calls it
One operation operationId becomes the tool name. MCP 2026-07-28 says names should be 1 to 128 characters and use only letters, digits, underscore, hyphen, and dot. 2.10.0 truncates at 64 and hashes. That cap belongs to the library get and query on one path are two tools. Do not merge the call
inputSchema With no $schema, the protocol requires JSON Schema 2020-12. The field must not be null. For no parameters, the recommended schema is type object plus additionalProperties false, which accepts only an empty object OpenAPI 3.0 nullable: true becomes a type array. 3.1 and 3.2 schemas are already close to 2020-12
OpenAPI 3.2 3.2.0 on 19 September 2025 added query, additionalOperations, and in: querystring. 3.2.1 on 10 September 2026 says it has no significant new features. It clarifies encoding A QUERY filter lives in the body. querystring is the whole query string and cannot sit beside in: query
Credentials and errors OpenAPI says to ignore header parameters named Authorization, Accept, or Content-Type. 2.10.0 keeps security schemes on the host unless you set includeSecurityInInput. An upstream API failure goes in the tool result with isError true The model fills arguments. The host sends the request. A 404 is not a JSON-RPC error

The shop and order A-1042 are fictional. The JSON below follows published rules. It is not a captured call. Do not put credentials in tool arguments.

How does an existing REST API become an MCP tool an agent can call?

Start from an OpenAPI document. Turn each operation into one MCP tool. The protocol revision is 2026-07-28. The model does not read paths, and it does not pick the HTTP method. It fills the one object inputSchema describes.

  • One operation, one tool. operationId becomes name. With no operationId, derive a stable name from method and path. Names must be unique on one server. If two servers both expose search, the client should add a prefix. The spec says serverInfo.name is not unique across servers, so do not use it as the key.
  • Parameters become one object. Path, query, header, cookie, and a JSON body all land in inputSchema.properties. OpenAPI requires path parameters. Put the body under body so it does not collide with a parameter. A response schema can become outputSchema. That also defaults to 2020-12, and it is optional.
  • QUERY is its own tool. OpenAPI 3.2.0 added query on the Path Item for the QUERY method, which carries a body. It is not the same operation as get. 3.2.1 did not add another method.

The gateway steps that turn REST into a remote MCP server on Google Cloud are in the gateway steps that turn REST into a remote MCP server. The tools/call wire shape is in how a coding agent calls MCP. This page is the field mapping for any OpenAPI document, on any host.

After a GET becomes a tool, the model sees only this object

The two operations below are a fictional order API. openapi is 3.2.1 because that is the patch published on 10 September 2026. Which operations you expose is your document:

{
  "openapi": "3.2.1",
  "info": { "title": "Example Orders", "version": "1.0.0" },
  "paths": {
    "/orders/{orderId}": {
      "get": {
        "operationId": "lookup_order",
        "summary": "Read one order.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "One order. Host example A-1042." }
        }
      }
    },
    "/orders": {
      "query": {
        "operationId": "search_orders",
        "summary": "Search orders with a JSON body.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": ["open", "shipped"]
                  }
                },
                "required": ["status"],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Matching orders." }
        }
      }
    }
  }
}

This is the tool lookup_order becomes. annotations are hints. The 2026-07-28 schema says readOnlyHint defaults to false, and destructiveHint defaults to true. The second hint matters only when the tool is not read-only. A GET without the read-only hint looks like it changes data. Clients must treat hints from an untrusted server as untrusted:

{
  "name": "lookup_order",
  "title": "Read one order",
  "description": "The host sends GET /orders/{orderId}. Fill only this object.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "orderId": {
        "type": "string",
        "description": "Path segment. Example A-1042."
      }
    },
    "required": ["orderId"],
    "additionalProperties": false
  },
  "annotations": {
    "readOnlyHint": true,
    "openWorldHint": true
  }
}

The model fills arguments, for example orderId A-1042. The host then sends GET. An upstream 404 or 422 is an API failure. The protocol puts API failures and input-validation failures in the tool result with isError true, not in a JSON-RPC error. The model can change the next arguments. A schema is a gate. See why a schema is a gate. OpenAPI 3.0 nullable: true is not 2020-12. The 2.10.0 notes turn that into a type array, and turn example into examples. A nullable note becomes:

{
  "type": "object",
  "properties": {
    "note": { "type": ["string", "null"] }
  },
  "additionalProperties": false
}

When the fields are known, set additionalProperties: false. For a tool with no parameters, the spec recommends the same shape, which accepts only an empty object. Leave readOnly id and createdAt on the response. Remove them from the input and from required. If one schema describes both request and response, a leftover read-only id makes the model invent an id when it creates an order.

QUERY, a whole query string, and a shared name each stay separate

search_orders is not lookup_order plus a query parameter. The QUERY filter is in the body. In the tool, that body sits under body:

{
  "name": "search_orders",
  "description": "QUERY /orders. status is a JSON body, not a query string.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "body": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": ["open", "shipped"]
          }
        },
        "required": ["status"],
        "additionalProperties": false
      }
    },
    "required": ["body"],
    "additionalProperties": false
  }
}

in: querystring is a different field. In 3.2 it is the entire query string. It must use content, it may appear once, and it must not appear with in: query. Its name is not used in serialization. Split it into several query properties and the host will send a URL the document never described. The key of additionalOperations is the method as it will be sent, including case, such as LINK. Do not put POST or GET there. Those already have fixed fields.

The 2.10.0 notes list the 3.2 fields it reads: query, additionalOperations, in: querystring, style: cookie, streamed itemSchema, and security schemes named by URI. What it skips or ignores is recorded in getDiagnostics() instead of dropped. A QUERY entry in that diagnostic means search_orders is not in the tool list yet. When the path and the body both use id, the model cannot see a single id. The library's public example renames them to pathId and bodyId and gives the host a mapper. The model does not see the mapper. The object below is that host-side shape, not a field of tools/list:

{
  "inputSchema": {
    "type": "object",
    "properties": {
      "pathId": { "type": "string", "description": "Path. Example A-1042." },
      "bodyId": { "type": "string", "description": "Body field, also named id." }
    },
    "required": ["pathId", "bodyId"],
    "additionalProperties": false
  },
  "mapper": [
    { "inputKey": "pathId", "type": "path", "key": "id" },
    { "inputKey": "bodyId", "type": "body", "key": "id" }
  ]
}

An operation-level parameter overrides a path-level parameter with the same name and location. 2.10.0 states that rule. 3.2.1 also clarified forbidden encoding combinations, including an array or object on a cookie with style: form and explode: false. The model still fills an object. The host serializes it.

Six mappings, so the OpenAPI document is not handed to the model raw

A converter most often treats the two documents as one document in these six places:

In OpenAPI In the MCP tool
operationId name. summary can become title. description is for the model: what it does, when to use it, and what it does not do. Leave deprecated operations out.
parameters and requestBody One inputSchema whose type is object. The body sits under body. Path parameters go into required. An Authorization header does not become a property.
nullable: true A JSON Schema 2020-12 type array, such as string and null. 3.1 and 3.2 do not need this rewrite. With no $schema, the protocol means 2020-12.
readOnly / writeOnly Remove readOnly from the input and from required. Keep writeOnly on the input. Do not put it on outputSchema.
securitySchemes Host configuration. 2.10.0 leaves them out of the input by default. Leave includeSecurityInInput off. Do not put a sample key in the schema, including sk_demo_not_real.
responses A 2xx JSON object can be outputSchema. 4xx and 5xx are isError: true on the tool result. Do not disguise a streamed itemSchema as one finished object. 2.10.0 records it on metadata.responseStream.

The HTTP method can suggest a hint: mark GET read-only, and mark PUT and DELETE as changing data. Those hints are not safe by default. With no annotations, read-only is false and destructive is true. The host still decides permission. The hint does not.

Six steps before this REST API is handed to an agent

Do not reverse the order. Read the document version, then the tool list, and only then let the model fill arguments.

  1. Read the openapi field. On 3.0, rewrite nullable first. On 3.2, list query, querystring, and additionalOperations first. 3.2.1 only clarifies encoding. Do not treat it as a release that added methods.
  2. Each operationId that is not deprecated becomes one tool. The name stays stable, unique, and inside the character set the protocol recommends.
  3. Collapse the inputs into one object. Rename collisions and keep the mapper on the host. Drop Authorization. Remove readOnly from the input.
  4. Validate inputSchema as JSON Schema 2020-12. The root must be an object, not null. Close extra properties when the fields are known.
  5. The host sends HTTP. Credentials stay on the host. For an untrusted spec, do not allow a file-protocol $ref. The 2.10.0 notes say that reads any local file the process can read. By default it blocks internal addresses while resolving $ref.
  6. After a spec change, compare the tool list. A missing search_orders means QUERY was dropped. The diagnostic should say so. A tidy list of GETs does not.

The model fills JSON. The host performs the side effect. The schema bounds the shape. It does not stop the model from inventing an order id the document never had. A-1042 is only an example.

What you should check

These checks run in the browser. The document and the tool list are not uploaded:

  • Use Format to expand the OpenAPI document and the generated tool. Then use Schema validator on inputSchema: the root is an object, nullable is gone, and a nullable field is a type array.
  • Use JSONPath to pull operationId, parameters, and requestBody, then compare them with the tool properties. querystring should still be one value, not a set of split query parameters.
  • Use JSON Diff on two tools/list payloads. Stop if search_orders disappeared. Extra pathId and bodyId fields need a matching mapper on the host.
  • If a token shows up in a log or a sample, remove it with redaction before it goes into a ticket. Tool arguments were never the place for a credential.

A passing schema check only means the shape is 2020-12. It does not prove the host sends QUERY, and it does not prove the credential stayed on the server.

Common mistakes

  • Treating the whole OpenAPI document as one tool. The model will not pick a method from a path. One operation is one call.
  • Turning QUERY into a GET query string. The filter is in the body. Since 3.2.0 it is a different method.
  • Splitting querystring into several in: query parameters. The spec forbids both on the same operation or the same Path Item. name is not serialized.
  • Leaving nullable: true on inputSchema. With no $schema, the 2026-07-28 revision requires 2020-12. Clients must be able to validate at least that dialect.
  • Putting Authorization or an API key in properties, or turning on includeSecurityInInput. The model will write the value into the conversation. Do not put a sample key in the repository example either.
  • Treating annotations as permissions. Unset, read-only defaults to false and destructive defaults to true. If the hint comes from an untrusted server, the client must not use it as access control.

FAQ

Do you have to generate server code?

No. 2.10.0 returns tool definitions and buildHttpRequest, which applies the OpenAPI serialization table. You can also write the host yourself. The model still sees the same inputSchema.

What if the document is still OpenAPI 3.1?

Keep it. A 3.1 schema is already close to JSON Schema 2020-12. The nullable rewrite is for 3.0. QUERY, querystring, and additionalOperations arrived in 3.2.0 on 19 September 2025. 3.2.1 added no method.

Is this the same article as the Google Cloud one?

No. That page is API Gateway turning REST into a remote MCP server. This page is the field check every host has to do: one operation, one object, and QUERY as its own tool.

Is outputSchema required?

No. If you add one, it also defaults to 2020-12. A streamed response uses itemSchema. 2.10.0 records that on metadata.responseStream. Do not turn it into an object that pretends the stream already finished.

What if two servers both expose lookup_order?

The spec scopes name uniqueness to one server. A client that aggregates servers should add a prefix. Do not rely on serverInfo.name. The spec says it is not unique across servers.

Conclusion

After 18 November, a conversion that claims OpenAPI 3.2 support has to make QUERY its own tool and leave skipped fields in the diagnostic. inputSchema is one JSON Schema 2020-12 object.

The model fills that object. The host sends HTTP and keeps the credential. Validate the schema, then compare the tool list. If search_orders is missing, this REST API is not ready for an agent.

Further reading

Checked . First published. Sources: OpenAPI 3.2.0 (19 September 2025) and 3.2.1 (10 September 2026), the MCP 2026-07-28 Tools page and schema.ts, and the npm notes for mcp-from-openapi 2.10.0 (18 November 2026).