[PR #371] [CLOSED] Added mcp CLI command #9598

Closed
opened 2026-02-16 18:13:49 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/371
Author: @ndraiman
Created: 6/24/2025
Status: Closed

Base: devHead: ndraiman/mcp-command


📝 Commits (10+)

  • 273b8b4 intial mcp command
  • 7d59ca2 cleanup
  • 86cfe94 Added scope and headers
  • cd31628 removed http transport from command options
  • 67d03a3 mcp tests
  • 139b7a1 tests cleanup
  • 98ed4dd tests
  • bfde2c5 Updated McpAddJsonCommand to determine local/remote based on command/url
  • 5ba54ac Update mcp list to show both global and project servers
  • 52dc2d0 Fix mcp get to check both global and project configs

📊 Changes

6 files changed (+1627 additions, -0 deletions)

View changed files

packages/opencode/src/cli/cmd/mcp.ts (+567 -0)
📝 packages/opencode/src/config/config.ts (+1 -0)
📝 packages/opencode/src/index.ts (+2 -0)
📝 packages/opencode/src/mcp/index.ts (+1 -0)
packages/opencode/test/cmd/mcp.test.ts (+938 -0)
📝 packages/web/src/content/docs/docs/cli.mdx (+118 -0)

📄 Description

Summary

  • Add comprehensive MCP (Model Context Protocol) server management CLI commands
  • Implement mcp add-json command with intelligent transport type inference
  • Support both stdio and SSE transport configurations with automatic validation

Changes

New CLI Commands

  • mcp add - Add MCP servers with stdio/SSE transport options
  • mcp remove - Remove configured MCP servers
  • mcp list - List all configured MCP servers
  • mcp get - Get details about a specific MCP server
  • mcp add-json - Add MCP servers using JSON configuration with automatic type inference

Key Features

  • Smart Type Inference: add-json command automatically determines local/remote type based on JSON
    structure
  • Transport Format Transformation: Converts flexible JSON formats to match internal schema
    requirements
  • Dual Scope Support: Configure servers at user or project level
  • Transport Validation: Enforces stdio/SSE constraints and validates inputs
  • Environment & Headers: Support for environment variables (stdio) and HTTP headers (SSE)

Technical Implementation

  • JSON schema validation with Zod
  • Automatic command/args merging for stdio transport
  • Environment variable mapping (env → environment)
  • Type field removal and inference from transport properties
  • Comprehensive error handling and user feedback

Test Coverage

  • Full test suite covering all commands and edge cases
  • Validation testing for transport constraints
  • Both user and project scope configuration testing
  • Error handling verification

🤖 Generated with https://claude.ai/code

Co-Authored-By: Claude


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/371 **Author:** [@ndraiman](https://github.com/ndraiman) **Created:** 6/24/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `ndraiman/mcp-command` --- ### 📝 Commits (10+) - [`273b8b4`](https://github.com/anomalyco/opencode/commit/273b8b421ff22a22e131c5ba1a0822d05e79148d) intial mcp command - [`7d59ca2`](https://github.com/anomalyco/opencode/commit/7d59ca2226fdc1ec89376368afcb924f344fae31) cleanup - [`86cfe94`](https://github.com/anomalyco/opencode/commit/86cfe94ab7c33f6dc53dd58e1f9faa3cf9a4037d) Added scope and headers - [`cd31628`](https://github.com/anomalyco/opencode/commit/cd316284a4c5c1734075fca0837e3642b00f73ca) removed http transport from command options - [`67d03a3`](https://github.com/anomalyco/opencode/commit/67d03a3b21e57f8f861ccb8306096aad461c9b54) mcp tests - [`139b7a1`](https://github.com/anomalyco/opencode/commit/139b7a12a6424a007db12faac71bd1dd4fba211c) tests cleanup - [`98ed4dd`](https://github.com/anomalyco/opencode/commit/98ed4dd8dbb4f7c0b505da9c39bc7bad35b33f3f) tests - [`bfde2c5`](https://github.com/anomalyco/opencode/commit/bfde2c5e71147c590b6a47aeab888cc1700978b1) Updated McpAddJsonCommand to determine local/remote based on command/url - [`5ba54ac`](https://github.com/anomalyco/opencode/commit/5ba54ac0e9298decfc4a762b338dc842c40ab5e7) Update mcp list to show both global and project servers - [`52dc2d0`](https://github.com/anomalyco/opencode/commit/52dc2d02a5cc22bb89bd606d6b4cf7beeec76c25) Fix mcp get to check both global and project configs ### 📊 Changes **6 files changed** (+1627 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `packages/opencode/src/cli/cmd/mcp.ts` (+567 -0) 📝 `packages/opencode/src/config/config.ts` (+1 -0) 📝 `packages/opencode/src/index.ts` (+2 -0) 📝 `packages/opencode/src/mcp/index.ts` (+1 -0) ➕ `packages/opencode/test/cmd/mcp.test.ts` (+938 -0) 📝 `packages/web/src/content/docs/docs/cli.mdx` (+118 -0) </details> ### 📄 Description Summary - Add comprehensive MCP (Model Context Protocol) server management CLI commands - Implement mcp add-json command with intelligent transport type inference - Support both stdio and SSE transport configurations with automatic validation Changes New CLI Commands - mcp add - Add MCP servers with stdio/SSE transport options - mcp remove - Remove configured MCP servers - mcp list - List all configured MCP servers - mcp get - Get details about a specific MCP server - mcp add-json - Add MCP servers using JSON configuration with automatic type inference Key Features - Smart Type Inference: add-json command automatically determines local/remote type based on JSON structure - Transport Format Transformation: Converts flexible JSON formats to match internal schema requirements - Dual Scope Support: Configure servers at user or project level - Transport Validation: Enforces stdio/SSE constraints and validates inputs - Environment & Headers: Support for environment variables (stdio) and HTTP headers (SSE) Technical Implementation - JSON schema validation with Zod - Automatic command/args merging for stdio transport - Environment variable mapping (env → environment) - Type field removal and inference from transport properties - Comprehensive error handling and user feedback Test Coverage - Full test suite covering all commands and edge cases - Validation testing for transport constraints - Both user and project scope configuration testing - Error handling verification 🤖 Generated with https://claude.ai/code Co-Authored-By: Claude --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:13:49 -05:00
yindo closed this issue 2026-02-16 18:13:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9598