{"id":46963484,"url":"https://github.com/njayp/ophis","last_synced_at":"2026-03-11T10:02:47.243Z","repository":{"id":298204735,"uuid":"999178698","full_name":"njayp/ophis","owner":"njayp","description":"Transform any Cobra CLI into an MCP server","archived":false,"fork":false,"pushed_at":"2026-02-14T02:15:13.000Z","size":6890,"stargazers_count":75,"open_issues_count":2,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-14T08:58:04.509Z","etag":null,"topics":["cli","cobra","cobra-cli","go","golang","golang-library","mcp","mcp-server","open-source"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/njayp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"njayp"}},"created_at":"2025-06-09T21:28:39.000Z","updated_at":"2026-02-14T02:15:10.000Z","dependencies_parsed_at":"2025-06-10T00:21:19.520Z","dependency_job_id":"144f7f8c-4b2c-45c2-9679-e0e19f4473eb","html_url":"https://github.com/njayp/ophis","commit_stats":null,"previous_names":["njayp/ophis"],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/njayp/ophis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njayp%2Fophis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njayp%2Fophis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njayp%2Fophis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njayp%2Fophis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/njayp","download_url":"https://codeload.github.com/njayp/ophis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njayp%2Fophis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30377837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cobra","cobra-cli","go","golang","golang-library","mcp","mcp-server","open-source"],"created_at":"2026-03-11T10:02:46.531Z","updated_at":"2026-03-11T10:02:47.234Z","avatar_url":"https://github.com/njayp.png","language":"Go","funding_links":["https://github.com/sponsors/njayp"],"categories":[],"sub_categories":[],"readme":"![Project Logo](./logo.png)\n\n**Transform any Cobra CLI into an MCP server**\n\nOphis automatically converts your Cobra commands into MCP tools, and provides CLI commands for integration with Claude Desktop, VSCode, and Cursor.\n\n## Quick Start\n\n### Install\n\n```bash\ngo get github.com/njayp/ophis\n```\n\n### Add to your CLI\n\n```go\npackage main\n\nimport (\n    \"os\"\n    \"github.com/njayp/ophis\"\n)\n\nfunc main() {\n    rootCmd := createMyRootCommand()\n    rootCmd.AddCommand(ophis.Command(nil))\n\n    if err := rootCmd.Execute(); err != nil {\n        os.Exit(1)\n    }\n}\n```\n\n### Enable in Claude Desktop, VSCode, or Cursor\n\n```bash\n# Claude Desktop\n./my-cli mcp claude enable\n# Restart Claude Desktop\n\n# VSCode (requires Copilot in Agent Mode)\n./my-cli mcp vscode enable\n\n# Cursor\n./my-cli mcp cursor enable\n```\n\nYour CLI commands are now available as MCP tools!\n\n### Stream over HTTP\n\nExpose your MCP server over HTTP for remote access:\n\n```bash\n./my-cli mcp stream --host localhost --port 8080\n```\n\n## Commands\n\nThe `ophis.Command(nil)` adds these subcommands to your CLI (the default command name is `mcp`, configurable via `Config.CommandName`):\n\n```\nmcp\n├── start            # Start MCP server on stdio\n├── stream           # Stream MCP server over HTTP\n├── tools            # Export available MCP tools as JSON\n├── claude\n│   ├── enable       # Add server to Claude Desktop config\n│   ├── disable      # Remove server from Claude Desktop config\n│   └── list         # List Claude Desktop MCP servers\n├── vscode\n│   ├── enable       # Add server to VSCode config\n│   ├── disable      # Remove server from VSCode config\n│   └── list         # List VSCode MCP servers\n└── cursor\n    ├── enable       # Add server to Cursor config\n    ├── disable      # Remove server from Cursor config\n    └── list         # List Cursor MCP servers\n```\n\n## Configuration\n\nControl which commands and flags are exposed as MCP tools using selectors. By default, all commands and flags are exposed (except hidden/deprecated).\n\n```go\nconfig := \u0026ophis.Config{\n    Selectors: []ophis.Selector{\n        {\n            CmdSelector: ophis.AllowCmdsContaining(\"get\", \"list\"),\n            LocalFlagSelector: ophis.ExcludeFlags(\"token\", \"secret\"),\n            InheritedFlagSelector: ophis.NoFlags,  // Exclude persistent flags\n\n            // Middleware wraps command execution\n            Middleware: func(ctx context.Context, req *mcp.CallToolRequest, in ophis.ToolInput, next func(context.Context, *mcp.CallToolRequest, ophis.ToolInput) (*mcp.CallToolResult, ophis.ToolOutput, error)) (*mcp.CallToolResult, ophis.ToolOutput, error) {\n                ctx, cancel := context.WithTimeout(ctx, time.Minute)\n                defer cancel()\n                return next(ctx, req, in)\n            },\n        },\n    },\n}\n\nrootCmd.AddCommand(ophis.Command(config))\n```\n\n### Custom Command Name\n\nBy default the ophis command is named `mcp`. If your CLI already uses `mcp` for something else, set `CommandName` to avoid the collision:\n\n```go\nconfig := \u0026ophis.Config{\n    CommandName: \"agent\",\n}\n\nrootCmd.AddCommand(ophis.Command(config))\n```\n\nThe command tree, editor config (`enable`/`disable`), and internal filters all use the configured name automatically.\n\n### Default Environment Variables\n\nEditors launch MCP server subprocesses with a minimal environment. On macOS this means a PATH of just `/usr/bin:/bin:/usr/sbin:/sbin`, so tools like `helm`, `kubectl`, or `docker` installed via mise/homebrew/nix won't be found. Use `DefaultEnv` to capture the current PATH (or any other variables) at `enable` time:\n\n```go\nconfig := \u0026ophis.Config{\n    DefaultEnv: map[string]string{\n        \"PATH\": os.Getenv(\"PATH\"),\n    },\n}\n\nrootCmd.AddCommand(ophis.Command(config))\n```\n\nThese are merged into the editor config written by `enable`. User-provided `--env` values take precedence on conflict.\n\nSee [docs/config.md](docs/config.md) for detailed configuration options.\n\n## How It Works\n\nOphis bridges Cobra commands and the Model Context Protocol:\n\n1. **Command Discovery**: Recursively walks your Cobra command tree\n2. **Schema Generation**: Creates JSON schemas from command flags and arguments ([docs/schema.md](docs/schema.md))\n3. **Tool Execution**: Spawns your CLI as a subprocess and captures output ([docs/execution.md](docs/execution.md))\n\n## Contributing\n\nContributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnjayp%2Fophis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnjayp%2Fophis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnjayp%2Fophis/lists"}