Skip to content

feat(mcp): add attributes detail info to matches in search_attributes - #2864

Draft
nikkikapadia wants to merge 10 commits into
mainfrom
nikki/search-attributes/attribute-details-call
Draft

nikkikapadia wants to merge 10 commits into
mainfrom
nikki/search-attributes/attribute-details-call

Conversation

@nikkikapadia

@nikkikapadia nikkikapadia commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

This PR integrates the attributes detail endpoint into the search_attributes tool call. Once the endpoint finds the matches, the attributes detail endpoint will be called for each of them and the additional info we get from that endpoint will be attached onto the attribute. This way when the user get's the matches back they get shown this data as well.

To make this happen there are a few things that have changed; I've adjusted the output schema and i've made project required to call the attribute details endpoint. This is how the attribute details work in the UI so i'd thought i'd reflect the same in the MCP. Also calling the attribute details endpoint on all projects hangs and takes the call forever to finish.

In addition, i've added the api caller function, new mocks, and updated the eval file.

Contributes to EXP-1349

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Dec 3, 2026 9:43pm UTC
sentry-local Ready Ready Preview Dec 3, 2026 9:43pm UTC

Request Review

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

📊 MCP Server Token Cost Report

Summary

  • Total Tokens: 72117 tokens
  • Tool Count: 79 tools
  • Average: 913 tokens/tool

Per-Tool Breakdown

Tool Tokens % of Total
get_issue_details 4049 5.6%
get_alert_rule 2245 3.1%
search_logs 1837 2.5%
search_metrics 1836 2.5%
search_traces 1835 2.5%
find_releases 1805 2.5%
get_issue_activity 1759 2.4%
update_alert_rule 1653 2.3%
get_replay_details 1602 2.2%
search_attributes 1542 2.1%
create_alert_rule 1506 2.1%
get_monitor_details 1501 2.1%
update_metric_monitor 1479 2.1%
create_metric_monitor 1458 2%
update_issue 1394 1.9%
get_event_stacktrace 1381 1.9%
get_snapshot 1370 1.9%
render_sentry_chart 1362 1.9%
get_profile 1291 1.8%
get_agent_conversation_details 1278 1.8%
find_monitors 1261 1.7%
get_alert_options 1236 1.7%
search_profiles 1228 1.7%
search_errors 1214 1.7%
get_profile_details 1203 1.7%
find_related_issues 1171 1.6%
get_uptime_monitor_details 1163 1.6%
render_issue_chart 1141 1.6%
create_monitor 1135 1.6%
onboarding_status_update 1109 1.5%
search_issue_events 1103 1.5%
search_replays 1095 1.5%
get_release_details 1056 1.5%
get_dashboard_details 1052 1.5%
search_issues 977 1.4%
search_docs 973 1.3%
find_alert_rules 908 1.3%
update_uptime_monitor 889 1.2%
create_uptime_monitor 883 1.2%
search_agent_conversations 830 1.2%
find_dropped_events 819 1.1%
get_metric_monitor_details 797 1.1%
create_project 793 1.1%
update_dsn 765 1.1%
get_issue_user_reports 630 0.9%
get_latest_base_snapshot 623 0.9%
find_dashboards 553 0.8%
link_issue 545 0.8%
find_uptime_monitors 537 0.7%
get_issue_breadcrumbs 492 0.7%
unlink_issue 476 0.7%
find_metric_monitors 471 0.7%
get_issue_tag_values 469 0.7%
find_project_members 448 0.6%
update_project 441 0.6%
get_sentry_resource 429 0.6%
submit_feedback_to_sentry_team 426 0.6%
add_issue_note 404 0.6%
delete_monitor_environment 363 0.5%
find_teams 351 0.5%
find_projects 346 0.5%
delete_alert_rule 345 0.5%
delete_uptime_monitor 333 0.5%
delete_metric_monitor 331 0.5%
create_dsn 326 0.5%
add_team_to_project 324 0.4%
remove_team_from_project 320 0.4%
find_dsns 319 0.4%
find_organizations 311 0.4%
get_snapshot_image 302 0.4%
analyze_issue_with_seer 300 0.4%
approve_snapshot 300 0.4%
get_event_attachment 299 0.4%
get_trace_details 282 0.4%
create_team 266 0.4%
get_span_details 263 0.4%
whoami 261 0.4%
get_sentry_mcp_info 142 0.2%
get_doc 102 0.1%

Note: This measures the static overhead of tool definitions sent to LLM clients with every request. Lower is better.

MCP Apps views

Each ui:// view as a host receives it from resources/read.

View MIME type Raw Gzip Brotli Budget % of budget
ui://sentry/chart/v6.html text/html;profile=mcp-app 19,249 B 7,913 B 7,014 B 24,576 B 78.3%

The budget applies to raw bytes, and the view's generator fails over it.

sentry-junior[bot]
sentry-junior Bot previously requested changes Dec 3, 2026

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The details merge and output schema look solid, and the tests cover the partial-failure paths well. A few things before this goes to the team:

  • Feature flag: in getsentry/sentry, OrganizationTraceItemAttributeDetailsEndpoint returns a bare 404 unless the org has organizations:attribute-management (still a FlagPole flag in temporary.py). For any org without it, every search_attributes match now makes up to limit extra requests that all 404, and every response gets "Some additional attribute details are unavailable." Check the org feature once, from the org's features list, before fanning out, and skip the details calls and the note when the flag is off.
  • Required projectSlug: it now gates the whole tool, including listing (no query), which never calls the details endpoint, and org-wide matching, which the attributes endpoint handles fine. Agents now have to pick a project before they can discover keys for org-wide search_traces/search_logs queries, and attributes that only exist in other projects drop out. Since the slow part is only the details fan-out, keep projectSlug optional and fetch details only when a project is set. That also keeps SearchAttributesParams.projectSlug: string | null and the if (params.projectSlug) branch in search.ts meaningful; right now both are dead.
  • Wrapper layers: fetchAttributeDetails in the new utils.ts and fetchSingleAttributeDetails in search.ts both just forward to apiService.getTraceItemAttributeDetails. Call the client method directly inside the map and drop utils.ts.

Also worth knowing: each details request re-lists every attribute across spans, logs, and tracemetrics server-side before computing stats. Running ~10 of them in parallel per search is heavy even with a project set, so it's worth keeping an eye on latency once this is live.

via Nikki Kapadia.

@sentry-junior
sentry-junior Bot dismissed their stale review December 3, 2026 20:28

Dismissed at the author's request; the feedback stands as comments only.

@linear-code

linear-code Bot commented Dec 3, 2026

Copy link
Copy Markdown

EXP-1349

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Love it! There's a bug I think is blocked, and some smaller ones. But the overall architecture/strategy looks very solid to me.

Note: I'm trying out a new adversarial review skill that posts a bunch of comments. I deleted ones that I didn't think were really worth it*. I think the rest are ones I like. But LMK what you think, I definitely don't want to be too nitpicky!

*I typed that, and then got paranoid I said that phrase because Claude tends to say it... but I couldn't think of a better fit.

Comment on lines +210 to +213
const hasAttributeDetailsFlag = await hasAttributeDetailsFeature(
apiService,
organizationSlug,
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Performance] We fetch this even if projectId !== undefined && matchedAttributes.length > 0. That's an extra network request that might not get used. Then hasAttributeDetailsFlag is only used later on after the attributeDetailsEnabled check once in the file, if projectId === undefined.

Do you think it might be worth it to set up some kind of small lazy getter? Like a ...

let attributesDetailedEnabled: boolean | undefined;
const getAttributesDetailedEnabled = async () => {
  attributesDetailedEnabled ??= await stuff();
};

...? I don't see precedent for this elsewhere but it might be nice to speed things up?

My intuition is no, this isn't worth it for a since request to a short-lived feature flag. But just putting it out there as something we might want to suggest if we end up seeing this pattern a lot.

// Details only add to a match, so the requests run in parallel and a failed
// one leaves just its match without them. Each returns whether it got a 404.
const attributeDetailsNotFound = await Promise.all(
attributesToGetDetailsFor.map(async (attribute) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Bug] If there are hundreds of requests this will spam the server and get rate limited. A couple of strategy thoughts:

  • Maybe we could have a multi-attribute-detail endpoint? One that takes a list of them and returns an array of results? This would be my preference.
    • Aside: I know GraphQL is no longer in vogue but whoo is it good for this kind of "same data store, different API needs" use case...
  • If that's not doable (why? 😢) we probably want some kind of throttled queue

I think this is blocking, but lmk if I'm misinterpreting please!

const apiNotes = attributeDetailsNotFound.some(Boolean)
? ["Some additional attribute details are unavailable."]
: [];
// The details need a project, so say how to get them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Docs] Nit: I think this is indicated nicely by the code?

Suggested change
// The details need a project, so say how to get them.

return {
...attributeDetails,
...attribute,
...(attributeDetails?.context && { context: attributeDetails.context }),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Bug] The details endpoint merges context across spans, logs, and tracemetrics, and keeps whichever has the highest precedence (merge_attributes_across_datasets in Sentry). So this can replace the searched dataset's description, examples, and deprecation with another dataset's.

The list call's context is already scoped to the dataset we searched, so I think we should keep that one and only take changelog, lastSeen, and datasets from the details.

},
});
}
return error instanceof ApiNotFoundError;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Bug] Only a 404 adds the "Some additional attribute details are unavailable." note. A 5xx, 429, 403, or parse error leaves lastSeen: null with no note, which reads as "not seen in the period" rather than "unknown".

Could we add the note for any failed request? Naming the affected keys in it would help the agent too.

const result = await searchAttributes.handler(
z.object(searchAttributes.inputSchema).parse({
organizationSlug: FIXTURES.organizationSlug,
projectSlug: FIXTURES.projectSlug,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Testing] Every eval passes projectSlug now, so none of them covers the default call without a project. As I understand it that's an important agent use case. Maybe keep at least one without it?

replacementAttribute: z.string().optional(),
details: z.array(z.string()).optional(),
isInOtel: z.boolean().optional(),
unit: z.string().optional(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Cleanup] Nit: nothing reads context.unit. Can we drop it?

...(modifiedCount !== undefined && { modifiedCount }),
}));

export const TraceItemAttributeChangelogEntrySchema = z

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Cleanup] Nit: nothing outside client.ts uses this export.

attributeSource: TraceItemAttributeSource;
projectId?: string | undefined;
statsPeriod?: string | undefined;
start?: string | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Cleanup] Nit: nothing passes start or end. Can we drop them for now?

*
* @param params Query parameters
* @param params.organizationSlug Organization identifier
* @param attributeName Name of the attribute to query for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Docs] These don't match the signature: they're missing the params. prefix, and params.attributeSource isn't listed. I think the one non-obvious bit is that attributeName is the attribute's name, not its key. Maybe keep just that?

This isn't at the level of https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/informative-docs.md but, that kind of spirit.

@nikkikapadia
nikkikapadia marked this pull request as draft December 4, 2026 18:15

This branch was successfully deployed

3 active deployments
Preview – sentry-local — 1df7f17a Deployed Dec 3, 2026 by vercel[bot]
Preview – cli — 1df7f17a Deployed Dec 3, 2026 by vercel[bot]
Actions — 1df7f17a Deployed Dec 3, 2026 by nikkikapadia via eval #2250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants