-
Notifications
You must be signed in to change notification settings - Fork 19
feat: add --index-url support for private package registries #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
79f12ac to
2e51c0b
Compare
d33a672 to
22eb651
Compare
1f09b30 to
553272c
Compare
Add support for custom package index URLs to allow installing dependencies from private registries. The --index-url CLI option can be repeated multiple times to specify multiple indexes, which are tried in order before PyPI. Changes: - Add --index-url CLI argument with action='append' for multiple indexes - Add index_urls parameter to run_mcp_server(), prepare_deno_env(), async_prepare_deno_env(), and code_sandbox() - Pass index_urls through Deno/TypeScript layer to micropip.install() - Update README with usage examples Usage: uvx mcp-run-python --index-url https://private.repo.com/simple --deps pkg stdio Python API: async with code_sandbox( dependencies=['pkg'], index_urls=['https://private.repo.com/simple'] ) as sandbox: await sandbox.eval('import pkg')
553272c to
81e9179
Compare
- Always pass indexUrls to prepare_env (even if empty), matching how dependencies are handled - Add repeatable --dep flag alongside existing --deps for CLI consistency with --index-url - Mark --deps as deprecated but keep it working for backwards compatibility
micropip treats empty list [] differently from None - with [] it doesn't fall back to PyPI. Using 'index_urls or None' ensures empty lists are converted to None so PyPI fallback works correctly.
mcp_run_python/deno/src/main.ts
Outdated
| --return-mode <xml/json> Return mode for output data (default: xml)`, | ||
| --port <port> Port to run the HTTP server on (default: 3001) | ||
| --deps <deps> Comma separated list of dependencies to install | ||
| --index-urls <urls> Comma separated list of package index URLs (tried in order before PyPI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly surprising they're not repeatable singular args here. I guess its not that important for these to be consistent, but see if you can make it so without too much effort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is my attempt at making it consistent!
- Update README.md examples to use --dep (repeatable) instead of --deps - Hide --deps from CLI help (argparse.SUPPRESS) - Add DeprecationWarning when --deps is used - Keep --deps working for backwards compatibility
- 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
- test_cli_dep_multiple: test multiple --dep flags (--dep numpy --dep pydantic) - test_cli_dep_and_deps_combined: test combining --dep and --deps - test_cli_deps_deprecation_warning: verify deprecation warning is emitted
| console.warn('Warning: --deps is deprecated, use --dep instead (can be repeated)') | ||
| } | ||
| if (flags['index-urls']) { | ||
| console.warn('Warning: --index-urls is deprecated, use --index-url instead (can be repeated)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this do we? 😄
Add support for custom package index URLs to allow installing dependencies from private registries. The --index-url CLI option can be repeated multiple times to specify multiple indexes, which are tried in order before PyPI.
Changes:
Usage:
uvx mcp-run-python --index-url https://private.repo.com/simple --deps pkg stdioPython API:
async with code_sandbox( dependencies=['pkg'], index_urls=['https://private.repo.com/simple'] ) as sandbox: await sandbox.eval('import pkg')