From af92367a2abd148cc35c172d7cf1594938485fd0 Mon Sep 17 00:00:00 2001 From: Mandark-droid Date: Thu, 29 Jan 2026 12:58:41 +0530 Subject: [PATCH 1/2] Fix: Add share and server_port params to Toolset.launch() Add explicit share and server_port parameters to Toolset.launch() and launch_gradio_ui() for type hints and IDE autocompletion. --- toolsets/gradio_ui.py | 13 +++++++++++-- toolsets/toolset.py | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/toolsets/gradio_ui.py b/toolsets/gradio_ui.py index 5cb9e9c..e8468c9 100644 --- a/toolsets/gradio_ui.py +++ b/toolsets/gradio_ui.py @@ -28,13 +28,20 @@ StreamableHTTPSessionManager = None -def launch_gradio_ui(toolset: "Toolset", mcp_server: bool = False) -> None: +def launch_gradio_ui( + toolset: "Toolset", + mcp_server: bool = False, + share: bool | None = None, + server_port: int | None = None, +) -> None: """ Launch the Gradio UI for the toolset. Args: toolset: The Toolset instance to create the UI for. mcp_server: If True, create and integrate the MCP server. Defaults to False. + share: If True, creates a publicly accessible link. Defaults to None (False). + server_port: The port to bind the server to. Defaults to None (7860). """ toolset._get_tool_data() if toolset._verbose: @@ -200,7 +207,9 @@ def get_mcp_info(request: gr.Request): except ImportError: pass - demo.launch(css=css, footer_links=["settings"]) + demo.launch( + css=css, footer_links=["settings"], share=share, server_port=server_port + ) def _get_complete_schema(toolset: "Toolset", request: Request) -> JSONResponse: diff --git a/toolsets/toolset.py b/toolsets/toolset.py index 5a4754e..dda1736 100644 --- a/toolsets/toolset.py +++ b/toolsets/toolset.py @@ -279,7 +279,12 @@ def _search_deferred_tools( return results - def launch(self, mcp_server: bool = False): + def launch( + self, + mcp_server: bool = False, + share: bool | None = None, + server_port: int | None = None, + ): """ Launch the Gradio UI for this toolset. @@ -290,6 +295,9 @@ def launch(self, mcp_server: bool = False): mcp_server: If True, creates and integrates an MCP server that exposes all tools through the MCP protocol at the `/gradio_api/mcp` endpoint. The MCP server can be accessed by MCP clients for programmatic tool usage. Defaults to False. + share: If True, creates a publicly accessible link for the Gradio UI. + Defaults to None (False). + server_port: The port to bind the server to. Defaults to None (7860). Examples: >>> from toolsets import Server, Toolset @@ -297,10 +305,14 @@ def launch(self, mcp_server: bool = False): >>> t.add(Server("gradio/mcp_tools")) >>> t.launch() # UI only >>> t.launch(mcp_server=True) # UI + MCP server + >>> t.launch(mcp_server=True, share=True) # With public link + >>> t.launch(server_port=8080) # Custom port Note: When mcp_server=True, the MCP server endpoint is available at `http://localhost:7860/gradio_api/mcp` (or the appropriate host/port). Connection details are shown in the "MCP Info" tab of the UI. """ - launch_gradio_ui(self, mcp_server=mcp_server) + launch_gradio_ui( + self, mcp_server=mcp_server, share=share, server_port=server_port + ) From 715a4e805047fe2b7c9eb3e7b417b013cdf75e77 Mon Sep 17 00:00:00 2001 From: gradio-pr-bot Date: Mon, 23 Feb 2026 21:43:10 +0000 Subject: [PATCH 2/2] add changeset --- .changeset/giant-pandas-cut.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/giant-pandas-cut.md diff --git a/.changeset/giant-pandas-cut.md b/.changeset/giant-pandas-cut.md new file mode 100644 index 0000000..d9d7d23 --- /dev/null +++ b/.changeset/giant-pandas-cut.md @@ -0,0 +1,5 @@ +--- +"toolsets": minor +--- + +feat:Fix: Pass launch kwargs to Gradio's demo.launch()