fix(mcp): return only content field in tool responses
Summary
MCP tools were returning pagination metadata instead of actual command output to Claude Code. This fixes the issue by removing the Meta field and following the Content-only pattern from official SDK examples.
Root Cause
- Meta field was populated with pagination data
- This appeared as
structuredContentin JSON-RPC responses - Claude Code preferentially displays structuredContent over content
- MCP specification states
contentshould be primary;structuredContentis for typed tool outputs only
Solution
- Remove Meta field usage entirely
- Simplify
processOutputto return only string (no metadata) - Follow MCP SDK examples which use Content-only pattern
- All tools now return only the content field with actual command output
Changes
- Updated
createCommandHandlerto not set Meta field - Simplified
processOutputsignature from(string, map[string]any)tostring - Removed all metadata construction logic (pagination calculations, navigation hints)
- Updated tests to validate Content-only response structure:
- Renamed
TestCallToolResultStructureWithContentAndMeta→TestCallToolResultStructure - Removed
TestMetadataStructure(no longer applicable) - Updated
TestProcessOutputto expect single return value
- Renamed
Testing
-
✅ All unit tests pass (31 tests) -
✅ MCP Inspector shows only content field (no structuredContent) -
✅ Claude Code displays actual command output -
✅ Verified withglab_alias_listandglab_issue_list
Closes #8117 (closed)