Skip to content

[FEATURE]:Add non-interactive mode for opencode mcp add #18581

@sanathusk

Description

@sanathusk

Problem Statement

The current opencode mcp add command only supports interactive mode, requiring users to manually input server name, type, and command/URL through prompts. This makes it difficult to automate MCP server setup in scripts, add multiple servers efficiently, use in CI/CD pipelines, or share exact server configurations with teams.

Proposed Solution

Add support for non-interactive syntax to the McpAddCommand that accepts server name and command as arguments:

opencode mcp add name command

Examples:

  • opencode mcp add playwright npx @playwright/mcp@latest
  • opencode mcp add filesystem opencode x @modelcontextprotocol/server-filesystem /path/to/dir

Implementation Details

The non-interactive mode should:

  1. Accept server name as first argument
  2. Accept command as second argument (quoted if contains spaces)
  3. Default to local type (most common use case)
  4. Use project config scope by default (can add --global flag for global scope)
  5. Maintain backward compatibility with interactive mode when no arguments provided

Benefits

  • Automation: Enables script-based MCP server setup
  • CI/CD Integration: Allows automated environment configuration
  • Documentation: Exact commands can be shared in documentation
  • Efficiency: Faster addition of known server configurations
  • Backward Compatibility: Existing interactive workflow remains unchanged

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions