jj
jj copied to clipboard
FR: Add MCP support
Is your feature request related to a problem? Please describe.
AI tools are more familiar with git but jj fits their natural style better if anything. Its simplicity also helps models not go into death loops.
Describe the solution you'd like
Expose the common functions (like undo =) ) as tools with docs for MCP.
Describe alternatives you've considered
DIY
I'm guessing you mean https://modelcontextprotocol.io/introduction? I don't know much about it, I just searched the web for "MCP".
Could you explain in a bit more detail what it would mean to expose jj's functions to MCP and what use-cases this would allow? For example, what would be the smallest change with the most bang-for-the-buck, and why?
Is there anything analogous for Git or other VCS?
@ilyagr Is there anything analogous for Git or other VCS?
This is the official Git MCP server: https://github.com/modelcontextprotocol/servers/tree/main/src/git
As an example: https://github.com/modelcontextprotocol/servers/blob/main/src/git/src/mcp_server_git/server.py#L100-L110
def git_log(repo: git.Repo, max_count: int = 10) -> list[str]:
commits = list(repo.iter_commits(max_count=max_count))
log = []
for commit in commits:
log.append(
f"Commit: {commit.hexsha}\n"
f"Author: {commit.author}\n"
f"Date: {commit.authored_datetime}\n"
f"Message: {commit.message}\n"
)
return log
@alok Expose the common functions (like undo =) ) as tools with docs for MCP.
MCP is a text-based protocol over stdio/stdout or HTTP. The official SDKs for it are available in Python and TypeScript. But there are people interested in Rust MCP servers: https://github.com/conikeec/mcpr. I think the easiest MVP approach is to use a Rust MCP server SDK for some small subset of jj commands like log, status, and check it works.
I'm not sure however if the PR belongs in this repo, or a new repo for a new Rust crate that depends on jj-lib.
I'm interested in both jujutsu and MCP servers and I'm happy to look into this. If there are docs on jj-lib or anyone with advice, comments, interest, please let me know.
Could you explain in a bit more detail what it would mean to expose jj's functions to MCP and what use-cases this would allow?
My understanding, as someone who learned about MCP literally yesterday, is that this would allow for jj to interact better with various chat-based LLM tools. So like, people could ask Claude or whatever, "what revset should i use to do
It the abstract, I can always ask these tools for examples of how to do things, but with MCP, they can answer questions about my repository directly, and act on it, rather than just answer general questions.
I think it might make sense to make a crate similar to a TUI/GUI crate. It might have to depend on both jj-lib and jj-cli (like https://github.com/gulbanana/gg, https://github.com/jakobhellermann/kahva), or it could convert MCP commands to jj CLI (like https://github.com/tim-janik/jj-fzf, https://github.com/Cretezy/lazyjj).
At this point, MCP is sort of on the way out. At the minimum, I think the right way to move forward with this idea is to have someone build said MCP out of tree, and if it truly proved valuable, consider upstreaming it.
(I use jj with claude daily and haven't felt the need for an MCP server, so I'm skeptical, but I also don't want to rain on anyone's parade who does somehow find this maybe useful.)
I agree, I think it's become like git to the models albeit with rough edges. I'm happy to close the issue.
More context-efficient would be to build a jj Skill (in the Claude sense).
I have an initial stab at that in my jj mod of the superpowers plugin: https://github.com/KingMob/superpowers-jj
Okay, I am going to close this one for now, but if anyone in the future has an implementation they'd like to upstream, we can talk about that concretely.