diff --git a/llama-index-integrations/tools/llama-index-tools-mcp/llama_index/tools/mcp/utils.py b/llama-index-integrations/tools/llama-index-tools-mcp/llama_index/tools/mcp/utils.py index 6ef36b3dee..da28364fc4 100644 --- a/llama-index-integrations/tools/llama-index-tools-mcp/llama_index/tools/mcp/utils.py +++ b/llama-index-integrations/tools/llama-index-tools-mcp/llama_index/tools/mcp/utils.py @@ -103,11 +103,14 @@ def workflow_as_mcp( async def _workflow_tool(run_args: StartEventCLS, context: Context) -> Any: # Handle edge cases where the start event is an Event or a BaseModel # If the workflow does not have a custom StartEvent class, then we need to handle the event differently - context.session + if isinstance(run_args, Event) and workflow._start_event_class != StartEvent: handler = workflow.run(start_event=run_args) elif isinstance(run_args, BaseModel): handler = workflow.run(**run_args.model_dump()) + elif isinstance(run_args, dict): + start_event = StartEventCLS.model_validate(run_args) + handler = workflow.run(start_event=start_event) else: raise ValueError(f"Invalid start event type: {type(run_args)}") diff --git a/llama-index-integrations/tools/llama-index-tools-mcp/pyproject.toml b/llama-index-integrations/tools/llama-index-tools-mcp/pyproject.toml index ce2b294515..43b712ecb6 100644 --- a/llama-index-integrations/tools/llama-index-tools-mcp/pyproject.toml +++ b/llama-index-integrations/tools/llama-index-tools-mcp/pyproject.toml @@ -29,7 +29,7 @@ dev = [ [project] name = "llama-index-tools-mcp" -version = "0.2.4" +version = "0.2.5" description = "llama-index tools mcp integration" authors = [{name = "Chojan Shang", email = "psiace@outlook.com"}] requires-python = ">=3.10,<4.0"