fix mcp issue
Browse files768 unmodified lines769770771772773774319 unmodified lines109410951096109710981099750 unmodified lines185018511852185318541855768 unmodified lines- FlashAttention-3 works on H200 hardware via kernels library- Dynamic shapes add flexibility for variable input sizes## Complete Gradio API ReferenceThis reference is automatically synced from https://www.gradio.app/llms.txt to ensure accuracy.319 unmodified lines- FlashAttention-3 works on H200 hardware via kernels library- Dynamic shapes add flexibility for variable input sizes## Complete Gradio API ReferenceThis reference is automatically synced from https://www.gradio.app/llms.txt to ensure accuracy.750 unmodified lines- Preserve all performance optimizations- Add ZeroGPU decorators for new GPU-dependent functionsIMPORTANT: Always ensure "Built with anycoder" appears as clickable text in the header/top section linking to https://huggingface.co/spaces/akhaliq/anycoder - if it's missing from the existing code, add it; if it exists, preserve it.CRITICAL: For imported spaces that lack anycoder attribution, you MUST add it as part of your modifications. Add it to the header/navigation area as clickable text linking to https://huggingface.co/spaces/akhaliq/anycoder"""768 unmodified lines769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886319 unmodified lines1206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323750 unmodified lines207420752076207720782079208020812082208320842085208620872088768 unmodified lines- FlashAttention-3 works on H200 hardware via kernels library- Dynamic shapes add flexibility for variable input sizes## MCP Server IntegrationWhen the user requests an MCP-enabled Gradio app or asks for tool calling capabilities, you MUST enable MCP server functionality.**🚨 CRITICAL: Enabling MCP Server**To make your Gradio app function as an MCP (Model Control Protocol) server:1. Set `mcp_server=True` in the `.launch()` method2. Add `"gradio[mcp]"` to requirements.txt (not just `gradio`)3. Ensure all functions have detailed docstrings with proper Args sections4. Use type hints for all function parameters**Example:**```pythonimport gradio as grdef letter_counter(word: str, letter: str) -> int:\"\"\"Count the number of occurrences of a letter in a word or text.Args:word (str): The input text to search throughletter (str): The letter to search forReturns:int: The number of times the letter appears\"\"\"return word.lower().count(letter.lower())demo = gr.Interface(fn=letter_counter,inputs=[gr.Textbox("strawberry"), gr.Textbox("r")],outputs=[gr.Number()],title="Letter Counter",description="Count letter occurrences in text.")if __name__ == "__main__":demo.launch(mcp_server=True)```**When to Enable MCP:**- User explicitly requests "MCP server" or "MCP-enabled app"- User wants tool calling capabilities for LLMs- User mentions Claude Desktop, Cursor, or Cline integration- User wants to expose functions as tools for AI assistants**MCP Requirements:**1. **Dependencies:** Always use `gradio[mcp]` in requirements.txt (not plain `gradio`)2. **Docstrings:** Every function must have a detailed docstring with:- Brief description on first line- Args section listing each parameter with type and description- Returns section (optional but recommended)3. **Type Hints:** All parameters must have type hints (e.g., `word: str`, `count: int`)4. **Default Values:** Use default values in components to provide examples**Best Practices for MCP Tools:**- Use descriptive function names (they become tool names)- Keep functions focused and single-purpose- Accept string parameters when possible for better compatibility- Return simple types (str, int, float, list, dict) rather than complex objects- Use gr.Header for authentication headers when needed- Use gr.Progress() for long-running operations**Multiple Tools Example:**```pythonimport gradio as grdef add_numbers(a: str, b: str) -> str:\"\"\"Add two numbers together.Args:a (str): First numberb (str): Second numberReturns:str: Sum of the two numbers\"\"\"return str(int(a) + int(b))def multiply_numbers(a: str, b: str) -> str:\"\"\"Multiply two numbers.Args:a (str): First numberb (str): Second numberReturns:str: Product of the two numbers\"\"\"return str(int(a) * int(b))with gr.Blocks() as demo:gr.Markdown("# Math Tools MCP Server")with gr.Tab("Add"):gr.Interface(add_numbers, [gr.Textbox("5"), gr.Textbox("3")], gr.Textbox())with gr.Tab("Multiply"):gr.Interface(multiply_numbers, [gr.Textbox("4"), gr.Textbox("7")], gr.Textbox())if __name__ == "__main__":demo.launch(mcp_server=True)```**REMEMBER:** If MCP is requested, ALWAYS:1. Set `mcp_server=True` in `.launch()`2. Use `gradio[mcp]` in requirements.txt3. Include complete docstrings with Args sections4. Add type hints to all parameters## Complete Gradio API ReferenceThis reference is automatically synced from https://www.gradio.app/llms.txt to ensure accuracy.319 unmodified lines- FlashAttention-3 works on H200 hardware via kernels library- Dynamic shapes add flexibility for variable input sizes## MCP Server IntegrationWhen the user requests an MCP-enabled Gradio app or asks for tool calling capabilities, you MUST enable MCP server functionality.**🚨 CRITICAL: Enabling MCP Server**To make your Gradio app function as an MCP (Model Control Protocol) server:1. Set `mcp_server=True` in the `.launch()` method2. Add `"gradio[mcp]"` to requirements.txt (not just `gradio`)3. Ensure all functions have detailed docstrings with proper Args sections4. Use type hints for all function parameters**Example:**```pythonimport gradio as grdef letter_counter(word: str, letter: str) -> int:\"\"\"Count the number of occurrences of a letter in a word or text.Args:word (str): The input text to search throughletter (str): The letter to search forReturns:int: The number of times the letter appears\"\"\"return word.lower().count(letter.lower())demo = gr.Interface(fn=letter_counter,inputs=[gr.Textbox("strawberry"), gr.Textbox("r")],outputs=[gr.Number()],title="Letter Counter",description="Count letter occurrences in text.")if __name__ == "__main__":demo.launch(mcp_server=True)```**When to Enable MCP:**- User explicitly requests "MCP server" or "MCP-enabled app"- User wants tool calling capabilities for LLMs- User mentions Claude Desktop, Cursor, or Cline integration- User wants to expose functions as tools for AI assistants**MCP Requirements:**1. **Dependencies:** Always use `gradio[mcp]` in requirements.txt (not plain `gradio`)2. **Docstrings:** Every function must have a detailed docstring with:- Brief description on first line- Args section listing each parameter with type and description- Returns section (optional but recommended)3. **Type Hints:** All parameters must have type hints (e.g., `word: str`, `count: int`)4. **Default Values:** Use default values in components to provide examples**Best Practices for MCP Tools:**- Use descriptive function names (they become tool names)- Keep functions focused and single-purpose- Accept string parameters when possible for better compatibility- Return simple types (str, int, float, list, dict) rather than complex objects- Use gr.Header for authentication headers when needed- Use gr.Progress() for long-running operations**Multiple Tools Example:**```pythonimport gradio as grdef add_numbers(a: str, b: str) -> str:\"\"\"Add two numbers together.Args:a (str): First numberb (str): Second numberReturns:str: Sum of the two numbers\"\"\"return str(int(a) + int(b))def multiply_numbers(a: str, b: str) -> str:\"\"\"Multiply two numbers.Args:a (str): First numberb (str): Second numberReturns:str: Product of the two numbers\"\"\"return str(int(a) * int(b))with gr.Blocks() as demo:gr.Markdown("# Math Tools MCP Server")with gr.Tab("Add"):gr.Interface(add_numbers, [gr.Textbox("5"), gr.Textbox("3")], gr.Textbox())with gr.Tab("Multiply"):gr.Interface(multiply_numbers, [gr.Textbox("4"), gr.Textbox("7")], gr.Textbox())if __name__ == "__main__":demo.launch(mcp_server=True)```**REMEMBER:** If MCP is requested, ALWAYS:1. Set `mcp_server=True` in `.launch()`2. Use `gradio[mcp]` in requirements.txt3. Include complete docstrings with Args sections4. Add type hints to all parameters## Complete Gradio API ReferenceThis reference is automatically synced from https://www.gradio.app/llms.txt to ensure accuracy.750 unmodified lines- Preserve all performance optimizations- Add ZeroGPU decorators for new GPU-dependent functions**MCP Server Support:**- If the user requests MCP functionality or tool calling capabilities:1. Add `mcp_server=True` to the `.launch()` method if not present2. Ensure `gradio[mcp]` is in requirements.txt (not just `gradio`)3. Add detailed docstrings with Args sections to all functions4. Add type hints to all function parameters- Preserve existing MCP configurations if already present- When adding new tools, follow MCP docstring format with Args and Returns sectionsIMPORTANT: Always ensure "Built with anycoder" appears as clickable text in the header/top section linking to https://huggingface.co/spaces/akhaliq/anycoder - if it's missing from the existing code, add it; if it exists, preserve it.CRITICAL: For imported spaces that lack anycoder attribution, you MUST add it as part of your modifications. Add it to the header/navigation area as clickable text linking to https://huggingface.co/spaces/akhaliq/anycoder"""
app.py+233