Skip to content

feat(mcp): ask the server to watch a Remote server's task [PRODEV-2009] - #2032

Open
alessandromuresan wants to merge 1 commit into
mainfrom
feat/mcp-remote-uipath-tasks
Open

alessandromuresan wants to merge 1 commit into
mainfrom
feat/mcp-remote-uipath-tasks

Conversation

@alessandromuresan

@alessandromuresan alessandromuresan commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

The SDK part of suspending on a Remote MCP server's task, for coded agents. Server side: UiPath/AgentHubService#2544. Low-code agents: UiPath/uipath-langchain-python#1253. Jira: PRODEV-2009.

Why

A Remote MCP server's upstream can answer a tool call with a task of its own. No Orchestrator job is behind it, so McpTask.job is empty and a caller has nothing to suspend on. AgentHub can watch such a task and wake the caller's job through an API trigger, but the caller has to ask for that on a tasks/get, and McpService.get_task could not send it.

What changed

  • McpService.watch_task(task, job_key=…, folder_key=…) (and watch_task_async). One tasks/get that also asks the server to watch the task for the job named. It returns the task as get_task does.
  • McpTask.api_trigger: set when the server annotated a working task with an Api resume trigger, with its suspend_after_ms.
  • McpTask.watch: the watch the server started, from a watch_task reply: watch_id and expires_in_ms. None when the reply names none or one that cannot be used.
  • call_tool(..., resume_trigger_types=…) (and call_tool_async). The trigger kinds declared to the server. The default stays ["Job"]; a caller that can suspend through a watch passes ["Job", "Api"].

Nothing changes for an existing caller: the default declaration is the same, and get_task sends what it sent before.

How it is used

outcome = sdk.mcp.call_tool("remote-server", "research", resume_trigger_types=["Job", "Api"])
task = outcome.task
if task and task.api_trigger:
    watched = sdk.mcp.watch_task(task, job_key=my_job_key, folder_key=my_folder_key)
    if watched.watch:
        # suspend on an API trigger whose request is
        # {"com.uipath/task": {"watchId": watched.watch.watch_id}}
        # and on a timer for watched.watch.expires_in_ms
        ...

The suspend itself is uipath-langchain's; it will call this from call_mcp_tool once this version is released.

Testing

  • packages/uipath-platform/tests/services: all pass (4 skipped, live LLM tests with no credentials). New: TestMcpTaskWatch, 21 tests — the two new properties and what they refuse, the declaration on call_tool, the request watch_task sends (sync and async), and that an ordinary poll is unchanged.
  • ruff and mypy are clean.
  • Run end to end on an Automation Suite test environment (27 Nov): AgentHub at this PR's image with McpRemoteUiPathTasks on, a real Orchestrator, a Remote server over an in-cluster upstream that answers research with a 150-second task, and a coded agent (call_mcp_tool) on a local Python robot built from the three branches. The job went Running → Suspended → Resumed → Successful. AgentHub logged the watch and woke job … (task completed, delivery Delivered); the upstream saw the repeated tasks/get every 5 s while the job was suspended, and the job resumed about 5 s after the task completed. So AgentHub's service identity could read the job's triggers and deliver there.
  • Not covered by that run: a low-code agent (see below), a connection-authenticated server, the timer waking the job, a server with guardrails, serverless.
  • Found by that run, not caused by these PRs: a low-code agent does not reach the task protocol on a Remote server at all. Its client sends a client-minted mcp-session-id on server/discover; AgentHub refuses a session id it did not see opened on a Remote server (-32601 Not Found), so the client falls back to the older handshake, where tasks are not declared. Low-code suspend on a Remote task needs that resolved first.

uipath-platform goes to 0.3.22.

🤖 Generated with Claude Code

A task a Remote MCP server runs has no Orchestrator job behind it, so
McpTask.job is empty and a caller could not suspend on it. AgentHub can
watch such a task and wake the caller's job through an API trigger; the
caller asks for that on a tasks/get.

- McpService.watch_task / watch_task_async: one tasks/get that names
  the caller's job for the server to wake.
- McpTask.api_trigger and McpTask.watch read the server's annotation.
- call_tool(resume_trigger_types=...) declares the trigger kinds the
  caller can suspend on; the default is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human integration review is needed because AgentHubService#2544 was inaccessible, and mocked validation does not establish live watch-contract compatibility, safe retry behavior, or API-trigger wake-up compatibility.

No open issues 🎉

What changed in this PR

Adds SDK support for asking AgentHub to watch Remote MCP tasks, enabling callers to suspend and resume through API triggers without an underlying Orchestrator job. Existing polling and default trigger declarations remain unchanged.

Changes:

  • Adds synchronous and asynchronous watch_task methods and configurable resume-trigger declarations.
  • Exposes API-trigger and watch metadata with validation and regression tests.
  • Bumps uipath-platform to 0.3.22 and updates both lockfiles.
File Description
packages/​uipath/​uv.lock Updates the linked platform package version.
packages/​uipath-platform/​uv.lock Records platform version 0.3.22.
packages/​uipath-platform/​tests/​services/​test_mcp_tasks.py Tests metadata validation, watch requests, and unchanged polling defaults.
packages/​uipath-platform/​src/​uipath/​platform/​orchestrator/​mcp_tasks.py Adds API-trigger and watch models and task properties.
packages/​uipath-platform/​src/​uipath/​platform/​orchestrator/​_mcp_service.py Adds watch methods and configurable request metadata.
packages/​uipath-platform/​src/​uipath/​platform/​orchestrator/​__init__.py Exports the new task metadata models.
packages/​uipath-platform/​pyproject.toml Bumps the platform package version to 0.3.22.

Review effort: Balanced

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants