Skip to content

Add repository provider type for git-based MCP servers#6

Merged
BillJr99 merged 1 commit into
mainfrom
claude/admiring-newton-FuK5K
May 25, 2026
Merged

Add repository provider type for git-based MCP servers#6
BillJr99 merged 1 commit into
mainfrom
claude/admiring-newton-FuK5K

Conversation

@BillJr99
Copy link
Copy Markdown
Owner

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)

  • Added REPOS_DIR import from config for repository workdir management
  • New helper functions:
    • _get_repository_spec() — extracts the repository: block from YAML
    • _safe_provider_dirname() — normalizes provider names to safe directory names
    • _repository_workdir() — resolves on-disk workdir paths for repositories
  • Updated _provider_to_structured() to handle repository specs alongside package/code types, populating repo_url, repo_ref, build_commands, and workdir fields
  • Updated _structured_to_yaml() to serialize repository specs back to YAML with optional ref and workdir fields
  • Enhanced _validate_provider() to validate repository specs (require repo_url and command, validate build_commands is a list)
  • New /api/clone-and-build endpoint that:
    • Clones a git repo (or pulls if .git exists for idempotency)
    • Checks out an optional ref
    • Runs build commands inside the workdir
    • Returns workdir path or error details
  • Updated /api/introspect to accept and forward a cwd parameter for running introspection inside a repository workdir
  • Updated list_tools() to include is_repository flag in tool metadata
  • Added UI components:
    • Repository type card in the wizard (alongside code and package)
    • Repository editor box with git URL, ref, build commands, and re-clone button
    • Wizard step for creating repository providers
    • CSS badge styling for repository providers (green)

Backend (server.py)

  • Added REPOS_DIR import from config
  • New helper functions:
    • repository_workdir() — resolves workdir path from spec, with fallback to REPOS_DIR/<provider_name>
    • materialize_repository() — idempotent clone/pull and build logic called on every server start
  • Updated _make_process_handler() to accept and pass through cwd parameter to get_session()
  • Updated register_provider() to:
    • Call materialize_repository() before registering tools
    • Pass repository workdir as cwd to process handlers
  • Updated run_provider_setup() to call materialize_repository() before running requirements/setup_commands

Process Runner (process_runner.py)

  • Updated ProcessSession to store and use cwd parameter when spawning subprocess
  • Modified session registry key from command string to (command, cwd) tuple so different workdirs create separate sessions
  • Updated get_session() to accept cwd parameter and use it for session keying
  • Updated introspect() to accept and forward cwd parameter

Configuration (config.py)

  • Added REPOS_DIR environment variable (default /app/repos) for repository clone base directory

Tests

  • Added comprehensive test coverage in tests/test_frontend.py:
    • Repository provider round-trip (YAML ↔ structured JSON)
    • Repository validation (required fields, type checking)
    • /api/clone-and-build endpoint tests (clone, pull, ref checkout, error handling)
    • Introspect cwd parameter forwarding
    • UI element presence checks
  • Added tests in tests/test_server.py:
    • repository_workdir() resolution logic
    • materialize_repository() clone/pull/build behavior
    • Repository provider registration with correct workdir
  • Added new tests/test_process_runner.py for session cwd handling and registry keying

Documentation (README.md)

  • Added repository provider overview and lifecycle documentation
  • Documented wizard flow for creating repository providers
  • Documented YAML structure with package: + `

https://claude.ai/code/session_01R2Vi6NE4wGxwv6rZ2HEXji

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
@BillJr99 BillJr99 merged commit c557e5a into main May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants