Skip to content

API and MCP

Start the app with uv run app.py. Save this example to a UTF-8 Python file and run it with uv run example.py.

python
from gradio_client import Client, handle_file

client = Client("http://127.0.0.1:7860")
text, caption, seed = client.predict("01_夜の秘密", api_name="/apply_voice_preset")
audio, log = client.predict(
    text="また会えたわね。", caption=caption, seed_raw=seed,
    num_steps=16, seconds_raw="3", api_name="/generate",
)
next_audio, next_log = client.predict(
    text="今夜は少しだけ、私と話しましょう。", caption=caption,
    reference_audio=[handle_file(audio)], seed_raw=seed,
    num_steps=16, seconds_raw="5", api_name="/generate",
)
print(next_audio)

MCP connection

app.py launches with mcp_server=True. The usual endpoint is http://127.0.0.1:7860/gradio_api/mcp/sse; confirm it in the app's API information. Let your MCP client discover the Gradio tool schema.

Reference files use Gradio's upload format; the Python example uses handle_file. Another computer cannot reach your 127.0.0.1. This repository does not bundle a separate local stdio MCP server.

Generation parameters

num_steps defaults to 40. Blank seconds_raw predicts duration automatically; blank seed_raw selects a random seed. The generation API returns an audio file and a log.