MCP Hub
Back to servers

API as MCP

Converts REST APIs into MCP tools using Gradio, specifically demonstrating integration with a local IBM Granite model running on Ollama.

Tools
1
Updated
Jul 3, 2025

Project Title

Turn your REST APIs to an MCP server

Description

This sample runs a IBM Granite model using ollama locally. The code uses gradio to expose an MCP server with a tool to call the POST API and get the response in JSON

Getting Started

Dependencies

Test

curl -XPOST -H "Content-Type: application/json" http://localhost:11434/v1/chat/completions -d '{"model": "granite3.2:8b", "messages": [{"role": "users", "content": "How are you today?"}]}'

Executing program

python -m venv apiasmcp
source apiasmcp/bin/activate
pip install -r requirements.txt
export GRADIO_MCP_SERVER=True
python app.py

Access locally

Open http://localhost:7860 in your browser Enter some text and click “Submit” You should see the results

Test

Add it to an MCP client

Visit http://localhost:7860/gradio_api/mcp/schema This shows the MCP tool schema that clients will use You can also find this in the “View API” link in the footer of your Gradio app Add this JSON BLOB to your MCP client:

{
  "mcpServers": {
    "gradio": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:7860/gradio_api/mcp/sse"
      ]
    }
  }
}

For example in cursor mcp client, you should see as below

Cursor

Reviews

No reviews yet

Sign in to write a review