Cloud Native 10 min read

Turn Existing OpenAPI Specs into AI‑Ready MCP Tools with Higress

This guide explains how to convert legacy OpenAPI schemas into Model Context Protocol (MCP) configurations, route them through the Higress cloud‑native gateway, set up dual authentication, and finally expose the MCP tools to AI platforms such as Dify, enabling seamless AI‑driven access to both local and internet data sources.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Turn Existing OpenAPI Specs into AI‑Ready MCP Tools with Higress

Background – Anthropic released the Model Context Protocol (MCP) in November 2024 to provide a unified interaction model that bridges large language models (LLMs) with heterogeneous data sources and tools, eliminating data silos.

Problem – Enterprises often have many existing OpenAPI specifications that are not directly callable by AI assistants. The challenge is to transform these OpenAPI definitions into MCP tools that AI platforms like Dify can invoke.

Solution Overview – Use the Higress cloud‑native gateway to (1) convert OpenAPI schemas to MCP configurations, (2) route requests to the original APIs, (3) implement dual authentication, (4) connect the MCP tools to AI assistants, and (5) fine‑tune prompts for optimal performance.

Step‑by‑Step Implementation

Convert OpenAPI Schema to MCP – Extract key information (paths, methods, parameters, responses) from the OpenAPI JSON/YAML and generate an MCP YAML using the openapi‑to‑mcp tool provided by Higress.

Configure Higress Routing – Create a ConfigMap with global MCP server settings, add a service source for each legacy API, and define a route that injects the generated MCP YAML.

Dual Authentication –

Higress ↔︎ Backend API authentication (e.g., API keys, OAuth).

User ↔︎ Higress SSE endpoint authentication via Consumer Management (KeyAuth example).

Expose MCP Tool in Dify – Deploy Dify (or use the Compute Nest one‑click deployment), install the “SSE Discovery and Call MCP Tool” plugin, paste the MCP server configuration, and create an agent that calls the MCP endpoint with a chosen model (e.g., QWEN‑MAX).

Prompt Optimization – Use Go templates and GJSON expressions in Higress to refine request/response payloads, and manually adjust prompts if the model misinterprets the MCP schema.

Example: Gaode Maps API – The article walks through converting a Gaode Maps OpenAPI definition into an MCP tool, configuring routing, adding required headers (e.g., Authorization: Bearer xxx), and invoking the tool from Dify to retrieve geographic data.

Key Configuration Snippets

{
  "amap-maps": {
    "headers": {
      "Authorization": "Bearer xxx"
    },
    "transport": "sse",
    "url": "http://12xx.94:8080/amap-maps/sse"
  }
}

Images

Conclusion – By leveraging MCP and Higress, organizations can instantly expose legacy APIs to AI assistants, achieving true “everything‑connected” AI applications across devices, cloud resources, and third‑party services.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

MCPOpenAPIHigress
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.