| import gradio as gr |
|
|
|
|
| |
| def my_tool(text: str) -> str: |
| """Process text. |
| |
| Args: |
| text: Input text |
| |
| Returns: |
| Processed text |
| """ |
| return text.upper() |
|
|
| |
| def bad_tool(text: str) -> str: |
| return text.upper() |
| |
| |
| def process_data(data: str, format: str = "json") -> str: |
| """Process data in specified format. |
| |
| Args: |
| data: Input data string |
| format: Output format (default: json) |
| |
| Returns: |
| Processed data as string |
| """ |
| return data |
|
|
| |
| def calculate(a: float, b: float, operation: str) -> float: |
| """Perform mathematical operation. |
| |
| Args: |
| a: First number |
| b: Second number |
| operation: Operation (add, subtract, multiply, divide) |
| |
| Returns: |
| Result of operation |
| """ |
| if operation == "add": |
| return a + b |
| |
|
|
| |
| def bad_function(data): |
| return data |
|
|
| |
| def also_bad(text: str) -> str: |
| return text.upper() |
|
|
| |
| def confusing(data: dict) -> list: |
| return [] |
|
|
| demo = gr.Interface(fn=my_tool, inputs="text", outputs="text") |
|
|
| if __name__ == "__main__": |
| demo.launch(mcp_server=True) |