Add custom port/address parameter to --mcp flag with optional value support
Plan: Add custom port support for --mcp parameter
- [x] Change
--mcpflag from boolean to string to accept custom port/address - [x] Update flag parsing in
common/flag.goto accept string value - [x] Update
common/config.goto changeIsMCPServertoMCPServerstring field - [x] Modify
runner/mcpServer.goto use the command-line parameter if provided, otherwise use config file - [x] Update all references to
IsMCPServerboolean to check ifMCPServerstring is non-empty - [x] Build and test the changes to ensure functionality
- [x] Run code review and address feedback
- [x] Run security checks (0 vulnerabilities found)
- [x] Support --mcp without value to use config.yaml default port
- [x] Address reviewer feedback on code clarity
- [x] Refactor to follow original format pattern (write directly to Info variable)
- [x] Add nil pointer validation for safety
- [x] Final verification and comprehensive testing
Summary
Successfully implemented custom port support for the --mcp parameter with optional value support, following the original codebase format conventions and with proper safety checks.
✨ Features:
-
--mcpalone uses config.yaml default port -
--mcp=:8080specifies custom port (short format) -
--mcp=http://localhost:8080specifies full URL with custom port
🔧 Implementation Pattern:
The new parameter follows the original format pattern where flags are registered in a single line and write directly to the Info struct fields:
flag.Var(&mcpFlag{serverAddr: &Info.MCPServer, serverSet: &Info.MCPServerSet}, "mcp", "...")
🛡️ Safety:
- Nil pointer validation in Set() method
- Consistent nil checking across all methods
- Prevents potential panics
Testing Results:
✅ All usage formats tested and working correctly ✅ Follows original codebase format pattern ✅ Nil pointer safety validated ✅ Code review feedback addressed ✅ Security scan: 0 vulnerabilities
Security Summary:
No security vulnerabilities detected by CodeQL analysis.
Original prompt
This section details on the original issue you should resolve
<issue_title>可以在--mcp地方加个参数指定监听到某个端口吗</issue_title> <issue_description>可以在--mcp地方加个参数指定监听到某个端口吗</issue_description>
<agent_instructions>mcp参数支持自定义</agent_instructions>
Comments on the Issue (you are @copilot in this section)
- Fixes wgpsec/ENScan_GO#206
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.