Skip to main content

Expose a REST API as MCP tools

Give a model a REST API's operations as MCP tools without writing an MCP server. You create an application of the OpenAPI to MCP type from the API's OpenAPI 3.x document, then add it to a Quick App. This guide is for app developers who have such a document. It assumes your administrator has deployed DIAL OpenAPI to MCP.

Prerequisites​

  • The OpenAPI to MCP application type registered in DIAL Core. Ask your administrator for its ID, such as https://dial.example.com/custom_application_schemas/openapi-to-mcp.
  • An OpenAPI 3.x document for the API, as JSON. The bridge rejects Swagger 2.0, so convert such a document first. The bridge's openapi_convert tool converts it.
  • An API that the bridge can reach over the network.
  • To create the application through the API: the DIAL Core URL, an API key, and your bucket ID. See Create a Quick App through the API.

Step 1: Prepare the document​

Give every operation an operationId, because each tool is named after it. This document, from the bridge's own example, produces one tool, listTodos:

{
"openapi": "3.0.0",
"info": { "title": "JSONPlaceholder TODO API", "version": "1.0.0" },
"servers": [{ "url": "https://jsonplaceholder.typicode.com" }],
"paths": {
"/todos": {
"get": {
"operationId": "listTodos",
"summary": "List all todos",
"responses": { "200": { "description": "Success" } }
}
}
}
}

To rename a tool or rewrite its description for the model, add x-mcp to the operation. The bridge reads name, description, and parameters.<name>.description:

"x-mcp": {
"name": "list_todos",
"description": "List every todo item, with its title and completion status."
}

Step 2: Create the application​

Create the application in DIAL Admin or through the API. Either way, set its properties:

PropertyDescription
openapiRequired. The document from Step 1, as a JSON object.
base_urlThe API's base URL. Set it even when the document has servers, so that the application decides where calls go.
extra_headersHeaders to add to every call, such as [{"name": "X-Client", "value": "dial"}]. The bridge rejects Authorization and other blocked names.
external_serviceThe ID of an external service on this application, for credentials. See Step 3.

In DIAL Admin. Open the OpenAPI to MCP Application Runner and create an application from it. Then set the properties in the application's Parameters.

Through the API. Save the application with PUT /v1/applications/{bucket}/{application-path}:

curl -X PUT "https://dial.example.com/v1/applications/${DIAL_BUCKET}/todo-api" \
-H "Content-Type: application/json" \
-H "api-key: ${DIAL_API_KEY}" \
-d '{
"displayName": "TODO API",
"description": "The JSONPlaceholder todo API as MCP tools.",
"applicationTypeSchemaId": "https://dial.example.com/custom_application_schemas/openapi-to-mcp",
"applicationProperties": {
"openapi": {
"openapi": "3.0.0",
"info": { "title": "JSONPlaceholder TODO API", "version": "1.0.0" },
"paths": {
"/todos": {
"get": {
"operationId": "listTodos",
"summary": "List all todos",
"responses": { "200": { "description": "Success" } }
}
}
}
},
"base_url": "https://jsonplaceholder.typicode.com"
}
}'

The application's ID is applications/<BUCKET>/todo-api.

Step 3: Add credentials​

Skip this step when the API needs no credentials, or only a fixed header that extra_headers can carry.

  1. Define an external service on the application, with its authentication settings. See External Services in DIAL Admin.
  2. Set the application's external_service property to the service's ID.

Each tool call then carries the caller's credential for that service. When a user hasn't signed in to the service yet, a Quick App asks them to sign in, then retries the call.

Note

In bridge 0.2.1, OAuth external services fail unless the administrator changes the bridge's header block list. See Credentials from external services.

Step 4: Check the tools​

Open the application in DIAL Admin. Its Tools overview lists the tools the bridge built, and lets you try them.

MCP clients reach the same tools through DIAL Core at POST /v1/deployments/<APPLICATION_ID>/mcp.

Step 5: Add the tools to a Quick App​

Add a dial-app Toolset to the Quick App's manifest:

{
"tool_sets": [
{
"type": "dial-app",
"name": "todos",
"deployment_id": "applications/<BUCKET>/todo-api",
"transport": "mcp"
}
]
}

With transport set to mcp, the Quick App fails at start if the application doesn't offer MCP, instead of calling it as a chat completion. Tool names start with the Toolset's name. To expose only some tools, list them in allowed_tools. See dial-app for every field.

Result​

The Quick App's model can call the API's operations. Each tool call becomes one HTTP request to the API, and the response returns as the tool result.

SymptomWhat to check
The application lists only openapi_verify and openapi_convertThe openapi property is empty.
Listing tools failsThe document must be OpenAPI 3.x, and every extra_headers name must be allowed. Ask your administrator for the bridge's log.
A tool call fails with "Sign-in required for external service"Sign in to the service when the Quick App asks, then retry.

Further reading​