Deploy an OpenAPI MCP Server with OCI Generative AI
Deploy an OpenAPI MCP server as an OCI Generative AI application. Then, create and activate a deployment, configure OAuth inbound authentication, and use the hosted MCP server from the OCI Responses API.
Overview
This tutorial uses the AWS Labs OpenAPI MCP Server as an example implementation of an OpenAPI-backed MCP server. The AWS Labs project dynamically creates MCP tools from OpenAPI specifications. In this tutorial, you adapt that use case for OCI Generative AI by deploying a containerized OpenAPI MCP server as an application, protecting the hosted endpoint with OAuth, and using the hosted MCP server from the OCI Responses API. If you use the AWS Labs implementation, follow its license and attribution requirements and ensure that the container exposes a remote Streamable HTTP endpoint on
0.0.0.0:8080.An OpenAPI MCP server is a service that turns an OpenAPI-described REST API into tools that an AI agent can call. OpenAPI describes the REST API operations, and Model Context Protocol (MCP) exposes those operations as callable tools.
In this tutorial, you deploy an OpenAPI MCP server as an OCI Generative AI application. The MCP server uses an OpenAPI specification, such as the Swagger Petstore API, to expose API operations as MCP tools. Then, you create and activate a deployment, protect the hosted endpoint with OAuth, and use the hosted MCP server from the OCI Responses API.
OpenAPI REST API -> MCP server tools -> OCI Generative AI application -> Responses API MCP Calling
OCI Generative AI provides applications and deployments for running containerized agent workloads.
- An application defines the managed runtime configuration, including scaling, storage, networking, and authentication.
- A deployment is a versioned release of an application based on a container image and image tag.
- An application can have several deployments, but only one deployment can be active at a time.
- The active deployment serves requests through the application endpoint.
Key tasks:
- Prepare an OpenAPI MCP server container image.
- Push the image to Oracle Cloud Infrastructure Registry.
- Configure OAuth inbound authentication with an OCI identity domain.
- Create an OCI Generative AI application.
- Create and activate a deployment.
- Use the hosted MCP server with OCI Responses API MCP Calling.
For background, see Hosted Applications and Deployments and Overview of Deploying Agents in OCI Generative AI.
Before You Begin
Complete the relevant setup in the QuickStart. At minimum, you need access to OCI Generative AI resources, a configured Responses API authentication method, the OCI Responses API endpoint, and a supported model in US Midwest (Chicago).
This tutorial uses the following values:
- Console region name: US Midwest (Chicago)
- Region identifier:
us-chicago-1 - Hosted-application endpoint:
https://application.generativeai.us-chicago-1.oci.oraclecloud.com/20251112/hostedApplications/
You also need:
- Permission to create and manage OCI
Generative AI applications and deployments. Your user group needs
manageaccess togenerative-ai-hosted-applicationandgenerativeaihosteddeployment, or togenerative-ai-family. See QuickStart Permissions for Users. - Runtime permissions for the hosted application to retrieve and validate the container image. Configure a dynamic group for OCI Generative AI applications and deployments, and grant it permission to read the OCIR repository and Vulnerability Scanning results. See For OCI Generative AI Applications.
- Permission to push container images to the OCIR repository. To push to an existing repository, you need
REPOSITORY_READandREPOSITORY_UPDATE. If you create the repository, you also needREPOSITORY_CREATE. See Policies to Control Repository Access. - Docker installed locally and an OCI auth token for signing in to OCIR. See Preparing for Container Registry.
- The AWS Labs OpenAPI MCP Server source configured to use the Swagger Petstore API. This tutorial uses
https://petstore3.swagger.io/api/v3as the API URL andhttps://petstore3.swagger.io/api/v3/openapi.jsonas the OpenAPI specification URL. The container must expose MCP over Streamable HTTP. - An OCIR repository in US Midwest (Chicago) for the container image. If you don't have one, see Creating a Repository.
- An active OCI identity domain in which you can create or manage a confidential application. Every tenancy includes a Default identity domain. You can use the Default identity domain or create another domain. See Managing Identity Domains and Step 1. Create an Identity Domain (Optional).
Inbound authentication controls client access to the hosted application endpoint. This tutorial uses identity domain bearer token authentication with an OCI IAM identity domain. For an overview of authentication methods for hosted applications, see Authentication. Responses API authentication is separate. The QuickStart authentication choices apply to calls to the OCI Responses API, not to inbound access for the hosted application endpoint.
If the OpenAPI MCP server implementation that you use runs as a local
stdio MCP server by default, use a container image or wrapper that exposes the MCP server as a remote Streamable HTTP endpoint on 0.0.0.0:8080.Outbound authentication controls how the deployed application accesses other OCI resources. Use IAM policies and resource principal access only if the deployed workload needs access to OCI resources.
1. Prepare the OpenAPI MCP Server Container
Prepare a container image that OCI Generative AI can run as an application deployment.
This tutorial uses the AWS Labs OpenAPI MCP Server with the Swagger Petstore API. Configure the server with the following values:
- API name:
petstore - API URL:
https://petstore3.swagger.io/api/v3 - OpenAPI specification URL:
https://petstore3.swagger.io/api/v3/openapi.json
The AWS Labs implementation uses
stdio transport by default. Use a container image or wrapper that exposes the server through a remote Streamable HTTP endpoint on 0.0.0.0:8080. A stdio-only server can't be used with this tutorial.2. Push the Image to OCIR
Make the MCP server image available to OCI Generative AI.
Before pushing the image, create or select an OCIR repository and ensure that you have permission to push images to it. You also need an OCI auth token. See Creating a Repository and Pushing Images Using the Docker CLI.
3. Configure OAuth Inbound Authentication
Create or configure an identity-domain confidential application that issues access tokens accepted by the hosted application.
An identity domain manages users, applications, and OAuth configuration. This tutorial uses a confidential application as both an OAuth resource server and client. You can use the tenancy's Default identity domain or another active identity domain. See Managing Identity Domains and Adding a Confidential Application.
4. Create an OCI Generative AI Application
5. Create and Activate a Deployment
Release the OCIR image as the active version of the application.
For more information, see Hosted Deployments.
6. Get an OAuth Access Token
Generate the token required to call the hosted application endpoint.
export IDCS_DOMAIN_URL="https://<your-domain>.identity.oraclecloud.com:443"
export IDCS_CLIENT_ID="<client-id>"
export IDCS_CLIENT_SECRET="<client-secret>"
export IDCS_SCOPE="https://application.generativeai.us-chicago-1.oci.oraclecloud.com/20251112/hostedApplications/invoke"
export HOSTED_APP_ACCESS_TOKEN=$(curl -s -X POST "${IDCS_DOMAIN_URL}/oauth2/v1/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=${IDCS_CLIENT_ID}" \
-d "client_secret=${IDCS_CLIENT_SECRET}" \
-d "scope=${IDCS_SCOPE}" | jq -r .access_token)HOSTED_APP_ACCESS_TOKEN contains a raw OAuth access token.
7. Use the Hosted MCP Server from the Responses API
Verify that OCI Generative AI can use tools exposed by the hosted MCP server.
Review the QuickStart Tools section. Under Add OpenAI Tools to OCI Responses API, expand MCP Calling.
MCP tools are executable functions or capabilities exposed by a remote MCP server. During a Responses API request, OCI Generative AI can communicate directly with the remote MCP server. MCP Calling supports Streamable HTTP. SSE is deprecated and unsupported.
Use allowed_tools when the application needs only a subset of tools exposed by the MCP server. Restricting tools can reduce unnecessary cost and latency. Server-side filtering controls what the MCP server exposes, and allowed_tools controls which exposed tools the Responses API request can use.
What You've Accomplished
You successfully:
- Prepared an OpenAPI MCP server container image.
- Pushed the image to OCIR.
- Configured OAuth inbound authentication.
- Created an OCI Generative AI application.
- Created and activated a deployment.
- Used the hosted MCP server from an OCI Responses API request.