Skip to content

Commit a6a3ee6

Browse files
committed
Merge branch 'feat-improve-test-coverage-redirections' into develop
2 parents 2fd686b + 6d68e08 commit a6a3ee6

13 files changed

+1758
-74
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
.DEFAULT_GOAL := all
33

44
test:
5-
pip install -e .
6-
pytest
5+
uv run pytest
76

87
format:
98
black .
@@ -19,7 +18,10 @@ lint:
1918
typecheck:
2019
mypy src/mcp_shell_server tests
2120

21+
coverage:
22+
pytest --cov=src/mcp_shell_server tests
23+
2224
# Run all checks required before pushing
2325
check: lint typecheck test
2426
fix: check format
25-
all: check test
27+
all: format check coverage

pyproject.toml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [
66
]
77
dependencies = [
88
"asyncio>=3.4.3",
9-
"mcp>=1.1.0",
9+
"mcp @ git+https://github.com/tumf/mcp-python-sdk.git@fix/handle-cancelled-notifications",
1010
]
1111
requires-python = ">=3.11"
1212
readme = "README.md"
@@ -22,6 +22,7 @@ test = [
2222
"pytest-asyncio>=0.23.0",
2323
"pytest-env>=1.1.0",
2424
"pytest-cov>=6.0.0",
25+
"pytest-mock>=3.12.0",
2526
]
2627
dev = [
2728
"ruff>=0.0.262",
@@ -69,3 +70,29 @@ path = "src/mcp_shell_server/version.py"
6970

7071
[tool.hatch.build.targets.wheel]
7172
packages = ["src/mcp_shell_server"]
73+
74+
[tool.hatch.metadata]
75+
allow-direct-references = true
76+
77+
78+
[tool.coverage.report]
79+
exclude_lines = [
80+
"pragma: no cover",
81+
"def __repr__",
82+
"raise NotImplementedError",
83+
"if __name__ == .__main__.:",
84+
"pass",
85+
"raise ImportError",
86+
"__version__",
87+
"except IOError:",
88+
"except IOError as e:",
89+
"def _cleanup_handles",
90+
"def __aexit__",
91+
"if path in [\">\", \">>\", \"<\"]:",
92+
"def _close_handles",
93+
]
94+
95+
omit = [
96+
"src/mcp_shell_server/__init__.py",
97+
"src/mcp_shell_server/version.py",
98+
]

src/mcp_shell_server/server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,14 @@ async def run_tool(self, arguments: dict) -> Sequence[TextContent]:
7070
if not command:
7171
raise ValueError("No command provided")
7272

73+
if not isinstance(command, list):
74+
raise ValueError("'command' must be an array")
75+
7376
result = await self.executor.execute(command, stdin, directory, timeout)
7477

7578
# Raise error if command execution failed
7679
if result.get("error"):
77-
raise RuntimeError(result["error"])
80+
raise ValueError(result["error"]) # Changed from RuntimeError to ValueError
7881

7982
# Convert executor result to TextContent sequence
8083
content: list[TextContent] = []

0 commit comments

Comments
 (0)