Get the FREE Ultimate OpenClaw Setup Guide →

ophis

Transform any Cobra CLI into an MCP server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Install directly from the repository: go get github.com/njayp/ophis

  2. Build and install (optional if you want a local binary): go build -o ophis ./...

  3. Integrate Ophis with your CLI: // Example usage in your main function (as per README): rootCmd := createMyRootCommand() rootCmd.AddCommand(ophis.Command(nil))

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

Sponsor this space

Reach thousands of developers