Skip to content

Commit 51539eb

Browse files
committed
fix: add single entrypoint verification
1 parent 775726b commit 51539eb

5 files changed

Lines changed: 104 additions & 29 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ cython_debug/
182182

183183
**/samples/**/.agent/
184184
**/samples/**/.claude/
185+
.claude/
185186
**/samples/**/AGENTS.md
186187
**/samples/**/CLAUDE.md
187188
**/samples/**/entry-points.json

pyproject.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[project]
22
name = "uipath-mcp"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
description = "UiPath MCP SDK"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
88
"mcp==1.26.0",
99
"pysignalr==1.3.0",
10-
"uipath>=2.8.23, <2.9.0",
11-
"uipath-runtime>=0.8.0, <0.9.0",
10+
# "uipath>=2.8.23, <2.9.0",
11+
"uipath==2.10.12.dev1014315285",
12+
"uipath-runtime>=0.9.1, <0.10.0",
1213
]
1314
classifiers = [
1415
"Development Status :: 3 - Alpha",
@@ -42,14 +43,13 @@ dev = [
4243
"mypy>=1.14.1",
4344
"ruff>=0.9.4",
4445
"pytest>=7.4.0",
45-
"pytest-asyncio>=0.23.0",
46+
"pytest-asyncio>=1.3.0",
4647
"pytest-cov>=4.1.0",
4748
"pytest-mock>=3.11.1",
4849
"pre-commit>=4.5.1",
4950
"filelock>=3.20.3",
5051
"virtualenv>=20.36.1",
5152
"numpy>=1.24.0",
52-
"pytest-asyncio>=1.3.0",
5353
]
5454

5555
[tool.ruff]
@@ -93,3 +93,6 @@ name = "testpypi"
9393
url = "https://test.pypi.org/simple/"
9494
publish-url = "https://test.pypi.org/legacy/"
9595
explicit = true
96+
97+
[tool.uv.sources]
98+
uipath = { index = "testpypi" }

src/uipath_mcp/_cli/_utils/_config.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,7 @@ def get_servers(self) -> list[McpServer]:
106106
def get_server(self, name: str) -> McpServer | None:
107107
"""
108108
Get a server model by name.
109-
If there's only one server available, return that one regardless of name.
110-
Otherwise, look up the server by the provided name.
111109
"""
112-
# If there's only one server, return it
113-
if len(self._servers) == 1:
114-
return next(iter(self._servers.values()))
115-
116-
# Otherwise, fall back to looking up by name
117110
return self._servers.get(name)
118111

119112
def get_server_names(self) -> list[str]:

tests/cli/test_factory.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import json
2+
from unittest.mock import MagicMock, patch
3+
4+
import pytest
5+
6+
from uipath_mcp._cli._runtime._exception import UiPathMcpRuntimeError
7+
from uipath_mcp._cli._runtime._factory import UiPathMcpRuntimeFactory
8+
9+
# Patch UiPath() constructor which requires auth env vars
10+
_UIPATH_PATCH = patch("uipath_mcp._cli._runtime._runtime.UiPath")
11+
12+
13+
@pytest.fixture
14+
def mcp_json_single(tmp_path):
15+
"""Create a temporary mcp.json with a single server."""
16+
config = {
17+
"servers": {
18+
"math-server": {
19+
"transport": "stdio",
20+
"command": "python",
21+
"args": ["server.py"],
22+
}
23+
}
24+
}
25+
config_path = tmp_path / "mcp.json"
26+
config_path.write_text(json.dumps(config))
27+
return str(config_path)
28+
29+
30+
@pytest.fixture
31+
def factory(tmp_path):
32+
context = MagicMock()
33+
context.config_path = str(tmp_path / "uipath.json")
34+
context.folder_key = "test-folder-key"
35+
context.mcp_server_id = "test-server-id"
36+
return UiPathMcpRuntimeFactory(context=context)
37+
38+
39+
@pytest.mark.asyncio
40+
async def test_exact_match_works(factory, mcp_json_single):
41+
"""Server found by exact name match."""
42+
factory._mcp_config = None
43+
with _UIPATH_PATCH, patch.object(factory, "_load_mcp_config") as mock_load:
44+
from uipath_mcp._cli._utils._config import McpConfig
45+
46+
mock_load.return_value = McpConfig(mcp_json_single)
47+
runtime = await factory.new_runtime(
48+
"math-server", "00000000-0000-0000-0000-000000000001"
49+
)
50+
assert runtime._entrypoint == "math-server"
51+
52+
53+
@pytest.mark.asyncio
54+
async def test_wrong_name_raises(factory, mcp_json_single):
55+
"""Wrong entrypoint raises SERVER_NOT_FOUND."""
56+
with patch.object(factory, "_load_mcp_config") as mock_load:
57+
from uipath_mcp._cli._utils._config import McpConfig
58+
59+
mock_load.return_value = McpConfig(mcp_json_single)
60+
with pytest.raises(UiPathMcpRuntimeError) as exc_info:
61+
await factory.new_runtime("my-mcp2", "00000000-0000-0000-0000-000000000001")
62+
assert "not found" in str(exc_info.value).lower()

uv.lock

Lines changed: 33 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)