fix(ui): preserve MCPServer argument ordering when creating stdio servers#2080
fix(ui): preserve MCPServer argument ordering when creating stdio servers#2080hawkli-1994 wants to merge 4 commits into
Conversation
…vers The UI was emitting the package name after the additional arguments, so a command like would produce args [-y, --stdio, package]. Build the args array in the same order shown in the command preview: [commandPrefix..., packageName, additionalArgs...]. Fixes kagent-dev#2078
There was a problem hiding this comment.
Pull request overview
This PR fixes stdio MCPServer CRD generation in the UI by ensuring the package name is placed before any additional arguments when constructing the args array, matching the command preview and expected executor semantics (e.g., npx -y <package> --stdio).
Changes:
- Added a shared
buildMCPServerArgshelper to consistently build stdio MCP server args in the correct order. - Updated
McpServerFormto use the helper for bothnpxanduvxcommand flows. - Added unit tests validating ordering, whitespace splitting of the prefix, and filtering of empty args.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ui/src/lib/toolUtils.ts | Adds buildMCPServerArgs helper to construct stdio MCPServer args in preview-consistent order. |
| ui/src/lib/tests/toolUtils.test.ts | Adds unit tests covering arg ordering and filtering behavior for the new helper. |
| ui/src/components/mcp/McpServerForm.tsx | Switches stdio server creation to use the shared args builder for both npx and uvx. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review comments: - Use consistent spacing. - Clarify that the executor (cmd) is supplied separately from the returned args array.
|
thanks for your PR! Could you sign the DCO and we can get this merged. |
|
quick quesstion: toolutils.ts:25 -- the old code always pushed packagename.trim() even when empty. the new guard silently skips an empty package name instead. is this intentional, or a side effect of the refactor? |
…kageName Replace ArgPair object wrapper with plain strings for argPairs across the form, helper, and tests. buildMCPServerArgs now always includes packageName (validated by the form before calling).
Fixes #2078
Problem
When creating an stdio MCPServer from the UI, the generated CRD placed the package name after the additional arguments. For example,
npx -y @modelcontextprotocol/server-map --stdioproduced:Fix
Build the args array in the same order shown in the command preview:
[commandPrefix..., packageName, additionalArgs...].Changes
buildMCPServerArgshelper inui/src/lib/toolUtils.ts.McpServerFormto use the helper for bothnpxanduvxflows.