Skip to content

feat: support both command array and command string + args formats#3

Merged
keybrdist merged 8 commits into
mainfrom
feat/dual-command-format-support
Jan 18, 2026
Merged

feat: support both command array and command string + args formats#3
keybrdist merged 8 commits into
mainfrom
feat/dual-command-format-support

Conversation

@keybrdist

Copy link
Copy Markdown
Owner

Summary

  • Adds normalizeCommand() utility to unify both MCP command formats
  • Updated McpServerConfig type to include optional args field
  • Added vitest test suite with 9 tests covering both formats and edge cases

Formats Supported

OpenCode format (command as array):

mcp:
  playwright:
    command: ["npx", "-y", "@playwright/mcp@latest"]

oh-my-opencode format (command string + args):

mcp:
  playwright:
    command: npx
    args: ["-y", "@anthropic-ai/mcp-playwright"]

Testing

npm test
# 9 tests pass

Closes #1

Adds cross-ecosystem compatibility for MCP server definitions:
- OpenCode format: command: ["npx", "-y", "@some/mcp-server"]
- oh-my-opencode format: command: "npx", args: ["-y", "@some/mcp-server"]

Closes #1
@keybrdist

Copy link
Copy Markdown
Owner Author

@keybrdist are environments handled as well? I believe there was a slight variation between omo and opencode re: env vs. environment. Maybe I'm wrong so please check.

@keybrdist

Copy link
Copy Markdown
Owner Author

Good catch! You're right — oh-my-opencode uses env while OpenCode uses environment.

Current state:

  • command + args → handled ✅
  • env vs environmentnot handled

I'll add normalization for this as well. The fix will:

  1. Accept both env and environment in McpServerConfig
  2. Normalize to environment internally (matching OpenCode's convention)
  3. Add tests for the env normalization

…bility

- Rename 'environment' to 'env' to align with both OpenCode and oh-my-opencode
- Support both object format { KEY: 'value' } and array format ['KEY=value']
- Add normalizeEnv() function to convert array to object format
- Add 8 tests for env normalization covering all formats and edge cases
- Update README with configuration examples for both formats

Citations:
- OpenCode uses env (array): github.com/opencode-ai/opencode/blob/main/cmd/schema/main.go#L133
- oh-my-opencode uses env (object): github.com/code-yeongyu/oh-my-opencode/blob/dev/src/features/skill-mcp-manager/manager.test.ts
Copilot AI review requested due to automatic review settings January 18, 2026 08:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for two MCP command configuration formats to improve compatibility between OpenCode and oh-my-opencode. The changes enable users to specify commands either as an array (e.g., ["npx", "-y", "@some/mcp"]) or as a string with separate args (e.g., command: "npx", args: ["-y", "@some/mcp"]). Similarly, environment variables can be specified as either an object or an array of KEY=value strings.

Changes:

  • Added normalizeCommand() and normalizeEnv() utility functions to unify both configuration formats
  • Updated McpServerConfig type to support both formats with optional args field and flexible env field
  • Added comprehensive vitest test suite with 15 tests covering both formats and edge cases
  • Updated error messages to reflect both supported formats
  • Added documentation and examples for both configuration styles

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vitest.config.ts New vitest configuration for running tests in src/**/*.test.ts
src/types.ts Updated McpServerConfig interface to support both command/env formats; renamed environment to env (breaking change); added NormalizedCommand and NormalizedEnv interfaces
src/utils/env-vars.ts Added normalizeCommand() and normalizeEnv() functions to convert both formats to normalized form
src/skill-mcp-manager.ts Updated to use new normalize functions and improved error messages to show both supported formats
src/tests/normalize-command.test.ts New comprehensive test suite with 15 tests covering command and env normalization
package.json Added vitest as dev dependency and test scripts
package-lock.json Updated dependencies including vitest 4.0.17 and related packages
README.md Updated documentation with examples for both configuration formats

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/env-vars.ts
Comment thread src/__tests__/normalize-command.test.ts
Comment thread src/utils/env-vars.ts
Comment thread src/types.ts
- Use client.config.get() to detect active plugins via OpenCode SDK
- Check if oh-my-opencode is in the plugin array
- If detected, return empty hooks to avoid duplicate skill/skill_mcp tools
- Add OPENCODE_LAZY_LOADER_FORCE=1 env var to override for testing
- Update AGENTS.md with detection logic documentation
- Throw error when command array is empty
- Add deprecated 'environment' field for backward compatibility
- normalizeEnv now checks both env and environment (env takes precedence)
- Add 3 new tests: empty array, deprecated field, precedence
Copilot AI review requested due to automatic review settings January 18, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/env-vars.ts
Comment thread src/__tests__/normalize-command.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.ts Outdated
Comment thread src/index.ts

Copilot AI commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

@keybrdist I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 18, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

[WIP] Fix command array and string support implementation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@keybrdist keybrdist merged commit 18941a1 into main Jan 18, 2026
6 checks passed
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.

Support both command: [] array and command: string + args: [] formats for MCP definitions

3 participants