1. Conduid
  2. Developer Tools
  3. Cobra MCP
MCP server · Developer Tools

Cobra MCP

Turn any Cobra CLI into an MCP server

Unclaimed Apache-2.0 devtools
59Fair

Scored 5 days ago · breakdown

About Cobra MCP

Cobra MCP is an MCP server published by eat-pray-ai in the Developer Tools category: turn any Cobra CLI into an MCP server.

The repository has 2 stars and 0 forks, with the last commit 16 days ago. Recent commit activity is the strongest signal that reported issues will get attention.

Install

From source
git clone https://github.com/eat-pray-ai/cobra-mcp

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about Cobra MCP

Powered by Claude · Grounded in docs

I know everything about Cobra MCP. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

Static checks derived from the repository 5 days ago. Heuristics on the source, not an audit.

  • ✓README presentThe repository ships documentation.
  • ✓License declaredUsable under a stated license.
  • ✓Tests presentA test suite exists in the repository.
  • ✓Dependencies pinnedA lockfile pins dependency versions.
  • ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
  • !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.

Releases

v0.4.8v0.4.8 · 6 Oct 2026Install go get github.com/eat-pray-ai/cobra-mcp@v0.4.8 Changes :memo: Document tool execution hook (@OpenWaygate) :sparkles: Add tool execution hook (@OpenWaygate) :arrow_up: Bump actions/setup-go from 6 to 7 (@dependabot[bot])
v0.4.7v0.4.7 · 5 Oct 2026Install go get github.com/eat-pray-ai/cobra-mcp@v0.4.7 Changes :arrow_up: Bump go deps (@OpenWaygate) :construction_worker: Improve dependency automation (@OpenWaygate) :sparkles: Pass context to resource handlers (@OpenWaygate) :sparkles:…
v0.4.5v0.4.5 · 30 Aug 2026Install go get github.com/eat-pray-ai/cobra-mcp@v0.4.5 Changes :wrench: Add contributor names to release notes (@OpenWaygate) :recycle: Apply modern Go guidelines (@OpenWaygate) :sparkles: Support MRTR with GenToolHandlerWithMRTR and…
v0.4.1v0.4.1 · 23 Aug 2026Install go get github.com/eat-pray-ai/cobra-mcp@v0.4.1 Changes :memo: Config deduplication and ListCacheTTL in README :recycle: Deduplicate Config and add ListCacheTTL
v0.4.0v0.4.0 · 23 Aug 2026Install go get github.com/eat-pray-ai/cobra-mcp@v0.4.0 Changes :recycle: Refactor cobramcp_test.go to table-driven tests :memo: Update example and README for MCP 2026-07-28 support :sparkles: Add stateless HTTP mode and HTTPOptions for MCP…

README

cobra-mcp

GitHub License Go Reference Go Coverage GitHub Actions test Status GitHub Release

Turn any Cobra CLI into an MCP server.

cobra-mcp gives you a pre-configured *mcp.Server and a mcp subcommand (stdio + HTTP) in one call. You keep full control over tool/resource/prompt schemas — the package handles wiring and transport.

Install

go get github.com/eat-pray-ai/cobra-mcp

Quick Start

See examples/main.go for a complete working example with tools, resources, and prompts.

server, mcpCmd := cobramcp.ServerAndCommand(&cobramcp.Config{
    Name: "myapp", Version: "0.1.0",
    ServerOptions: &mcp.ServerOptions{Instructions: "A demo CLI with MCP support"},
})

// Register a tool
mcp.AddTool(server, &mcp.Tool{...}, cobramcp.GenToolHandler("hello", hello))

// Optional: observe or block generated tool executions
cobramcp.SetDefaultToolExecutionHook(myHook)

// Register a resource
server.AddResource(&mcp.Resource{...}, cobramcp.GenResourceHandler("version", "application/json", version))

// Register a prompt
server.AddPrompt(&mcp.Prompt{...}, cobramcp.GenPromptHandler("review", review))

rootCmd.AddCommand(mcpCmd)
# Use as MCP server (stdio)
myapp mcp

# Use as MCP server (HTTP, stateless by default for MCP 2026-07-28)
myapp mcp --mode http --port 8080

# Use as MCP server (HTTP, bind all interfaces)
myapp mcp --mode http --port 8080 --host 0.0.0.0

# Use as MCP server (HTTP, stateful sessions for legacy clients)
myapp mcp --mode http --port 8080 --stateless=false

# Use as MCP server (HTTP with OAuth)
myapp mcp --mode http --port 8080 --baseUrl https://mcp.example.com

API

Function Signature Purpose
ServerAndCommand (cfg *Config) (*mcp.Server, *cobra.Command) Create MCP server + cobra command
GenToolHandler [T any](name string, op func(T, io.Writer) error) Typed tool handler with JSON deserialization
GenToolHandlerWithMRTR [T any](name string, op func(context.Context, *mcp.CallToolRequest, T, io.Writer) (*mcp.CallToolResult, error)) Typed tool handler with multi round-trip support
SetDefaultToolExecutionHook (hook ToolExecutionHook) Install or clear a process-wide generated-tool hook
GenResourceHandler (name, mimeType string, op func(context.Context, *mcp.ReadResourceRequest, io.Writer) error) Resource handler with MIME type
GenPromptHandler (name string, op func(*mcp.GetPromptRequest) ([]*mcp.PromptMessage, error)) Multi-message prompt handler

Config

Field Default Description
Name — Server implementation name
Version — Server implementation version
Auth nil OAuth config (HTTP only)
HTTPOptions nil Override *mcp.StreamableHTTPOptions (HTTP only)
ListCacheTTL 0 TTL hint (ms) on */list responses; 0 = no caching
ServerOptions nil *mcp.ServerOptions (Instructions, PageSize, KeepAlive, etc.)

PageSize defaults to 100 and KeepAlive defaults to 13s unless HTTPOptions.Stateless is true (no session to ping).

ContextAware

Tool input types implementing ContextAware receive the request context before the operation is invoked:

type ContextAware interface {
    SetContext(context.Context)
}

ToolExecutionHook

Generated tool handlers can be observed or blocked with a process-wide ToolExecutionHook:

type ToolExecutionHook interface {
    BeforeTool(ctx context.Context, toolName string, input any) error
    AfterTool(ctx context.Context, toolName string, input any, err error)
}

Install or clear the hook with:

cobramcp.SetDefaultToolExecutionHook(myHook)
cobramcp.SetDefaultToolExecutionHook(nil) // clear

BeforeTool runs after ContextAware injection and before the tool operation. If it returns an error, the operation is not called. AfterTool runs after the operation returns, including operation error cases. Existing generated handlers read the hook at execution time, so a hook can be installed after tools are registered.

Example:

type auditHook struct{}

func (auditHook) BeforeTool(ctx context.Context, toolName string, input any) error {
    slog.InfoContext(ctx, "tool starting", "tool", toolName, "input", input)
    return nil
}

func (auditHook) AfterTool(ctx context.Context, toolName string, input any, err error) {
    slog.InfoContext(ctx, "tool finished", "tool", toolName, "error", err)
}

cobramcp.SetDefaultToolExecutionHook(auditHook{})

AuthConfig

When Auth is set, the HTTP transport requires OAuth Bearer tokens. See examples/main.go and the AuthConfig godoc for details.

Design

  • Schema-first — you provide *jsonschema.Schema for each tool, no auto-generation
  • In-process — handlers call your Go functions directly, not via subprocess
  • Transport included — stdio and HTTP handled by the generated mcp command
  • OAuth built-in — optional MCP OAuth with auto-derived metadata
  • Hookable tools — generated tool handlers support centralized audit, policy, and rate-limit hooks

License

Apache-2.0

README fetched from the repository 5 days ago. The original is authoritative.

Questions

About Cobra MCP

How do I install Cobra MCP?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Cobra MCP safe to use with an AI agent?

Its trust score is 59 out of 100 (fair). It passes 5 of the 6 static security checks run so far; the failures are listed above. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Cobra MCP still maintained?

Yes — the latest release is v0.4.8 (6 Oct 2026), and the last commit was 16 days ago. The repository has 2 stars.