MinCPionS / app.py
KoRiF
improve data lifecycle
6791083
import gradio as gr
from typing import List, Dict, Any, Tuple
from toolset_semantics import search_suitable_tools, search_suitable_spaces, initialize_and_upload_to_vector_db
from hfspaces_tracking import update_database
def suitable_MCP_servers(task: str) -> List[Dict[str, Any]]:
"""
Looking for suitable MCP server for the given task.
Args:
task (str): The text description of the task
Returns:
List: A list of items that contains the info about the suitable MCP servers
"""
spaces = search_suitable_spaces(task)
return spaces
def suitable_MCP_tools(task: str, server: List[Dict[str, Any]]=None) -> List[Tuple[str, Dict[str, Any]]]:
"""
Looking for suitable tools for the given task
Args:
task (str): The text description of the task
Returns:
List: A list of items that contains the tool name and the info of its MCP server
"""
tools = search_suitable_tools(task)
return tools
# Create the Gradio interface
mcps_interface = gr.TabbedInterface(
[
gr.Interface(
fn=suitable_MCP_servers,
inputs=gr.Textbox(placeholder="Enter task for MCP server"),
outputs=gr.JSON(),
title="MCP servers",
description="List of suitable MCP servers",
api_name="mcp_servers"
),
gr.Interface(
fn=suitable_MCP_tools,
inputs=gr.Textbox(placeholder="Enter task for MCP tool"),
outputs=gr.JSON(),
title="MCP tools",
description="List of suitable MCP tools",
api_name="mcp_tools"
)
],
[
"MCP Servers",
"MCP Tools"
]
)
# Launch the interface and MCP server
if __name__ == "__main__":
if update_database():
initialize_and_upload_to_vector_db()
mcps_interface.launch(mcp_server=True)