Skip to content

Commit 568054e

Browse files
authored
fix example return code (#7)
1 parent 8b48a9c commit 568054e

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

mcp_run_python/deno/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ a
286286
)
287287
console.log('Tool return value:')
288288
console.log(asXml(result))
289+
if (result.status !== 'success') {
290+
Deno.exit(1)
291+
}
289292
}
290293

291294
// list of log levels to use for level comparison

tests/test_cli.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from __future__ import annotations as _annotations
2+
3+
import pytest
4+
5+
from mcp_run_python._cli import cli_logic
6+
7+
8+
def test_cli_version(capsys: pytest.CaptureFixture[str]):
9+
assert cli_logic(['--version']) == 0
10+
captured = capsys.readouterr()
11+
assert captured.out.startswith('mcp-run-python ')
12+
13+
14+
def test_cli_example_success():
15+
assert cli_logic(['--deps', 'numpy', 'example']) == 0
16+
17+
18+
def test_cli_example_fail():
19+
assert cli_logic(['example']) == 1

tests/test_mcp_servers.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from mcp.client.streamable_http import streamablehttp_client
1616

1717
from mcp_run_python import async_prepare_deno_env
18-
from mcp_run_python._cli import cli_logic
1918

2019
if TYPE_CHECKING:
2120
from mcp import ClientSession
@@ -213,13 +212,3 @@ def logging_callback(level: str, message: str) -> None:
213212
</return_value>\
214213
"""
215214
)
216-
217-
218-
def test_cli_version(capsys: pytest.CaptureFixture[str]):
219-
assert cli_logic(['--version']) == 0
220-
captured = capsys.readouterr()
221-
assert captured.out.startswith('mcp-run-python ')
222-
223-
224-
def test_cli_example():
225-
assert cli_logic(['--deps', 'numpy', 'example']) == 0

0 commit comments

Comments
 (0)