ENScan_GO icon indicating copy to clipboard operation
ENScan_GO copied to clipboard

Add custom port/address parameter to --mcp flag with optional value support

Open Copilot opened this issue 2 months ago • 2 comments

Plan: Add custom port support for --mcp parameter

  • [x] Change --mcp flag from boolean to string to accept custom port/address
  • [x] Update flag parsing in common/flag.go to accept string value
  • [x] Update common/config.go to change IsMCPServer to MCPServer string field
  • [x] Modify runner/mcpServer.go to use the command-line parameter if provided, otherwise use config file
  • [x] Update all references to IsMCPServer boolean to check if MCPServer string 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:

  • --mcp alone uses config.yaml default port
  • --mcp=:8080 specifies custom port (short format)
  • --mcp=http://localhost:8080 specifies 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.

Copilot avatar Dec 05 '25 08:12 Copilot