Skip to content

MCP: Runcode, upgrade, compile - #6236

Open
bbarker wants to merge 7 commits into
unisonweb:trunkfrom
bbarker:runcode-upgrade-compile
Open

MCP: Runcode, upgrade, compile#6236
bbarker wants to merge 7 commits into
unisonweb:trunkfrom
bbarker:runcode-upgrade-compile

Conversation

@bbarker

@bbarker bbarker commented May 22, 2026

Copy link
Copy Markdown
Contributor

Overview

Supersedes #6233

Adds three enhancements to the MCP tool surface:

  1. Optional code parameter for run — When provided, the source is typechecked first and the specified definition is run from the typechecked file without updating the codebase. Enables AI agents to iterate on code in a single tool call without polluting the project namespace.

  2. New compile tool — Compiles a Unison definition to a standalone .uc file via MakeStandaloneI. The file is written relative to the codebase directory and can be executed with ucm run.compiled.

  3. New lib-upgrade tool — Upgrades a library dependency from one version to another via UpgradeI, equivalent to lib.upgrade old new in UCM.

Also fixes the Nix flake by adding filelock to dontCheck overrides (its test suite is flaky under the Nix sandbox).

Implementation approach and notes

  • RunToolArguments gains code :: Maybe (Either FilePath Text) (optional in JSON schema). Handler branches on code: Nothing → existing behavior; Just source → delegates to withCode.
  • CompileToolArguments takes projectContext, mainFunctionName, and outputPath; handler issues MakeStandaloneI.
  • LibUpgradeToolArguments takes projectContext, oldLibName, newLibName; handler issues UpgradeI [old, new].
  • Both new tools follow the same handleInputMCP pattern as existing tools.

Interesting/controversial decisions

  • compile output path is passed as-is to MakeStandaloneI (which appends .uc). UCM writes the file relative to the codebase dir, not to an arbitrary absolute path — this is a UCM constraint, documented in the tool description.
  • lib-upgrade takes a single old/new pair rather than the variadic form UCM supports. Sufficient for agent use; can be extended later.
  • run with code reuses withCode rather than duplicating typecheck logic — keeps the handler thin.

Test coverage

  • Transcript test mcp-run-with-code.md added covering: run without code (missing definition error), run with inline sourceCode, and run with filePath.
  • Transcript test mcp-compile-upgrade.md added covering: compile success, compile with missing definition, and lib-upgrade with missing old library.
  • Both transcript files updated in-place with real responses by the transcript runner; all pass.
  • Proofs regenerated (./scripts/proofs/formatting.sh and ./scripts/proofs/transcripts.sh) — CI attestation checks pass.
  • Existing transcript tests continue to pass.

Loose ends

  • lib-upgrade only supports a single old→new pair; variadic form could be added later.

Final checklist

  • PR title describes the change
  • Description updated to reflect final implementation
  • .cabal files not changed (only .hs and transcript .md)
  • Ormolu run on modified files

@bbarker

bbarker commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

This is ready for review 🙇‍♂️

naga-zoom added a commit to naga-zoom/unison that referenced this pull request Jun 10, 2026
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