Skip to content

Update uipath SDK to 2.8#159

Open
edis-uipath wants to merge 1 commit intomainfrom
feature/update_uipath_2.2
Open

Update uipath SDK to 2.8#159
edis-uipath wants to merge 1 commit intomainfrom
feature/update_uipath_2.2

Conversation

@edis-uipath
Copy link
Collaborator

@edis-uipath edis-uipath commented Dec 9, 2025

This PR updates the uipath-mcp package to align with the new UiPath 2.8 runtime model. The changes refactor the codebase to use the new runtime protocol-based architecture instead of the previous middleware-based approach.

Key changes

  • Migrates from middleware-based execution to runtime factory pattern
  • Implements UiPathRuntimeProtocol with execute() and get_schema() methods
  • Implements UiPathRuntimeFactoryProtocol with get_settings(), discover_entrypoints(), discover_runtimes(), new_runtime(), and dispose()
  • Updates import paths from uipath._cli to uipath.platform and uipath.runtime
  • Updates uipath dependency to >=2.8.23, <2.9.0
  • Adds explicit uipath-runtime>=0.8.0, <0.9.0 dependency
  • Uses UiPathRuntimeContext for mcp_server_id/mcp_server_slug instead of manual uipath.json parsing
  • Uses UiPathConfig.config_file_path for config path resolution
  • Removes stream() method and event emitting — unnecessary complexity for MCP servers
  • Removes manual tracing/LlmOpsHttpExporter setup — now handled by the CLI automatically
  • Deletes old middleware hooks (cli_run.py, cli_init.py) and simplifies server template

Remaining remarks

  • Remove duplicate factory registration in __init__.py — registered both via entry point and UiPathRuntimeFactoryRegistry.register() (@radu-mocanu)

Development Package

  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath-mcp==0.0.109.dev1001590237",

  # Any version from PR
  "uipath-mcp>=0.0.109.dev1001590000,<0.0.109.dev1001600000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath-mcp = { index = "testpypi" }

@edis-uipath edis-uipath self-assigned this Dec 9, 2025
@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch 2 times, most recently from 1f6de07 to 33c8807 Compare December 11, 2025 13:15
@edis-uipath edis-uipath marked this pull request as ready for review December 11, 2025 13:16
Copilot AI review requested due to automatic review settings December 11, 2025 13:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the uipath-mcp package to align with the new UiPath 2.2 runtime model. The changes refactor the codebase to use the new runtime protocol-based architecture instead of the previous middleware-based approach.

Key changes:

  • Migrates from middleware-based execution to runtime factory pattern
  • Refactors runtime to implement UiPathRuntimeProtocol with execute() and stream() methods
  • Updates import paths from uipath._cli to uipath.platform and uipath.runtime

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/uipath_mcp/middlewares.py Removes init and run middleware registrations
src/uipath_mcp/_cli/cli_run.py Deletes entire run middleware implementation
src/uipath_mcp/_cli/cli_init.py Deletes entire init middleware implementation
src/uipath_mcp/_cli/_utils/_config.py Adds type annotation for command field
src/uipath_mcp/_cli/_templates/server.py.template Simplifies template by removing many example tool functions
src/uipath_mcp/_cli/_runtime/_session.py Updates imports and adds type cast for command parameter
src/uipath_mcp/_cli/_runtime/_runtime.py Major refactor to implement runtime protocol, adds factory pattern support, and streaming capabilities
src/uipath_mcp/_cli/_runtime/_factory.py Adds new factory class for creating MCP runtime instances
src/uipath_mcp/_cli/_runtime/_exception.py Updates import path for error classes
src/uipath_mcp/_cli/_runtime/_context.py Removes UiPathMcpRuntimeContext class, keeps only UiPathServerType enum
src/uipath_mcp/_cli/_runtime/init.py Adds factory registration and exports
pyproject.toml Updates uipath dependency version and adds local development source
.vscode/settings.json Adds new VS Code workspace configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch 2 times, most recently from 90495a9 to e7df223 Compare December 11, 2025 13:32
@edis-uipath edis-uipath requested a review from Copilot December 11, 2025 13:33
@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch from e7df223 to 80f2f3b Compare December 11, 2025 13:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch from 80f2f3b to 6c8f026 Compare December 11, 2025 13:56
@edis-uipath edis-uipath added the build:dev Create a dev build from the pr label Dec 11, 2025
@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch from 6c8f026 to ce27d27 Compare December 11, 2025 14:48
@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch from ce27d27 to 141dd08 Compare December 11, 2025 15:23
edis-uipath added a commit that referenced this pull request Feb 13, 2026
- Update uipath SDK to >=2.8.23 and add uipath-runtime >=0.8.0 dependency
- Use UiPathRuntimeContext for mcp_server_id/slug instead of manual uipath.json parsing
- Add get_settings() method to factory protocol
- Remove TODO comment on auth validation (confirmed needed)
- Remove manual tracing/LlmOpsHttpExporter setup (handled by CLI)
- Fix self.context.folder_key bug in _on_runtime_abort (use self._folder_key)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch from 141dd08 to 427cd65 Compare February 13, 2026 14:59
@edis-uipath edis-uipath changed the title Update uipath 2.2 Update uipath SDK to 2.8 Feb 13, 2026
@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch 3 times, most recently from 06acbf1 to 4884c3e Compare February 13, 2026 15:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

async def cleanup(self) -> None:
async def _cleanup(self) -> None:
"""Clean up all resources."""

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The cleanup method can be called multiple times: once from the finally block in _run_server() and again if dispose() is called. Consider adding a flag to prevent duplicate cleanup operations, or ensure all cleanup operations are truly idempotent. For example, _on_runtime_abort() will send duplicate HTTP requests if called twice.

Suggested change
# Ensure cleanup is only performed once, even if called from multiple places.
if getattr(self, "_cleanup_done", False):
return
self._cleanup_done = True

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point — added a _cleanup_done flag to guard against duplicate cleanup. The _on_runtime_abort() HTTP call now only fires once even if _cleanup() is called from both the finally block and dispose().

@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch from 4884c3e to ebda119 Compare February 13, 2026 15:55
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@edis-uipath edis-uipath force-pushed the feature/update_uipath_2.2 branch from ebda119 to 54a3433 Compare February 13, 2026 16:01
UiPathErrorCategory.DEPLOYMENT,
)
# Context fields accessed from environment
self._job_id = os.environ.get("UIPATH_JOB_KEY")
Copy link
Collaborator

Choose a reason for hiding this comment

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

let s use UiPathConfig here

)

if not self.context.trace_context.tenant_id:
if not self._tenant_id:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we can merge these 2 conditions into a single one.
if not (self._tenant_id and self._org_id)

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

Labels

build:dev Create a dev build from the pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants