feat: support both command array and command string + args formats#3
Conversation
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 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. |
|
Good catch! You're right — oh-my-opencode uses Current state:
I'll add normalization for this as well. The fix will:
|
…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
There was a problem hiding this comment.
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()andnormalizeEnv()utility functions to unify both configuration formats - Updated
McpServerConfigtype to support both formats with optionalargsfield and flexibleenvfield - 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.
- 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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@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>
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Summary
normalizeCommand()utility to unify both MCP command formatsMcpServerConfigtype to include optionalargsfieldFormats Supported
OpenCode format (command as array):
oh-my-opencode format (command string + args):
Testing
Closes #1