Skip to content

feat(mcp): Add AI conversation search#1123

Merged
dcramer merged 19 commits into
mainfrom
dcramer/feat/ai-conversations-mcp-search
Jun 25, 2026
Merged

feat(mcp): Add AI conversation search#1123
dcramer merged 19 commits into
mainfrom
dcramer/feat/ai-conversations-mcp-search

Conversation

@dcramer

@dcramer dcramer commented Jun 24, 2026

Copy link
Copy Markdown
Member

Add a catalog-only search_ai_conversations tool backed by Sentry AI Conversations. It returns one structured summary per conversation, resolves project slugs to numeric IDs, supports cursor pagination and scoped time windows, and leaves the direct MCP tool surface unchanged.

AI conversation detail lookup now returns a chronological structured transcript with user messages, assistant messages, and tool calls as first-class timeline events. Search and detail outputs use Unix millisecond timestamps, detail responses include the lookup window that was queried, and the server generates JSON text fallbacks from structuredContent for clients that still read text.

The generated tool definitions now include output schemas for structured tools, with shared test helpers covering structured-only handler output and generated compatibility text. The AI Conversations spec and contributing docs document the structuredContent contract and the expectation that Sentry endpoint behavior is checked against ~/src/sentry when tool contracts change.

Add a catalog-only search_ai_conversations tool backed by the Sentry AI Conversations endpoint, plus URL/detail handling improvements for scoped conversation links.

Document the conversation-native MCP behavior and the requirement to validate Sentry endpoint contracts against the source tree before changing tool schemas.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/api-client/client.ts Outdated
Comment thread packages/mcp-core/src/tools/catalog/get-ai-conversation-details.ts
Reuse the shared time parameter validation for AI Conversation lookups and search so partial absolute ranges are rejected and statsPeriod cannot be mixed with start/end.

Update the empty conversation detail response to describe the explicit lookup window when one was used.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/catalog/search-ai-conversations.ts Outdated
Comment thread packages/mcp-core/src/tools/catalog/search-ai-conversations.ts Outdated
Comment thread packages/mcp-core/src/tools/catalog/get-ai-conversation-details.ts
dcramer and others added 3 commits June 24, 2026 16:57
Reject one-sided absolute time ranges at the tool layer before calling the API client, and reject mixed relative and absolute windows for conversation search.

Tighten the conversation search limit schema to emit an integer type in generated tool definitions.

Co-Authored-By: Codex <noreply@openai.com>
Keep the specs README focused on authoring guidance instead of maintaining a duplicated catalog of every spec file.

Co-Authored-By: Codex <noreply@openai.com>
Point AI conversation follow-up guidance at span search by gen_ai.conversation.id so agents inspect telemetry across every trace in the conversation.

Keep trace IDs framed as per-trace context instead of the primary conversation inspection path.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/catalog/search-ai-conversations.ts
Comment thread packages/mcp-core/src/tools/catalog/get-ai-conversation-details.ts Outdated
Comment thread packages/mcp-core/src/tools/catalog/get-sentry-resource.ts
dcramer and others added 2 commits June 24, 2026 18:12
Expose search_ai_conversations results through an MCP outputSchema and structuredContent while preserving the existing markdown text fallback.

Add a typed structured text result helper so tools can return structuredContent without hand-assembling the legacy content block.

Co-Authored-By: Codex <noreply@openai.com>
Align AI conversation search with the details lookup window and return a stable structuredContent projection. Document structuredContent response expectations for tool authors and keep generated tool metadata in sync.

Co-Authored-By: OpenAI GPT-5 Codex <noreply@openai.com>
Comment thread packages/mcp-core/src/tools/catalog/search-ai-conversations.ts Outdated
dcramer and others added 4 commits June 24, 2026 19:07
Treat an empty AI conversation search statsPeriod like an omitted value so the search and detail tools share the same default 30 day window.

Co-Authored-By: OpenAI GPT-5 Codex <noreply@openai.com>
Keep structured tool handlers focused on structuredContent and move compatibility text generation to the server boundary.

Remove the JSON artifact block from handwritten AI conversation detail markdown so tools use either handwritten markdown or structuredContent, not both.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Return AI conversation details as structured content so clients can inspect the transcript without a large handwritten markdown view. Keep the payload focused on debugging fields and rely on the server-generated JSON fallback for compatibility.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Keep AI conversation search output focused on fields that help select the next conversation to inspect. Replace full input and output text with bounded previews, return sampled trace IDs, and omit non-actionable user identifiers.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/mcp-core/src/tools/catalog/get-ai-conversation-details.ts
dcramer and others added 2 commits June 25, 2026 08:30
Move structuredContent test helpers into a shared test utility so structured result tests use one contract for extracting payloads and checking generated fallback text.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Remove per-turn project from AI conversation details because the payload already includes conversation-level projects. Add ordering coverage for shuffled spans so tool calls are explicitly grouped with the preceding AI client span until the next AI client starts.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/mcp-core/src/tools/catalog/search-ai-conversations.ts
Replace nested AI conversation turns with a flat timeline of message and tool call events. Keep trace/span identifiers on each event so consumers can inspect execution chronology without inferring order from grouped turns.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread packages/mcp-core/src/tools/catalog/get-ai-conversation-details.ts
Document that AI conversation details should expose a chronological timeline instead of grouping tool calls under synthetic turns. Keep trace identifiers as the path for deeper execution-tree analysis.

Co-Authored-By: GPT-5 Codex <codex@openai.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 4 total unresolved issues (including 3 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 186c35a. Configure here.

Comment thread packages/mcp-core/src/tools/catalog/get-ai-conversation-details.ts
Comment thread packages/mcp-core/src/toolDefinitions.json
Simplify AI conversation search as a normal catalog tool by removing sampling mode and focused-span plumbing from the public surface. Keep structuredContent as the source of truth, emit generated compatibility text at the server boundary, and include output schemas in generated definitions.

Add focused coverage for structured catalog dispatch and shared structuredContent assertions so search/detail outputs have snapshot-style regression coverage.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Comment thread docs/contributing/tool-responses.md
dcramer and others added 3 commits June 25, 2026 09:53
Drop the unused samplingMode parameter from AI conversation client and URL helpers so the simplified search tool does not leave dead API surface behind.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Return AI conversation detail timestamps in Unix milliseconds to match search results and include the lookup window in structured detail output so empty transcripts still show which time range was queried.

Co-Authored-By: GPT-5 Codex <codex@openai.com>
Expose generated output schemas through the exported tool definition type and keep AI conversation duration derived directly from API timestamps.

Add concise comments for the structured detail projection and AI conversation URL helpers so the public and wire-facing contracts are easier to maintain.

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
@dcramer dcramer marked this pull request as ready for review June 25, 2026 20:03
@dcramer dcramer merged commit 912eaaf into main Jun 25, 2026
19 checks passed
@dcramer dcramer deleted the dcramer/feat/ai-conversations-mcp-search branch June 25, 2026 20:04
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.

1 participant