Skip to content

Conversation

@prosdev
Copy link
Collaborator

@prosdev prosdev commented Nov 26, 2025

Summary

Adds a dedicated metadata field to MCP tool responses for operational data like token counts, timing, and result statistics. This separates operational metadata from content, making it easier for AI tools to parse and use programmatically.

Changes

New MCPMetadata Interface

  • Core metrics: tokens, duration_ms, timestamp, cached
  • Data quality: results_total, results_returned, results_truncated
  • Future-ready: confidence, warnings, request_id, etc.

Formatter Updates

  • Formatters now return { content, tokens } instead of embedding token info in content
  • Removed 🪙 ~XX tokens footer from content strings

Adapter Updates

  • search-adapter, github-adapter, status-adapter now populate full MCPMetadata
  • adapter-registry uses duration_ms instead of executionTime

Test Fixes

  • Updated all MCP adapter/formatter tests for new structure
  • Fixed flaky scanner tests by narrowing scope

Testing

  • ✅ All 1249 tests pass
  • ✅ Lint passes
  • ✅ Typecheck passes
  • ✅ Build passes

Closes #51

- Define MCPMetadata interface with core metrics (tokens, duration_ms, timestamp, cached)
- Add data quality fields (results_total, results_returned, results_truncated)
- Include future-ready fields for confidence, warnings, request_id
- Update FormattedResult to use 'tokens' instead of 'tokenEstimate'

Part of #51
- Remove token footer from content string (moved to metadata)
- Return tokens as separate field in FormattedResult
- Update formatter tests for new structure

Part of #51
- Update search, github, status adapters to populate MCPMetadata
- Include tokens, duration_ms, timestamp, cached, results_total
- Use duration_ms instead of executionTime in adapter registry
- Update all adapter tests for new metadata structure

Closes #51
- Narrow repoRoot scope in slow tests to avoid timeouts
- Add explicit timeout of 10s for integration-style tests
- Tests now complete in <1s instead of timing out
@prosdev prosdev merged commit 4a25d84 into main Nov 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mcp): add structured metadata field to MCP tool responses

1 participant