Skip to content

FR: Add MCP support #6146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alok opened this issue Mar 27, 2025 · 4 comments
Open

FR: Add MCP support #6146

alok opened this issue Mar 27, 2025 · 4 comments

Comments

@alok
Copy link

alok commented Mar 27, 2025

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

@ilyagr
Copy link
Contributor

ilyagr commented Mar 27, 2025

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?

@asimihsan
Copy link

asimihsan commented Mar 27, 2025

@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.

@steveklabnik
Copy link
Contributor

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 ?" or even stuff like "please rebase these three branches for me" and it would be able to do it.

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.

@ilyagr
Copy link
Contributor

ilyagr commented Mar 27, 2025

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).

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

No branches or pull requests

4 participants