feat: add unified simulation API, CLI, and MCP tools - #15
Merged
Conversation
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
MatKit's existing engine-specific interfaces do not provide a shared contract for running calculations, inspecting scientific outcomes, or retrieving artifacts through Python, CLI, and agent tools. This PR adds the first experimental unified execution layer: users can prepare a portable calculation bundle, execute it locally or in a separately configured environment, and inspect the same structured result through Python, CLI, or optional MCP tools.
The initial scientific scope is MLIP evaluation and fixed-cell relaxation, Zeo++ pore analysis, and single-component gRASPA CUDA adsorption. MatKit remains usable without an agent, MOFforge, or ChemGraph.
Changes
Simulation setup and parser fixes
success=Truefor successfully parsed RASPA2 output and reject nonfinite adsorption values, nonpositive density, and negative reported errors.Shared API and scientific contracts
matkit.apiwith versioned Pydantic request, result, batch, structure, artifact, and failure models. Reject unknown fields, invalid numeric values, incompatible adapter settings, and inconsistent result states.prepare,execute,run,inspect_run,run_batch, and operation-specific evaluation, relaxation, pore-analysis, and adsorption functions.accepted. An unconverged relaxation retains its numerical payload but is not accepted; adsorption uncertainty is distinct from execution failure, and sampling quality remains unknown.Portable bundles, structure handoff, and execution
Scientific adapters
CLI and optional MCP
evaluate,relax,pores,adsorption prepare/run/analyze,prepare,execute,inspect,batch, andcapabilitiescommands. Resolve input paths relative to specification files and support execution-profile JSON.matkit-mcpstdio server and seven tools: capabilities, evaluation, relaxation, pore analysis, general preparation, adsorption preparation, and inspection.matkit://runs/{run_id}/artifacts/{digest}resources.Packaging, documentation, examples, and CI
pydantic>=2,<3, optionalmcp>=2,<3, and thematkit-mcpentry point. Include nested simulation templates and definitions in wheels.docs/unified-api.mdcovering installation, specifications, execution profiles, scientific outcomes, artifact/structure contracts, CLI, and MCP; adddocs/capabilities.mddistinguishing unified and legacy capabilities from scientific validation. Update README and changelog links/notes.Compatibility and scope
Existing engine APIs, CLI commands, and legacy MLIP result formats remain available. The unified schemas use their own names and version 1. This PR also intentionally corrects the cutoff and RASPA2 behaviors described above.
All new scientific adapters remain experimental. CPU fixtures and mocked/synthetic engine outputs validate interface behavior, not scientific accuracy or GPU compatibility. Real MACE/Rootstock/ALCHEMI, Zeo++, gRASPA, and Polaris execution evidence is still required before promotion; unresolved model identities, seeds, and sampling quality are not presented as verified.
Deferred work includes unified DFT/MD/cell optimization, normalized mixture adsorption results, MOFforge/charge workflows, scientific reference/parity benchmarks, automatic resume/result reuse, scheduler submission, persistent background jobs, HTTP MCP transport, and agent evaluations. Long calculations use prepared bundles and CLI/job-script execution.
Validation
pytest tests/ -q).MATKIT_WHEEL_TEST=1: 336 passed, 1 skipped, including real local MCP stdio discovery, execution, resource retrieval, timeout, and cancellation tests.git diff --check origin/main...HEADpassed.The implementation is split into
aa8d5c8(setup/parser fixes) ande84b29e(unified API, interfaces, documentation, and tests).