feat: add draft step capability helper

This commit is contained in:
lda
2026-06-26 19:45:24 +07:00 Verified
parent be3e21d9e8
commit 4987409473
22 changed files with 1627 additions and 0 deletions
+33
View File
@@ -265,6 +265,39 @@ class BindOutputToStateRequest(BaseModel):
)
class AddStepFromCapabilityRequest(BaseModel):
"""Typed MCP request for adding one capability-backed draft step with wiring."""
workspace_id: WorkspaceId
revision: int = Field(ge=1, description="Expected workspace revision.")
step_id: str = Field(description="New draft step id.")
capability_name: str = Field(description="Qualified capability name.")
route_from_step: str | None = Field(
default=None,
description="Optional existing step whose outcome should route to the new step.",
)
route_from_outcome: str = Field(
default="ok",
description="Outcome on route_from_step that should route to the new step.",
)
route_outcome: str = Field(
default="ok",
description="Outcome emitted by the new step.",
)
route_to: str = Field(
default="__end__",
description="Target step id or __end__ for the new step outcome.",
)
input_map: dict[str, str] = Field(
default_factory=dict,
description="Graph source path to node-local target field.",
)
bind_outputs: dict[str, str] = Field(
default_factory=dict,
description="Node-local output field to state path with schema projection.",
)
class DeleteDraftWorkspaceRequest(BaseModel):
"""Typed MCP request payload for deleting one draft workspace."""
+27
View File
@@ -13,6 +13,7 @@ from wf_mcp.broker.service.workflow_operation_context import context_from_servic
from .models import (
AddStateFromOutputRequest,
AddStepFromCapabilityRequest,
BindOutputToStateRequest,
CallCapabilityResult,
CreateArtifactFromWorkspaceRequest,
@@ -483,6 +484,32 @@ def register_workflow_tools(server: FastMCP[Any], service: WfMcpService) -> None
)
)
@server.tool(
name="wf.workflow.add_step_from_capability",
title="Add Step From Capability",
description=(
"Add one capability-backed draft step with explicit route, input, "
"and output-to-state binding hints."
),
)
async def add_step_from_capability(
request: AddStepFromCapabilityRequest,
) -> DraftWorkspaceResult:
return DraftWorkspaceResult.model_validate(
await handlers.add_step_from_capability(
workspace_id=request.workspace_id,
revision=request.revision,
step_id=request.step_id,
capability_name=request.capability_name,
route_from_step=request.route_from_step,
route_from_outcome=request.route_from_outcome,
route_outcome=request.route_outcome,
route_to=request.route_to,
input_map=request.input_map,
bind_outputs=request.bind_outputs,
)
)
@server.tool(
name="wf.workflow.create_minimal_draft_workspace",
title="Create Minimal Draft Workspace",