Skip to content

Expose conversationId in MCP tool content - #106

Merged
kentcdodds merged 1 commit into
mainfrom
cursor/tool-response-conversation-id-53d5
Mar 30, 2026
Merged

kentcdodds merged 1 commit into
mainfrom
cursor/tool-response-conversation-id-53d5

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Mar 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • prepend a text metadata block with conversationId for MCP tool responses
  • add a shared helper for constructing metadata-first content arrays
  • update MCP e2e expectations to tolerate the new metadata block

Testing

  • npm run test:mcp
Open in WebΒ Open in CursorΒ 

Summary by CodeRabbit

Release Notes

  • New Features

    • Tool responses now include conversation ID tracking metadata, improving context preservation across tool interactions.
  • Tests

    • Updated test utilities to properly handle and validate the new metadata structure in tool responses.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
kentcdodds marked this pull request as ready for review March 30, 2026 17:28
@kentcdodds
kentcdodds merged commit c9e36a1 into main Mar 30, 2026
14 of 15 checks passed
@coderabbitai

coderabbitai Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5f21b10-cd61-44ce-8986-6aec56952e4c

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 22b2050 and 3c45119.

πŸ“’ Files selected for processing (6)
  • packages/worker/client/mcp-apps/widget-host-bridge.node.test.ts
  • packages/worker/src/mcp/mcp-server.mcp-e2e.test.ts
  • packages/worker/src/mcp/tools/execute.ts
  • packages/worker/src/mcp/tools/open-generated-ui.ts
  • packages/worker/src/mcp/tools/search.ts
  • packages/worker/src/mcp/tools/tool-response-content.ts

πŸ“ Walkthrough

Walkthrough

Tool responses now include a prepended conversation metadata block (conversationId: ...) via a new helper; execute, search, and open-generated-ui tools were updated. Tests were adjusted to extract and assert text blocks including the metadata.

Changes

Cohort / File(s) Summary
Tool Response Metadata Prepending
packages/worker/src/mcp/tools/execute.ts, packages/worker/src/mcp/tools/search.ts, packages/worker/src/mcp/tools/open-generated-ui.ts
Tool handlers now wrap returned content arrays with prependToolMetadataContent(conversationId, ...), replacing direct single-element content arrays with metadata-prepended arrays.
Metadata Prepending Utility
packages/worker/src/mcp/tools/tool-response-content.ts
Added exported prependToolMetadataContent(conversationId, content) which constructs a type:'text' metadata block conversationId: ${conversationId} and prepends it to provided content (or returns it alone if content empty).
E2E Test Adjustments
packages/worker/src/mcp/mcp-server.mcp-e2e.test.ts
Introduced local getTextContent(content) to extract the relevant text block (skipping blocks starting with conversationId: when appropriate) and replaced inline extraction logic with this helper; updated assertions to validate metadata presence and text content.
Widget Host Bridge Test Update
packages/worker/client/mcp-apps/widget-host-bridge.node.test.ts
Test changed extraction of user content from content[0] to .find(...) that selects the first object with a type field, and computes text from that selected block.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I nibble at metadata, neat and spry,
I prepend IDs so no message will fly,
A breadcrumb of convo in each text part,
Hopping through tests with a joyful heart,
✨πŸ₯•

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/tool-response-conversation-id-53d5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

2 participants