Spaces:
Sleeping
Sleeping
SURIAPRAKASH1
commited on
Commit
·
917f42b
1
Parent(s):
9231ab5
gradio + mcp implementation
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from primitives import tools
|
| 3 |
+
from registry import get_tool_functions
|
| 4 |
+
|
| 5 |
+
# Auto register gradio components
|
| 6 |
+
with gr.Blocks() as demo:
|
| 7 |
+
for name, func in get_tool_functions().items():
|
| 8 |
+
component = tools.TOOL_COMPONENTS.get(name)
|
| 9 |
+
|
| 10 |
+
if component:
|
| 11 |
+
if component["is_gradio_api"]:
|
| 12 |
+
gr.Markdown(
|
| 13 |
+
"""
|
| 14 |
+
This tool is MCP-only, so it doesn't have UI. Have to access programmatically.
|
| 15 |
+
"""
|
| 16 |
+
)
|
| 17 |
+
gr.api(
|
| 18 |
+
fn = func,
|
| 19 |
+
api_name= name,
|
| 20 |
+
)
|
| 21 |
+
else:
|
| 22 |
+
gr.Interface(
|
| 23 |
+
fn = func,
|
| 24 |
+
inputs= component["inputs"],
|
| 25 |
+
outputs = component["outputs"],
|
| 26 |
+
title= name
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
demo.launch(
|
| 31 |
+
share= True,
|
| 32 |
+
mcp_server = True
|
| 33 |
+
)
|