Repository navigation
Conversation
This branch has not been deployed
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.
Adds a Model Context Protocol server so an LLM can discover and validate Pruna's optimization catalogue without loading a model.
The server has two tiers. Seven discovery and validation tools (
list_tags,list_algorithms,describe_algorithm,list_benchmarks,list_metrics,list_datasets,validate_config) are read-only and need neither a GPU nor network access, so they are always registered.smash_modelandevaluate_modelload a model and are registered only when the server is started with--allow-execute, so a client can discover that execution is unavailable rather than being offered a tool that would download gigabytes of weights.validate_configreusescheck_argument_compatibilityandcheck_algorithm_packages_availabilityfrompruna.config.pre_smash_routines, plus a static mirror of the pairwise branch ofcheck_algorithm_cross_compatibility. These surface missing pip extras, missing tokenizers, and incompatible algorithm pairs before any device is touched. The two checks that genuinely need a loaded model are reported innotesrather than guessed at.Install with
pip install "pruna[mcp]", then registerpruna-mcpas an MCP server.Related Issue
<!-- If this PR addresses an existing issue, please link to it here -->
Fixes
Type of Change
<!-- Mark the appropriate option with an "x" (no spaces around the "x") -->
Testing
<!-- How did you verify your changes? Which tests did you run? -->
uv run pytest -m "cpu and not slow")57 tests added under
tests/mcp_server/, run against Pruna 0.3.4 (48 registered algorithms). The suite was also driven end-to-end over real stdio JSON-RPC in both modes: handshake,tools/list,tools/call, plusping,resources/list, andprompts/listusing themcpSDK's ownClientSession, against a subprocess runningpruna-mcp.Notable coverage:
describe_algorithmadvertises back intoSmashConfigand assert Pruna accepts it, so the server cannot report a value it would then reject.smash,save_pruna_model, the loaders, andEvaluationAgentwith arguments those functions actually accept. These need no device, and they are what caughtPrunaDataModulebeing called with adata_nameit does not have.mcpextra, asserting the failure namespruna[mcp]and does not surface a traceback.Not yet verified:
smash_modelandevaluate_modelhave not been executed against a real model. Every call they make is signature-checked, but the paths aftersmash()runs need a device to confirm.Checklist
<!-- Mark items with "x" (no spaces around the "x") -->