Skip to content

Conversation

@ChrisPenner
Copy link
Member

@ChrisPenner ChrisPenner commented Jun 23, 2025

Overview

Adds an MCP server into UCM itself via the ucm mcp command, with tools for typechecking code, listing/searching/viewing definitions and searching Share.

See the new mcp.md doc for setup instructions.

Implementation Details

NOTE: The ucm mcp command needs to connect to your codebase, and is executed by AI agents, so will need to be able to run in tandem with UCM. To that end it opens the codebase without checking codebase locks.

Currently the only endpoint which can mutate anything is lib.install.

UCM is much safer than it used to be w/r to concurrent commands, it no longer keeps an in-memory branch which would cause issues if altered; so any changes will be picked up automatically whenever a command is run.

The only potential issue would be running a lib.install in MCP DURING a similar pull/lib.install in UCM, in which case one or the other update would be clobbered (but not corrupted or anything). It's worth looking into improving this.

  • Adds ability to specify locking strategy when obtaining a codebase. MCP server doesn't lock or check for an existing lock on the codebase.
  • Adds the ucm mcp command for agents to call as a STDIO mcp server (the standard method)
  • Adds a dozen AI agent tools
  • The current tools are mostly implemented by running the HandleInput loop with the appropriate input events and then returning the captured output to the AI, so it's very similar to the AI using UCM directly, just with a few hints (and restrictions) on what inputs it can provide.
  • Adds a guide for setting up mcp in ./docs/mcp.md

Testing

Paul and I have been experimenting with this branch, it's not an exact science since you just interact with the AI via prompts and stuff.

We don't have a transcript testing strategy for the STDIO MCP command, but see the MCP HTTP server PR adds transcript tests: #5788

@ChrisPenner ChrisPenner changed the title [EXPERIMENTAL] Integrated MCP server Integrated MCP server Jul 1, 2025
@ChrisPenner ChrisPenner marked this pull request as ready for review July 1, 2025 20:48
@ChrisPenner ChrisPenner changed the base branch from trunk to topic/cacherootmtl August 2, 2025 06:33
@ChrisPenner ChrisPenner changed the base branch from topic/cacherootmtl to trunk August 2, 2025 06:34
"args": ["mcp"]
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why Github is freaking out here.

stack.yaml Outdated
Comment on lines 62 to 65
# - github: ChrisPenner/hs-mcp
# commit: e903b3e63ec74057d35aa9fe82613f165f2f7b9f
- github: ChrisPenner/hs-mcp
commit: 14fe82d086a04e82b1c05d7f5a4bbd30eec22042
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need both of these?

@pchiusano
Copy link
Member

Nice.

One suggestion for the prompts - just fetch them on use from https://github.com/unisoncomputing/unison-llm-support/tree/main

I imagine we'll do a bunch more iteration on them... pretty much every time I use it I end up making tweaks so I'd rather not bundle the text with UCM until they're a bit more stable.

I also had an idea for standardizing prompts. It's maybe out of scope for this PR, but the gist is you put some definitions in the prompts namespace.

-- a description of the prompt
prompts.writeJsonEncoder.doc: Doc

-- the prompt itself
prompts.writeJsonEncoder : Doc

-- overview of all the prompts, optional
prompts : Doc

Then there could be standard MCP commands to list available prompts for a project and/or load them as context. The prompts don't need to repeat the docs, they might literally say "read the docs for this function, then view the source for this definition blah blah blah"

What I've observed is that the generic prompts can be relatively effective, but a more specialized prompt can be even better.

@ChrisPenner
Copy link
Member Author

@pchiusano Ah, good idea, I'll merge this with the concrete file but will look at changing that.

@ChrisPenner ChrisPenner merged commit dc4e186 into trunk Aug 5, 2025
39 of 45 checks passed
@ChrisPenner ChrisPenner deleted the mcp/init branch August 5, 2025 20:21
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.

4 participants