Skip to content
7 changes: 7 additions & 0 deletions python/packages/core/agent_framework/declarative/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@
"DeclarativeLoaderError",
"DeclarativeWorkflowError",
"DefaultHttpRequestHandler",
"DefaultMCPToolHandler",
"ExternalInputRequest",
"ExternalInputResponse",
"HttpRequestHandler",
"HttpRequestInfo",
"HttpRequestResult",
"MCPToolApprovalRequest",
"MCPToolHandler",
"MCPToolInvocation",
"MCPToolResult",
"ProviderLookupError",
"ProviderTypeMapping",
"ToolApprovalRequest",
"ToolApprovalResponse",
"WorkflowFactory",
"WorkflowState",
]
Expand Down
14 changes: 14 additions & 0 deletions python/packages/core/agent_framework/declarative/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ from agent_framework_declarative import (
DeclarativeLoaderError,
DeclarativeWorkflowError,
DefaultHttpRequestHandler,
DefaultMCPToolHandler,
ExternalInputRequest,
ExternalInputResponse,
HttpRequestHandler,
HttpRequestInfo,
HttpRequestResult,
MCPToolApprovalRequest,
MCPToolHandler,
MCPToolInvocation,
MCPToolResult,
ProviderLookupError,
ProviderTypeMapping,
ToolApprovalRequest,
ToolApprovalResponse,
WorkflowFactory,
WorkflowState,
)
Expand All @@ -27,13 +34,20 @@ __all__ = [
"DeclarativeLoaderError",
"DeclarativeWorkflowError",
"DefaultHttpRequestHandler",
"DefaultMCPToolHandler",
"ExternalInputRequest",
"ExternalInputResponse",
"HttpRequestHandler",
"HttpRequestInfo",
"HttpRequestResult",
"MCPToolApprovalRequest",
"MCPToolHandler",
"MCPToolInvocation",
"MCPToolResult",
"ProviderLookupError",
"ProviderTypeMapping",
"ToolApprovalRequest",
"ToolApprovalResponse",
"WorkflowFactory",
"WorkflowState",
]
1 change: 1 addition & 0 deletions python/packages/declarative/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ YAML/JSON-based declarative agent and workflow definitions.
- **`WorkflowState`** - State management for declarative workflows
- **`ProviderTypeMapping`** - Maps provider types to implementations
- **`HttpRequestHandler`** / **`DefaultHttpRequestHandler`** - Pluggable HTTP transport for the `HttpRequestAction` declarative action (configured via `WorkflowFactory(http_request_handler=...)`)
- **`MCPToolHandler`** / **`DefaultMCPToolHandler`** - Pluggable MCP transport for the `InvokeMcpTool` declarative action (configured via `WorkflowFactory(mcp_tool_handler=...)`)
- **`DeclarativeLoaderError`** / **`ProviderLookupError`** / **`DeclarativeWorkflowError`** / **`DeclarativeActionError`** - Error types

## External Input Handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@
DeclarativeActionError,
DeclarativeWorkflowError,
DefaultHttpRequestHandler,
DefaultMCPToolHandler,
ExternalInputRequest,
ExternalInputResponse,
HttpRequestHandler,
HttpRequestInfo,
HttpRequestResult,
MCPToolApprovalRequest,
MCPToolHandler,
MCPToolInvocation,
MCPToolResult,
ToolApprovalRequest,
ToolApprovalResponse,
WorkflowFactory,
WorkflowState,
)
Expand All @@ -31,13 +38,20 @@
"DeclarativeLoaderError",
"DeclarativeWorkflowError",
"DefaultHttpRequestHandler",
"DefaultMCPToolHandler",
"ExternalInputRequest",
"ExternalInputResponse",
"HttpRequestHandler",
"HttpRequestInfo",
"HttpRequestResult",
"MCPToolApprovalRequest",
"MCPToolHandler",
"MCPToolInvocation",
"MCPToolResult",
"ProviderLookupError",
"ProviderTypeMapping",
"ToolApprovalRequest",
"ToolApprovalResponse",
"WorkflowFactory",
"WorkflowState",
"__version__",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
HTTP_ACTION_EXECUTORS,
HttpRequestActionExecutor,
)
from ._executors_mcp import (
MCP_ACTION_EXECUTORS,
InvokeMcpToolActionExecutor,
MCPToolApprovalRequest,
)
from ._executors_tools import (
FUNCTION_TOOL_REGISTRY_KEY,
TOOL_ACTION_EXECUTORS,
Expand All @@ -90,6 +95,12 @@
HttpRequestInfo,
HttpRequestResult,
)
from ._mcp_handler import (
DefaultMCPToolHandler,
MCPToolHandler,
MCPToolInvocation,
MCPToolResult,
)
from ._state import WorkflowState

