Add repository provider type for git-based MCP servers#6
Merged
Conversation
Repository providers extend the existing package provider with a git clone + build step. YAML stores the repo URL and build commands so ephemeral containers re-materialize the workdir on every start. - config: add REPOS_DIR (MCPPROXY_REPOS_DIR, default /app/repos) - process_runner: thread cwd through ProcessSession, get_session, introspect; session registry keyed on (command, cwd) - server: add materialize_repository() invoked from run_provider_setup before requirements/setup_commands; register_provider passes the workdir as cwd to the subprocess handler - frontend: add /api/clone-and-build endpoint, accept cwd in /api/introspect, round-trip repository: block in structured JSON - HTML: third wizard card (Repository), repository editor box with re-clone & build button, repo badge in the provider list - tests: round-trip, validation, clone/pull idempotency, cwd threading, session registry keying — all offline (no real git or subprocesses) - README: new "Part 3.5" walkthrough, env vars, lifecycle, troubleshooting
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
This PR introduces a new repository provider type that allows mcpproxy to clone a git repository, run build commands, and spawn the resulting stdio MCP server. This enables support for MCP servers distributed only as source code (without npm/pip/binary distributions).
Key Changes
Frontend (
frontend/app.py)REPOS_DIRimport from config for repository workdir management_get_repository_spec()— extracts therepository:block from YAML_safe_provider_dirname()— normalizes provider names to safe directory names_repository_workdir()— resolves on-disk workdir paths for repositories_provider_to_structured()to handle repository specs alongside package/code types, populatingrepo_url,repo_ref,build_commands, andworkdirfields_structured_to_yaml()to serialize repository specs back to YAML with optionalrefandworkdirfields_validate_provider()to validate repository specs (requirerepo_urlandcommand, validatebuild_commandsis a list)/api/clone-and-buildendpoint that:.gitexists for idempotency)/api/introspectto accept and forward acwdparameter for running introspection inside a repository workdirlist_tools()to includeis_repositoryflag in tool metadataBackend (
server.py)REPOS_DIRimport from configrepository_workdir()— resolves workdir path from spec, with fallback toREPOS_DIR/<provider_name>materialize_repository()— idempotent clone/pull and build logic called on every server start_make_process_handler()to accept and pass throughcwdparameter toget_session()register_provider()to:materialize_repository()before registering toolscwdto process handlersrun_provider_setup()to callmaterialize_repository()before running requirements/setup_commandsProcess Runner (
process_runner.py)ProcessSessionto store and usecwdparameter when spawning subprocesscommandstring to(command, cwd)tuple so different workdirs create separate sessionsget_session()to acceptcwdparameter and use it for session keyingintrospect()to accept and forwardcwdparameterConfiguration (
config.py)REPOS_DIRenvironment variable (default/app/repos) for repository clone base directoryTests
tests/test_frontend.py:/api/clone-and-buildendpoint tests (clone, pull, ref checkout, error handling)cwdparameter forwardingtests/test_server.py:repository_workdir()resolution logicmaterialize_repository()clone/pull/build behaviortests/test_process_runner.pyfor session cwd handling and registry keyingDocumentation (
README.md)package:+ `https://claude.ai/code/session_01R2Vi6NE4wGxwv6rZ2HEXji