ophis
Transform any Cobra CLI into an MCP server
claude mcp add --transport stdio njayp-ophis go get -u github.com/njayp/ophis \ --env GO111MODULE="on"
How to use
Ophis automatically converts your Cobra-based CLI into MCP tools. It inspects your Cobra command tree, exposes each command and flag as MCP tools, and provides CLI subcommands to manage integration with editing environments like Claude Desktop, VSCode, and Cursor. You can then start the MCP server to expose these tools over standard input/output or via HTTP streaming for remote access. The server can generate tool schemas, spawn your CLI as a subprocess to execute commands, and offer a JSON export of available tools for tooling integrations. Use the start command to run on stdio, the stream command to expose an HTTP interface, and the tools command to view the available MCP tools. You can also enable the server in Claude Desktop, VSCode, or Cursor so those tools show up in those editors and environments.
How to install
Prerequisites:
- Go (1.18+ preferred)
- Basic knowledge of your Cobra-based CLI project
Install the Ophis MCP server:
-
Install directly from the repository: go get github.com/njayp/ophis
-
Build and install (optional if you want a local binary): go build -o ophis ./...
-
Integrate Ophis with your CLI: // Example usage in your main function (as per README): rootCmd := createMyRootCommand() rootCmd.AddCommand(ophis.Command(nil))
-
Run the MCP server (after building) to start serving MCP tools via stdio or HTTP as described in the Quick Start:
- Start MCP server on stdio: ./my-cli mcp start
- Stream over HTTP: ./my-cli mcp stream --host localhost --port 8080
Prerequisites recap:
- Go installed and configured
- Your Cobra-based CLI ready
- Ophis imported and wired into your root command as shown in the documentation
Additional notes
Tips and considerations:
- The default MCP command name is mcp, but you can customize it via Ophis Config.CommandName to avoid collisions with existing commands.
- Use DefaultEnv to capture and merge environment variables (notably PATH) for editor subprocesses on macOS where PATH might be limited.
- The tool discovery process respects your selectors to expose only desired commands and flags. You can customize which commands/flags are exposed and optionally wrap execution with middleware.
- If you plan to expose over HTTP, ensure appropriate security considerations, e.g., access controls and network exposure.
- The stream feature enables remote access; consider deploying behind a reverse proxy or firewall as appropriate.
Related MCP Servers
sandbox
A Model Context Protocol (MCP) server that enables LLMs to run ANY code safely in isolated Docker containers.
tasker
An MCP server for Android's Tasker automation app.
homebutler
🏠 Manage your homelab from chat. Single binary, zero dependencies.
shipyard-cli
The Shipyard CLI and MCP server enable you to manage ephemeral environments from your terminal or from your AI agent.
interop
Interop CLI: Go command-line tool for efficient project management and command execution across your development workspace.
backlog
Help coding agents and developers to keep track of a project's backlog by storing tasks as markdown in git.