Spaces:
Runtime error
Runtime error
phil71x
commited on
Commit
·
7b9f1bd
1
Parent(s):
ea687f2
docs: Clarify the process of "automatic" schema generation in MCP tools with Gradio
Browse files- docs/01_mcp_server.md +6 -0
docs/01_mcp_server.md
CHANGED
@@ -105,6 +105,12 @@ Gradio significantly simplifies exposing a Python function as an MCP tool:
|
|
105 |
* **Description**: Taken from the function's docstring.
|
106 |
* **Input Schema**: Inferred from the `inputs` argument of `gr.Interface` and the function's type hints and `Args` section in the docstring.
|
107 |
* **Output Schema**: Inferred from the `outputs` argument of `gr.Interface` and the function's return type hint and `Returns` section in the docstring.
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
3. **MCP Endpoint**: Gradio hosts the MCP service at a specific path (usually `/gradio_api/mcp/sse` relative to the base URL), handling the JSON-RPC communication required by MCP.
|
109 |
|
110 |
## 6. Conclusion for Part 1
|
|
|
105 |
* **Description**: Taken from the function's docstring.
|
106 |
* **Input Schema**: Inferred from the `inputs` argument of `gr.Interface` and the function's type hints and `Args` section in the docstring.
|
107 |
* **Output Schema**: Inferred from the `outputs` argument of `gr.Interface` and the function's return type hint and `Returns` section in the docstring.
|
108 |
+
|
109 |
+
> **A Note on "Automatic" Schema Generation:**
|
110 |
+
> It's important to clarify what "automatic" means here. You, the developer, manually write your Python function (like `sentiment_analysis`) with its descriptive docstrings and type hints. You also manually define the `gr.Interface` and specify its `inputs` and `outputs` components.
|
111 |
+
>
|
112 |
+
> Gradio's "automatic" role is to then *interpret* all this information you've provided. It takes your Python function's definition, your docstrings, your type hints, and your `gr.Interface` configuration, and from these, it **automatically constructs the formal, standardized JSON schema that the Model Context Protocol (MCP) requires.** You don't have to write this detailed MCP-specific schema yourself; Gradio generates it for you, acting as a bridge between your Python code and the MCP standard.
|
113 |
+
|
114 |
3. **MCP Endpoint**: Gradio hosts the MCP service at a specific path (usually `/gradio_api/mcp/sse` relative to the base URL), handling the JSON-RPC communication required by MCP.
|
115 |
|
116 |
## 6. Conclusion for Part 1
|