Repository navigation
Description
Description
ProcessFlags in cmd/mcptools/commands/utils.go scans the entire argument list of tools, resources, prompts and guard and removes every occurrence of -f, --format, --transport, --server-logs, --auth-user and --auth-header, together with the value that follows. It does not stop at the server command, so these flags are also removed when they belong to the MCP server being launched.
Many servers take -f (file or config) or --transport as their own options. With mcptools, those arguments never reach the server, and the value is silently applied to mcptools instead. For example, -f settings.yaml sets the output format to settings.yaml, which is not even a valid format, yet no error is raised.
Steps to Reproduce
A minimal stdio server that records the arguments it received:
# /tmp/srv.py
import sys, json
open('/tmp/srv_argv.txt', 'w').write(json.dumps(sys.argv[1:]))
for line in sys.stdin:
m = json.loads(line)
if 'id' not in m:
continue
if m['method'] == 'initialize':
r = {"protocolVersion": "2024-11-05", "capabilities": {"tools": {}},
"serverInfo": {"name": "s", "version": "1"}}
else:
r = {"tools": []}
print(json.dumps({"jsonrpc": "2.0", "id": m['id'], "result": r}), flush=True)go build -o /tmp/mcpt ./cmd/mcptools
/tmp/mcpt tools python3 /tmp/srv.py -f settings.yaml
cat /tmp/srv_argv.txt # []
/tmp/mcpt tools python3 /tmp/srv.py --transport stdio
cat /tmp/srv_argv.txt # []Expected Behavior
There should be a way to pass these arguments to the server. The README documents trailing mcptools flags (for example mcp call ... npx -y @modelcontextprotocol/server-everything -f json), so the trailing form needs to keep working, but a -- separator should end mcptools option parsing so that mcp tools -- python3 /tmp/srv.py -f settings.yaml delivers ["-f", "settings.yaml"] to the server. At minimum, an invalid format value should be reported instead of silently accepted.
Actual Behavior
The server receives [] in both cases. The command exits with status 0 and no warning, and the invalid format settings.yaml is accepted.
Environment
- mcptools:
masterbuilt from source - Go 1.x, Linux
Possible Solution
- In
ProcessFlags, treat--as the end of mcptools options: copy everything after it to the server command unchanged. - Document the separator next to the existing
-f jsonexamples in the README. - Validate the format value with
IsValidFormatand return an error for unknown values, so a swallowed server argument is at least visible.
func ProcessFlags(args []string) []string {
parsedArgs := []string{}
for i := 0; i < len(args); i++ {
switch {
case args[i] == "--":
return append(parsedArgs, args[i+1:]...)
case (args[i] == FlagFormat || args[i] == FlagFormatShort) && i+1 < len(args):
FormatOption = args[i+1]
i++
// ... other mcptools flags unchanged ...
default:
parsedArgs = append(parsedArgs, args[i])
}
}
return parsedArgs
}I'm happy to send a PR.
Activity