Skip to content

feat(tools): add get_issue_tag_values tool for tag distribution - #706

Merged
dcramer merged 5 commits into
mainfrom
feat/get-issue-tag-values
Jan 11, 2026
Merged

dcramer merged 5 commits into
mainfrom
feat/get-issue-tag-values

Conversation

@drazisil-codecov

Copy link
Copy Markdown

Summary

Adds new MCP tool get_issue_tag_values to expose Sentry's Tag Distributions view. This addresses CCMRG-1999.

Context

Currently, the Sentry MCP doesn't expose the Tag Distributions view (like https://sentry.io/issues/{id}/distributions/url/). This makes it impossible for AI agents to get aggregate counts of unique tag values for an issue (e.g., "how many unique repos are affected by this error").

Key Changes

  • API Client: Added getIssueTagValues() method calling GET /api/0/issues/{issue_id}/tags/{tag_name}/
  • Schema: Added IssueTagValuesSchema Zod schema for response validation
  • New Tool: Created get_issue_tag_values tool with full documentation, examples, and hints
  • Testing: Added MSW mock handler, fixture, and comprehensive unit tests
  • Updated tool counts: Fixed use-sentry handler tests for new tool count (21 tools)

Example Usage

// Get URL distribution for an issue
get_issue_tag_values(organizationSlug='my-org', issueId='PROJECT-123', tagKey='url')

// Get browser distribution using issue URL
get_issue_tag_values(issueUrl='https://sentry.io/issues/PROJECT-123/', tagKey='browser')

Breaking Changes

None

Add new MCP tool to expose Sentry's Tag Distributions view, allowing
AI agents to get aggregate counts of unique tag values for an issue.

Changes:
- Add getIssueTagValues method to API client
- Add IssueTagValuesSchema for response validation
- Create get-issue-tag-values tool with full documentation
- Add MSW mock handler and fixture for testing
- Add comprehensive unit tests
- Update use-sentry handler tests for new tool count

Co-Authored-By: Cursor <noreply@cursor.sh>
@drazisil-codecov
drazisil-codecov marked this pull request as ready for review January 9, 2026 15:02
@dcramer

dcramer commented Jan 11, 2026

Copy link
Copy Markdown
Member

Given the ticket has been open and we dont yet have a better idea, I think I'm good with this. Gonna run a couple checks on it then we'll merge

Add regex validation to tagKey in get_issue_tag_values tool to prevent
path traversal attacks. The tagKey is now restricted to alphanumeric
characters, dots, hyphens, and underscores, matching the pattern used
for other URL path parameters like organizationSlug.

Also removes unused topTotal variable from output formatting.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread packages/mcp-core/src/api-client/schema.ts Outdated
Comment thread packages/mcp-core/src/tools/get-issue-tag-values.ts
- Make firstSeen/lastSeen nullable in IssueTagValueSchema to handle
  API responses that return null instead of omitting the field
- Escape pipe, backtick, and newline characters in markdown table
  output to prevent table formatting issues

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread packages/mcp-core/src/tools/get-issue-tag-values.ts Fixed
Comment thread packages/mcp-core/src/tools/get-issue-tag-values.ts Fixed
Address CodeQL security alert by escaping backslash characters before
escaping other special markdown characters. This prevents incomplete
escaping when input contains backslashes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread packages/mcp-core/src/tools/get-issue-tag-values.ts Outdated
Address Cursor Bot feedback - the get_issue_details suggestion now
includes the required organizationSlug parameter.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dcramer
dcramer merged commit 44bc95a into main Jan 11, 2026
14 checks passed
@dcramer
dcramer deleted the feat/get-issue-tag-values branch January 11, 2026 23:10

This branch was previously deployed

1 inactive deployment
Actions — 1da0b33c Deployed Jan 11, 2026 by dcramer via eval #703
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.

3 participants