Generalize npx providers to support any stdio MCP subprocess#1
Merged
Conversation
…p_commands
- Rename npx_runner.py → process_runner.py; class NpxSession → ProcessSession
(NpxSession alias kept for backward compat)
- Add SUBPROCESS_KEYS = ('package', 'npx') so existing npx: YAML files keep
working unchanged; saving through the UI rewrites them to package: format
- Add _get_package_command() helper that checks both keys in priority order
- Add run_provider_setup() that pip-installs requirements and runs setup_commands
on every server startup (safe no-op when already installed)
- Add requirements: and setup_commands: fields to both code and package providers
in YAML, structured JSON, validation, and editor UI
- Merge all introspect endpoints into a single POST /api/introspect that accepts
command + requirements + setup_commands; removes /api/introspect-npx
- Remove the ad-hoc 'Run Command' modal; setup_commands replace it persistently
- Simplify the wizard to 2 cards: Python Code and Package
- Package card accepts any command (npx, uvx, python -m, installed binary);
package manager auto-detected from the command prefix for display purposes
- Update provider list badges: 'pkg' (purple) for package, 'code' (blue) for code
- Add provider_type field to GET /api/tools list; is_npx kept as backward-compat alias
- Install uv via pip in Dockerfile so uvx-based providers work out of the box;
add /root/.local/bin to PATH
- Add pip install uv step to GitHub Actions CI workflow
- 150/150 tests pass covering all new behavior and backward compat
https://claude.ai/code/session_016EMphWWMguzwVrfAYvJFSX
- SUBPROCESS_KEYS reduced to ('package',); npx: key no longer read
- _get_package_command() simplified to a direct spec.get('package') lookup
- _get_package_spec() in frontend/app.py simplified to spec.get('package')
- Removed is_npx alias from GET /api/tools list response
- Removed is_npx || is_package JS fallback in provider list rendering
- Removed all backward-compat test cases for npx: key
- Updated SUBPROCESS_KEYS test to assert ('package',) exactly
- Removed backward-compat notes from README
- 144/144 tests pass
https://claude.ai/code/session_016EMphWWMguzwVrfAYvJFSX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the MCP provider system to support any stdio-based MCP server subprocess—not just
npxcommands. This includes support foruvx,python -m, installed binaries, and any other command that speaks the MCP stdio transport. Adds support for pip requirements and setup commands that run on every server startup.Key Changes
Renamed
npx_runner.py→process_runner.py: Generalized the subprocess spawning and session management to handle any command, not just npx. TheNpxSessionclass is nowProcessSessionwith a backward-compatible alias.Updated YAML schema:
npx:key topackage:(legacynpx:still accepted for backward compatibility)requirements:list for pip packages to install before server startupsetup_commands:list for shell commands to run on every server startupFrontend API changes:
/api/introspect-npx→/api/introspect(acceptscommand,requirements,setup_commands)/api/run-commandendpoint (setup commands now declarative in YAML)"npx"to"package"in structured JSONnpx_command→commandin provider objectsPackage manager detection: Added
_detect_package_manager()helper to identify the package manager from command prefix (npx, uvx, python, npm) for logging/display purposes.Server-side setup: Added
run_provider_setup()function that:subprocess.run([sys.executable, "-m", "pip", "install", ...])subprocess.run(shlex.split(cmd))UI updates:
Validation: Updated
_validate_provider()to checkrequirementsandsetup_commandsare lists if present.Tests: Added comprehensive test coverage for:
Implementation Details
ProcessSessionclass maintains one persistent connection per command string, reusing it across tool calls for efficiency.https://claude.ai/code/session_016EMphWWMguzwVrfAYvJFSX