-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add brew mcp-server
: a MCP server for Homebrew.
#20041
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a new brew mcp-server
command that launches a standalone Ruby MCP (Model Context Protocol) server for Homebrew, along with documentation, shell completions, and tests.
- Introduces the MCP server implementation and its test suite
- Updates manpages and markdown docs for the new command
- Adds bash, zsh, and fish completions plus the shell wrapper and command registration in
brew.sh
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
manpages/brew.1 | Bumped manpage date and added mcp-server entry |
docs/Manpage.md | Added mcp-server section and --debug flag |
completions/zsh/_brew | Added _brew_mcp_server function and command list |
completions/internal_commands_list.txt | Registered mcp-server in internal commands list |
completions/fish/brew.fish | Added fish completion for mcp-server |
completions/bash/brew | Added _brew_mcp_server and hook in command case |
Library/Homebrew/test/mcp_server_spec.rb | New RSpec tests covering MCP server behavior |
Library/Homebrew/mcp_server.rb | Core MCP server implementation in Ruby |
Library/Homebrew/cmd/mcp-server.sh | Shell wrapper to invoke the MCP server faster |
Library/Homebrew/cmd/mcp-server.rb | Homebrew command definition for mcp-server |
Library/Homebrew/brew.sh | Registered mcp-server in the main brew.sh |
Comments suppressed due to low confidence (1)
Library/Homebrew/cmd/mcp-server.sh:13
- [nitpick] The shell wrapper for
mcp-server
isn't covered by any integration or unit tests. Adding a test to verify thathomebrew-mcp-server
is invoked correctly would help prevent regressions in the CLI entry point.
"${HOMEBREW_RUBY_PATH}" "-r${HOMEBREW_LIBRARY}/Homebrew/mcp_server.rb" -e "Homebrew::McpServer.new.run" "$@"
35041bb
to
63a5e15
Compare
Add a new `brew mcp-server` command for a Model Context Protocol (MCP) server for Homebrew. This integrates with AI/LLM tools like Claude, Claude Code and Cursor. It currently supports the calls needed/used by the MCP Inspector and Cursor (where I've tested it). It provides as `tools` the subcommands output by `brew help` but should be fairly straightforward to add more in future. It is implemented in a slightly strange way (a standalone Ruby command called from a shell command) as MCP servers need a faster startup time than a normal Homebrew Ruby command allows and fail if they don't get it. There are a few Ruby libraries available but, given how relatively simplistic the implementation is, it didn't feel worthwhile to use and vendor them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
In the future if we want to enable more functionality, I bet we could extract a lot of the tool definitions from the command DSLs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
@Rylan12 Yeh, I was thinking the same. We'd need to do something like dump it to a JSON and use that, though, because we're so constrained on startup time and because we'd only want to support a subset of commands to not go over the (current) 40 maximum. |
It would probably be easiest to just work this into the manpage generation since that's doing functionally the same thing, regardless. I think while there's the limit of 40 though, let's just keep it manual. These tools are unlikely to change since only the most basic invocations are really important for now, I think |
Good job! |
Add a new
brew mcp-server
command for a Model Context Protocol (MCP) server for Homebrew. This integrates with AI/LLM tools like Claude, Claude Code and Cursor.It currently supports the calls needed/used by the MCP Inspector and Cursor (where I've tested it).
It provides as
tools
the subcommands output bybrew help
but should be fairly straightforward to add more in future.It is implemented in a slightly strange way (a standalone Ruby command called from a shell command) as MCP servers need a faster startup time than a normal Homebrew Ruby command allows and clients such as Cursor fail if they don't get a response quickly enough.
There are a few Ruby libraries available but, given how relatively simplistic the implementation is, it didn't feel worthwhile to use and vendor them.