Objective
Replace the hardcoded mcpToolParams() map in mcp_argument_validation.go with reflection-based extraction of JSON tag names from tool input structs, eliminating a known maintenance hazard.
Context
From discussion #30108 (Go Fan module review): mcp_argument_validation.go contains a hardcoded map of tool names to valid parameter names, marked with a // MAINTENANCE: comment acknowledging the drift risk. The same reflection pass used for JSON schema generation can auto-extract JSON tag names.
Approach
- Locate
mcpToolParams() in pkg/cli/mcp_argument_validation.go
- Instead of the static map, register tool input struct types alongside tool registration
- Use
reflect to iterate the struct's fields and collect json tag names at startup
- Replace the hardcoded map lookup with the reflected names
- Remove the
// MAINTENANCE: comment and hardcoded entries
Alternatively, build the map once at server init by passing tool input struct types to the validation setup.
Files to Modify
pkg/cli/mcp_argument_validation.go — replace hardcoded map with reflection
pkg/cli/mcp_server.go — pass struct type info to validation setup if needed
pkg/cli/mcp_argument_validation_test.go — update/add tests
Acceptance Criteria
Generated by Plan Command for issue #discussion #30108 · ● 308.5K · ◷
Objective
Replace the hardcoded
mcpToolParams()map inmcp_argument_validation.gowith reflection-based extraction of JSON tag names from tool input structs, eliminating a known maintenance hazard.Context
From discussion #30108 (Go Fan module review):
mcp_argument_validation.gocontains a hardcoded map of tool names to valid parameter names, marked with a// MAINTENANCE:comment acknowledging the drift risk. The same reflection pass used for JSON schema generation can auto-extract JSON tag names.Approach
mcpToolParams()inpkg/cli/mcp_argument_validation.goreflectto iterate the struct's fields and collectjsontag names at startup// MAINTENANCE:comment and hardcoded entriesAlternatively, build the map once at server init by passing tool input struct types to the validation setup.
Files to Modify
pkg/cli/mcp_argument_validation.go— replace hardcoded map with reflectionpkg/cli/mcp_server.go— pass struct type info to validation setup if neededpkg/cli/mcp_argument_validation_test.go— update/add testsAcceptance Criteria
mcpToolParams()no longer contains a hardcoded list of parameter namesmake test-unitpasses