Description
In cmd/mcp/server.go, buildArgs processes named flags from flagMappings and appends remaining string values as positional arguments. For tools that require ordered positionals (like diff which needs oldFile before newFile), there is no mechanism to guarantee argument order.
Steps to Reproduce
Call diff via MCP with:
{"oldPath": "/tmp/a.go", "newPath": "/tmp/b.go"}
Since Go map iteration is unordered, buildArgs may emit /tmp/b.go /tmp/a.go — reversing the diff.
Affected Tools
diff (oldPath, newPath must be ordered)
head/tail with multiple files
- Any future tool with ordered positional semantics
Proposed Fix
Add an orderedPositionals []string field to the flag mapping definition that explicitly names keys in the order they should appear as positional arguments:
"diff": {
flags: map[string]string{...},
positionals: []string{"oldPath", "newPath"},
}
Related
cmd/mcp/server.go buildArgs, flagMappings
Description
In
cmd/mcp/server.go,buildArgsprocesses named flags fromflagMappingsand appends remaining string values as positional arguments. For tools that require ordered positionals (likediffwhich needsoldFilebeforenewFile), there is no mechanism to guarantee argument order.Steps to Reproduce
Call
diffvia MCP with:{"oldPath": "/tmp/a.go", "newPath": "/tmp/b.go"}Since Go map iteration is unordered,
buildArgsmay emit/tmp/b.go /tmp/a.go— reversing the diff.Affected Tools
diff(oldPath, newPath must be ordered)head/tailwith multiple filesProposed Fix
Add an
orderedPositionals []stringfield to the flag mapping definition that explicitly names keys in the order they should appear as positional arguments:Related
cmd/mcp/server.gobuildArgs,flagMappings