__all__ = [
Expand All @@ -102,6 +113,7 @@
"EXTERNAL_INPUT_EXECUTORS",
"FUNCTION_TOOL_REGISTRY_KEY",
"HTTP_ACTION_EXECUTORS",
"MCP_ACTION_EXECUTORS",
"TOOL_ACTION_EXECUTORS",
"TOOL_APPROVAL_STATE_KEY",
"TOOL_REGISTRY_KEY",
Expand All @@ -126,6 +138,7 @@
"DeclarativeWorkflowError",
"DeclarativeWorkflowState",
"DefaultHttpRequestHandler",
"DefaultMCPToolHandler",
"EmitEventExecutor",
"EndConversationExecutor",
"EndWorkflowExecutor",
Expand All @@ -140,9 +153,14 @@
"HttpRequestResult",
"InvokeAzureAgentExecutor",
"InvokeFunctionToolExecutor",
"InvokeMcpToolActionExecutor",
"JoinExecutor",
"LoopControl",
"LoopIterationResult",
"MCPToolApprovalRequest",
"MCPToolHandler",
"MCPToolInvocation",
"MCPToolResult",
"QuestionExecutor",
"RequestExternalInputExecutor",
"ResetVariableExecutor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
)
from ._executors_external_input import EXTERNAL_INPUT_EXECUTORS
from ._executors_http import HTTP_ACTION_EXECUTORS, HttpRequestActionExecutor
from ._executors_mcp import MCP_ACTION_EXECUTORS, InvokeMcpToolActionExecutor
from ._executors_tools import TOOL_ACTION_EXECUTORS, InvokeFunctionToolExecutor
from ._http_handler import HttpRequestHandler
from ._mcp_handler import MCPToolHandler

logger = logging.getLogger(__name__)

Expand All @@ -55,6 +57,7 @@
**EXTERNAL_INPUT_EXECUTORS,
**TOOL_ACTION_EXECUTORS,
**HTTP_ACTION_EXECUTORS,
**MCP_ACTION_EXECUTORS,
}

# Action kinds that terminate control flow (no fall-through to successor)
Expand Down Expand Up @@ -90,6 +93,7 @@
"EmitEvent": ["event"],
"InvokeFunctionTool": ["functionName"],
"HttpRequestAction": ["url"],
"InvokeMcpTool": ["serverUrl", "toolName"],
}

# Alternate field names that satisfy required field requirements
Expand Down Expand Up @@ -135,6 +139,7 @@ def __init__(
validate: bool = True,
max_iterations: int | None = None,
http_request_handler: HttpRequestHandler | None = None,
mcp_tool_handler: MCPToolHandler | None = None,
):
"""Initialize the builder.

Expand All @@ -150,6 +155,9 @@ def __init__(
http_request_handler: Handler used to dispatch HttpRequestAction requests.
Must be supplied when the workflow contains any HttpRequestAction;
otherwise build raises ``DeclarativeWorkflowError``.
mcp_tool_handler: Handler used to dispatch InvokeMcpTool calls.
Must be supplied when the workflow contains any InvokeMcpTool;
otherwise build raises ``DeclarativeWorkflowError``.
"""
self._yaml_def = yaml_definition
self._workflow_id = workflow_id or yaml_definition.get("name", "declarative_workflow")
Expand All @@ -162,6 +170,7 @@ def __init__(
self._validate = validate
self._seen_explicit_ids: set[str] = set() # Track explicit IDs for duplicate detection
self._http_request_handler = http_request_handler
self._mcp_tool_handler = mcp_tool_handler
# Resolve max_iterations: explicit arg > YAML maxTurns > core default
resolved = max_iterations if max_iterations is not None else yaml_definition.get("maxTurns")
if resolved is not None and (not isinstance(resolved, int) or resolved <= 0):
Expand Down Expand Up @@ -481,6 +490,19 @@ def _create_executor_for_action(
id=action_id,
http_request_handler=self._http_request_handler,
)
elif kind == "InvokeMcpTool":
if self._mcp_tool_handler is None:
raise DeclarativeWorkflowError(
f"Workflow defines InvokeMcpTool '{action_id}' but no "
"mcp_tool_handler was supplied to WorkflowFactory. Pass "
"mcp_tool_handler=DefaultMCPToolHandler() (or a custom "
"implementation) to enable MCP tool invocations."
)
executor = InvokeMcpToolActionExecutor(
action_def,
id=action_id,
mcp_tool_handler=self._mcp_tool_handler,
)
else:
executor = executor_class(action_def, id=action_id)
self._executors[action_id] = executor
Expand Down
Loading
Loading