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 structuredContent in JSON-RPC responses
  • Claude Code preferentially displays structuredContent over content
  • MCP specification states content should be primary; structuredContent is for typed tool outputs only

Solution

  • Remove Meta field usage entirely
  • Simplify processOutput to 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 createCommandHandler to not set Meta field
  • Simplified processOutput signature from (string, map[string]any) to string
  • Removed all metadata construction logic (pagination calculations, navigation hints)
  • Updated tests to validate Content-only response structure:
    • Renamed TestCallToolResultStructureWithContentAndMetaTestCallToolResultStructure
    • Removed TestMetadataStructure (no longer applicable)
    • Updated TestProcessOutput to expect single return value

Testing

  • All unit tests pass (31 tests)
  • MCP Inspector shows only content field (no structuredContent)
  • Claude Code displays actual command output
  • Verified with glab_alias_list and glab_issue_list

Closes #8117 (closed)

Merge request reports

Loading