Spaces:
Sleeping
Sleeping
| import random | |
| import gradio as gr | |
| def driver_championship_score(driver_name: str) -> str: | |
| """ | |
| Get the championship score for the given driver. | |
| Args: | |
| driver_name (str): The driver's name | |
| Returns: | |
| int: The driver's championship score | |
| """ | |
| return f"Driver {driver_name} has {random.randint(0, 100)} championship points" | |
| def driver_position(driver_name: str) -> str: | |
| """ | |
| Get the current position of the given driver. | |
| Args: | |
| driver_name (str): The driver's name | |
| Returns: | |
| str: The driver's current position | |
| """ | |
| return f"Driver {driver_name} is in position {random.randint(1, 20)}" | |
| # Create interfaces for each tool | |
| iface1 = gr.Interface( | |
| fn=driver_championship_score, | |
| inputs="text", | |
| outputs="text", | |
| title="[Dummy] Driver Championship Score" | |
| ) | |
| iface2 = gr.Interface( | |
| fn=driver_position, | |
| inputs="text", | |
| outputs="text", | |
| title="[Dummy] Driver Position" | |
| ) | |
| # Combine into tabs into server | |
| gradio_server = gr.TabbedInterface( | |
| [iface1, iface2], | |
| tab_names=["Driver Championship Score", "Driver Position"], | |
| title="Formula 1 MCP server" | |
| ) | |
| # Launch the interface and MCP server | |
| if __name__ == "__main__": | |
| gradio_server.launch(mcp_server=True) |