Skip to content

MCP server buildArgs cannot handle ordered positional arguments for tools like diff #29

@github-actions

Description

@github-actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions