Skip to content

Add MCP server#560

Open
jelmer wants to merge 7 commits intomasterfrom
svp-mcp
Open

Add MCP server#560
jelmer wants to merge 7 commits intomasterfrom
svp-mcp

Conversation

@jelmer
Copy link
Owner

@jelmer jelmer commented Jul 16, 2025

No description provided.

jelmer added 7 commits July 16, 2025 11:43
This adds a Model Context Protocol (MCP) server to silver-platter, allowing
AI assistants and other MCP clients to interact with svp functionality.

The MCP server is enabled with the "mcp" feature flag and adds:
- A new "svp mcp" command that runs the MCP server on stdin/stdout
- Three initial tools exposed via MCP:
  - list_forges: List all configured forges
  - list_proposals: List merge proposals by the current user
  - repo_info: Get information about a specific repository

The implementation uses the official Rust MCP SDK (rmcp) and follows
the MCP specification for tool discovery and invocation.
This adds a new tool 'run_recipe' to the MCP server that allows running
silver-platter recipes. The tool accepts:
- recipe: Recipe definition as inline JSON object with fields:
  - name: Recipe name
  - command: Command as string or array of arguments
  - mode: Optional mode (push, propose, attempt-push)
  - merge-request: Optional merge request configuration
- url: URL of the repository to apply the recipe to

The current implementation parses and validates the recipe definition,
returning basic information about the recipe. This provides a foundation
for full recipe execution in the MCP environment without requiring
separate recipe files.
This adds the apply_changes tool which allows applying a script to make
changes in an existing local checkout. The tool supports:
- directory: Directory containing the repository
- command: Command as string or array of arguments
- diff: Optional flag to show diff of changes
- commit_pending: Whether to commit pending changes (yes/no/auto)

The tool opens a working tree, checks that it's clean, runs the specified
script, and returns the results. This mirrors the 'svp apply' command
functionality.
This adds the batch_generate tool which creates a batch of changes to
apply to multiple repositories. The tool supports:
- directory: Directory to create the batch in
- candidates: Path to candidates file
- command: Command as string or array of arguments (alternative to recipe)
- recipe: Path to recipe file (alternative to command)

The tool loads candidates from a file, creates a recipe from either the
provided recipe file or command, and generates a batch using the
Batch::from_recipe method. This mirrors the 'svp batch generate' command
functionality.
This adds the batch_publish tool which publishes a batch of changes or a
specific entry from a batch. The tool supports:
- directory: Directory containing the batch
- name: Specific entry to publish (optional)
- overwrite: Whether to overwrite existing branches
- refresh: Refresh changes if branch already exists

Currently provides a simulation of the batch publish functionality.
In a full implementation, this would need to be refactored to expose
the actual batch_publish function from the binary as a library function.
- Add batch_status tool with real implementation using load_batch_metadata
- Add batch_diff tool for showing entry diffs
- Add batch_refresh tool for refreshing batch changes
- Add login tool for forge authentication

All tools include proper JSON schema definitions and error handling.
The batch_status tool provides actual functionality while others have
placeholder implementations that would require library refactoring
for full functionality.
- Add test_server_info to verify server metadata and capabilities
- Add test_server_creation to test basic server initialization
- Add test_data_structures to verify JSON serialization/deserialization
  for ProposalInfo, RepoInfo, and RunRecipeResult structs
- Add test_json_schema_creation to verify JSON schema functionality
- Add test_tool_definitions to verify tool capability configuration

The tests focus on core functionality that can be tested without
complex async setup, ensuring all data structures work correctly
and the server can be properly initialized and configured.
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.

1 participant

Comments