[log] Add debug logging to MCP types schema normalization#606
Conversation
Enhanced internal/mcp/types.go with debug logging for better troubleshooting:
- Added logger declaration: var log = logger.New("mcp:types")
- Added 7 strategic logging calls to NormalizeInputSchema function
- Logs schema validation decisions and normalization actions
- All log arguments have no side effects (values already in scope)
- Follows project logging guidelines from AGENTS.md
There was a problem hiding this comment.
Pull request overview
This PR enhances the MCP types schema normalization function with debug logging to improve troubleshooting capabilities. The changes add a debug logger instance and 9 strategic log statements throughout the NormalizeInputSchema function to provide visibility into schema validation and normalization operations.
Changes:
- Added debug logger declaration following the project convention (
var log = logger.New("mcp:types")) - Added 9 debug logging statements at key decision points in the schema normalization flow
- No changes to function behavior or logic - purely additive logging
Comments suppressed due to low confidence (2)
internal/mcp/types.go:119
- Remove trailing whitespace from this blank line. This improves consistency with Go formatting standards.
internal/mcp/types.go:65 - Remove trailing whitespace from this blank line. This improves consistency with Go formatting standards.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| typeVal, hasType := schema["type"] | ||
|
|
||
| log.Printf("Tool %s schema analysis: hasType=%v", toolName, hasType) | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from this blank line. This improves consistency with Go formatting standards.
This issue also appears in the following locations of the same file:
- line 119
- line 65
| // but is missing the required "properties" field, we add an empty properties | ||
| // object to make it valid per JSON Schema standards. | ||
| func NormalizeInputSchema(schema map[string]interface{}, toolName string) map[string]interface{} { | ||
| log.Printf("Normalizing input schema for tool: %s", toolName) |
There was a problem hiding this comment.
The PR description states "7 strategic logging calls" but there are actually 9 log.Printf calls in the NormalizeInputSchema function (lines 64, 69, 80, 86, 95, 99, 109, 117-118, 132, and 136). Consider updating the PR description to reflect the accurate count.
Summary
Enhanced
internal/mcp/types.gowith debug logging to improve troubleshooting of MCP tool schema normalization.Changes Made
Added debug logger declaration and 7 strategic logging calls to the
NormalizeInputSchemafunction:Benefits
Testing
var log = logger.New("mcp:types")Quality Checklist
pkg:filenameconvention (mcp:types)Example Debug Output
With
DEBUG=mcp:*, developers will see: