Turn your Python functions into web services in minutes
Transform your Python functions into MCP (Model Context Protocol) servers with practical web interfaces. No web development skills required.
From this:
@mcp.tool()
def circle_area(radius: float) -> float:
"""Calculate the area of a circle."""
return math.pi * radius * radius
@mcp.tool()
def rectangle_area(width: float, height: float) -> float:
"""Calculate the area of a rectangle."""
return width * height
@mcp.tool()
def add_numbers(a: float, b: float) -> float:
"""Add two numbers together."""
return a + b
@mcp.tool()
def multiply_numbers(a: float, b: float) -> float:
"""Multiply two numbers."""
return a * b
- Install:
git clone https://github.com/juliensimon/gradio-mcp-server-builder.git
cd gradio-mcp-server-builder
pip install -r requirements.txt
- Create your functions:
@mcp.tool()
def greet_user(name: str) -> str:
"""Generate a friendly greeting message."""
return f"Hello, {name}! Welcome to your first MCP server!"
@mcp.tool()
def add_numbers(a: float, b: float) -> float:
"""Add two numbers together."""
return a + b
- Generate and run:
python main.py my_functions.py --preserve-docstrings
cd output && python server/gradio_server.py
- Open your browser: http://127.0.0.1:7860
That's it! Your functions are now a web service with a functional interface.
See the complete workflow:
Building an MCP server from Python functions
The generated Gradio server interface
MCP client interface showing available tools
Using the client to call a function
Terminal output showing the function execution
The builder generates everything you need:
- 🚀 MCP Server - Exposes your functions as callable tools
- 🌐 Gradio Interface - Practical web UI for testing and demonstration
- 📚 AI-generated docstrings - Enhanced function documentation
- 🧪 Test Client - For testing the server
- ⚙️ Configuration - Requirements and config files
The tool automatically:
- Parses your
@mcp.tool()
decorated functions - Generates an MCP server with validation and error handling
- Creates a responsive Gradio UI based on your function signatures
- Enhances function docstrings with AI
# Preserve original docstrings (don't enhance with AI)
python main.py functions.py --preserve-docstrings
# Specify output directory
python main.py functions.py --output-dir my_server
# Enable Gradio sharing (creates public URL)
python main.py functions.py --share
# Use a local Hugging Face model
python main.py functions.py --local-model "microsoft/DialoGPT-medium"
# Use an OpenAI-compatible endpoint
python main.py functions.py --model-endpoint http://localhost:8000
Check the input-samples/
directory for complete examples:
input-simple/
- Basic math and geometry functionsinput-hello-world/
- Minimal exampleinput-advanced/
- Complex data processing tasks
- Quick Start Guide - Step-by-step tutorial
- User Guide - Function format requirements
- Configuration Guide - Advanced configuration
./serve-docs.sh
Then visit http://127.0.0.1:8001
# Quick setup
./setup-dev.sh
# Or manual setup
pip install -r requirements-dev.txt
pre-commit install
# Fast tests (CI)
python -m pytest tests/ -v --ignore=tests/slow/
# Slow tests (local development)
./run-slow-tests.sh
The project uses pre-commit hooks for automatic code formatting and linting. See tests/slow/README.md for detailed testing information.
We welcome contributions! Please check existing issues before submitting changes.
Before submitting a pull request:
- Set up the development environment
- Ensure all pre-commit hooks pass
- Add tests for new functionality
- Update documentation as needed
This project is licensed under CC BY-NC 4.0. You're free to use it for personal and educational projects, but commercial use requires permission.
Ready to get started? Check out the Quick Start Guide for a detailed walkthrough.