Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit afd0d05

Browse files
committed
refactor: make Deno CLI use repeatable args for consistency
- Add --dep and --index-url as repeatable args in Deno CLI (using collect) - Update Python main.py to pass --dep= and --index-url= instead of comma-separated - Add deprecation warnings when --deps or --index-urls are used - Update Deno help text to show new args - Keep backwards compatibility for old comma-separated format - Add test for repeatable --dep flag
1 parent b972ef4 commit afd0d05

3 files changed

Lines changed: 34 additions & 8 deletions

File tree

mcp_run_python/deno/src/main.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,27 @@ export async function main() {
2121
const { args } = Deno
2222
const flags = parseArgs(Deno.args, {
2323
string: ['deps', 'return-mode', 'port', 'index-urls'],
24+
collect: ['dep', 'index-url'],
2425
default: { port: '3001', 'return-mode': 'xml' },
2526
})
26-
const deps = flags.deps?.split(',') ?? []
27-
const indexUrls = flags['index-urls']?.split(',') ?? []
27+
28+
// Deprecation warnings for old comma-separated args
29+
if (flags.deps) {
30+
console.warn('Warning: --deps is deprecated, use --dep instead (can be repeated)')
31+
}
32+
if (flags['index-urls']) {
33+
console.warn('Warning: --index-urls is deprecated, use --index-url instead (can be repeated)')
34+
}
35+
36+
// Support both new repeatable args and old comma-separated (backwards compat)
37+
const deps: string[] = [
38+
...((flags.dep as string[] | undefined) ?? []),
39+
...(flags.deps?.split(',').filter(Boolean) ?? []),
40+
]
41+
const indexUrls: string[] = [
42+
...((flags['index-url'] as string[] | undefined) ?? []),
43+
...(flags['index-urls']?.split(',').filter(Boolean) ?? []),
44+
]
2845
if (args.length >= 1) {
2946
if (args[0] === 'stdio') {
3047
await runStdio(deps, indexUrls, flags['return-mode'])
@@ -53,8 +70,8 @@ Usage: deno ... deno/main.ts [stdio|streamable_http|streamable_http_stateless|ex
5370
5471
options:
5572
--port <port> Port to run the HTTP server on (default: 3001)
56-
--deps <deps> Comma separated list of dependencies to install
57-
--index-urls <urls> Comma separated list of package index URLs (tried in order before PyPI)
73+
--dep <pkg> Dependency to install (can be repeated)
74+
--index-url <url> Package index URL (can be repeated, tried before PyPI)
5875
--return-mode <xml/json> Return mode for output data (default: xml)`,
5976
)
6077
Deno.exit(1)

mcp_run_python/main.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,11 @@ def _deno_install_args(dependencies: list[str] | None = None, index_urls: list[s
181181
'noop',
182182
]
183183
if dependencies is not None:
184-
args.append(f'--deps={",".join(dependencies)}')
184+
for dep in dependencies:
185+
args.append(f'--dep={dep}')
185186
if index_urls:
186-
args.append(f'--index-urls={",".join(index_urls)}')
187+
for url in index_urls:
188+
args.append(f'--index-url={url}')
187189
return args
188190

189191

@@ -207,9 +209,11 @@ def _deno_run_args(
207209
f'--return-mode={return_mode}',
208210
]
209211
if dependencies is not None:
210-
args.append(f'--deps={",".join(dependencies)}')
212+
for dep in dependencies:
213+
args.append(f'--dep={dep}')
211214
if index_urls:
212-
args.append(f'--index-urls={",".join(index_urls)}')
215+
for url in index_urls:
216+
args.append(f'--index-url={url}')
213217
if http_port is not None:
214218
if mode in ('streamable_http', 'streamable_http_stateless'):
215219
args.append(f'--port={http_port}')

tests/test_cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ def test_cli_example_success():
1515
assert cli_logic(['--deps', 'numpy', 'example']) == 0
1616

1717

18+
def test_cli_dep_repeatable():
19+
"""Test new --dep repeatable flag"""
20+
assert cli_logic(['--dep', 'numpy', 'example']) == 0
21+
22+
1823
def test_cli_example_fail():
1924
assert cli_logic(['example']) == 1

0 commit comments

Comments
 (0)