feat: wrap FastMCP tools as AskUI Tool via Tool.from_mcp_tool#250
Open
mlikasam-askui wants to merge 2 commits intomainfrom
Open
feat: wrap FastMCP tools as AskUI Tool via Tool.from_mcp_tool#250mlikasam-askui wants to merge 2 commits intomainfrom
mlikasam-askui wants to merge 2 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Tool.from_mcp_tool()so a FastMCPToolcan be used as an AskUIToolin the same flows as hand-written tools (for exampleToolCollection). Name, description, and JSON schema come from the FastMCP tool; execution delegates to its callable.What changed
Tool.from_mcp_tool(mcp_tool, name_prefix=None)— factory that returns an adapter implementing AskUI’sToolcontract._McpToolAdapter— forwards__call__tomcp_tool.fn, with optionalname_prefixon the exposed tool name._convert_from_mcp_tool_call_resultmaps return values to AskUI-friendly primitives:str— unchangedMcpTextContent— textMcpImageContent— PIL image viabase64_to_imagelist/tupleof the above — same structure, items converted per elementMcpToolAdapterException— raised when the wrapped tool returns an unsupported type or has no callable, with the tool name included for debugging.Usage
Notes
Tool.to_mcp_tool()for the opposite direction (AskUI → FastMCP).