Skip to content

Conversation

ndraiman
Copy link
Contributor

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

ndraiman and others added 12 commits June 24, 2025 22:45
- Modified McpListCommand to display both user and project scope MCP servers
- Added clear section headers to distinguish between global and project servers
- Added test coverage for listing servers from both scopes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update mcp get command to search both user and project configurations
- Prioritize project config over global when both contain the same server name
- Display scope (user/project) in output to show where server was found
- Add headers display for remote servers when present
- Add comprehensive test coverage for scope priority and header display

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thdxr
Copy link
Contributor

thdxr commented Jun 25, 2025

wow i was gonna work on this - i'll take a look ty!

@ndraiman
Copy link
Contributor Author

Thank you. 🙏🏻

I didn't implement the full list of sub-commands like in claude mcp because I didn't know how far you want to make it the same.

Commands I didn't implement:

  • serve
  • add-from-claude-desktop
  • reset-project-choices

Also Claude has "local" scope for mcp.

@aspiers
Copy link
Contributor

aspiers commented Jun 28, 2025

This sounds awesome, thanks a lot @ndraiman!

@ndraiman
Copy link
Contributor Author

  1. Updated to include support for enable / disable commands
  2. Fixed mcp.test file to use a mock local config instead of overriding the existing opencode.json in project root.

@thdxr thdxr self-assigned this Jul 2, 2025
ndraiman added 5 commits July 2, 2025 22:41
  - Mock Config.global() to bypass lazy cache and ensure test isolation
  - Replace UI function mocking with real stderr capture using spyOn
  - Update project config tests to use Config.get() instead of manual file parsing
  - Fix lint errors by using optional chaining bracket notation
  - Add proper spy cleanup in test teardown
@3dyuval
Copy link

3dyuval commented Jul 6, 2025

Hey, nice work! Do you plan to integrate /mcp commands (to TUI) next? I would love to help

@ndraiman
Copy link
Contributor Author

ndraiman commented Jul 9, 2025

Looking at the code architecture now, I see that I should have:

  1. Extracted logic to functions
  2. Exposed logic as server endpoints
  3. TUI will be able to control MCP configs via Client sdk

Hopefully I'll be able to this later today.

@3dyuval
Copy link

3dyuval commented Jul 9, 2025

Yes. I'd love to learn how the model, view, and the functional logic are clearly seperated in the solution.

@adamdotdevin
Copy link
Contributor

@ndraiman i don't think we need to support this in the tui, probably dont want to have to maintain all that; cli only is fine!

@Ramblurr
Copy link

Any /mcp slash command in the tui would be a big welcome to figure out the state of the configured mcp servers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants