File size: 967 Bytes
917f42b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr 
from primitives import tools 
from registry import get_tool_functions 

# Auto register gradio components 
with gr.Blocks() as demo:
    for name, func in get_tool_functions().items(): 
        component = tools.TOOL_COMPONENTS.get(name)

        if component:
            if component["is_gradio_api"]:
                gr.Markdown(
                    """
                    This tool is MCP-only, so it doesn't have UI. Have to access programmatically. 
                    """
                    )
                gr.api(
                    fn = func, 
                    api_name= name, 
                )
            else:
                gr.Interface(
                    fn = func, 
                    inputs= component["inputs"], 
                    outputs = component["outputs"], 
                    title= name
                )

if __name__ == "__main__":
    demo.launch(
        share= True, 
        mcp_server = True
    )