Skip to content

ref(mcp): Port Junior's tool description rules - #2260

Merged
dcramer merged 7 commits into
mainfrom
feat/mcp-tool-description-rules
Nov 16, 2026
Merged

dcramer merged 7 commits into
mainfrom
feat/mcp-tool-description-rules

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Tool descriptions still followed legacy steering: <examples> call samples, <hints>, "Use this tool when you need to:" lists, DO NOT USE blocks, and org/project hints copied into every tool. This ports the rules from Junior's policies/tool-design.md and agent-steering.md and rewrites every MCP tool to match.

Rules (docs/contributing/adding-tools.md, "Descriptions and Params")

  • A tool description says what the tool does to which Sentry object and what it returns. The first sentence carries the search terms for harness tool search.
  • Name a sibling tool only when the contrast is the contract, in one line.
  • Field meaning goes in describe() on the param, and cross-field rules go on the dependent field. A tool description never names its input fields.
  • No examples or hints. Search syntax stays, on the query param.
  • Not every harness loads server instructions, so each tool keeps the routing it needs (for example, get_sentry_resource as the starting point for URLs and IDs). The server instructions may repeat it.
  • Prose that only repeats a handler check (a UserInputError or a query rewrite) is deleted.

tool-descriptions.test.ts enforces these as hard limits: 512 characters per tool description (down from 2,048) and 256 per param, including nested params. It also rejects <examples>/<hints> and fails when a description names its own input fields.

Tool descriptions went from 67.6k to 17.8k characters, and param descriptions from 70.7k to 44.0k. Total tool definition tokens went from about 76.7k to 59.8k; most of what remains is output schemas. The change is text only: no schemas, defaults, validation, or handler output changed.

Follow-ups. This text carried behavior that the handlers don't enforce yet, so it belongs in code:

  • create_project: add a response note when the repository fails to link, and one that tells the user the DSN.
  • onboarding_status_update: failed requires eventNote, but only the param text says so. Enforce it with a superRefine.
  • update_alert_rule / update_metric_monitor: add a 403 hint for a missing alerts:write scope.
  • All-project metric monitor sources need org:write. Nothing checks this before the API call.
  • get_profile: add an empty-result response note (exact transaction name, longer period, profiling enabled).

via @dcramer.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 16, 2026 5:19pm UTC

Request Review

@dcramer

dcramer commented Nov 16, 2026

Copy link
Copy Markdown
Member

rebase

sentry-junior Bot and others added 7 commits November 16, 2026 17:10
Add the description and param rules, enforce 512/256 character limits with a
shrink-only param baseline, and trim the shared params, gateway tools, and
server instructions.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Some harnesses do not load server instructions, so tool and param text must
stand alone. The org and project slug params carry the org/project notation.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Rewrite the setup, release, snapshot, and docs tool descriptions to the
rules in docs/contributing/adding-tools.md: what the tool does and
returns, one sibling-contrast line where it matters, and no examples,
hints, or use-case lists. Param descriptions now say what the value is
and carry their cross-field rules. Rules the handlers already enforce
with UserInputError are no longer repeated in prose.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Rewrite the search_*, trace, span, profile, replay, agent conversation,
dropped events, and dashboard tool descriptions to the rules in
docs/contributing/adding-tools.md: what the tool returns in user words,
one short sibling-routing line, and no examples, hints, or use-case lists.
Move field meaning and cross-field rules onto the params, keep the logs
regex syntax on the search_logs query param, and drop prose the handlers
already enforce.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Cut call samples, hints, use-case lists, and field names from the alert
rule, metric monitor, cron monitor, and uptime monitor tool descriptions.
Each description now says what the tool does and returns, with one line
that contrasts cron, uptime, and metric monitors and alert rules.

Field gotchas moved onto the params they describe, such as condition
result codes, percent thresholds, and Slack and Teams destinations.
Prose that repeated handler validation is gone. Schemas and behavior are
unchanged.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Cut legacy steering (examples, hints, use-case and DO NOT USE lists) from
the issue, event, and resource tool descriptions. Keep what the model
needs: what each tool returns, one sibling contrast where tools look
alike, search syntax on the query params, and cross-field rules on the
dependent param. Drop prose the handlers already enforce or that the
responses already carry.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Every tool and param fits the limits after the rewrite, so the checks are hard
limits. search_logs overrides its query description at the use site instead
of through a one-off builder option.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
@sentry-junior
sentry-junior Bot force-pushed the feat/mcp-tool-description-rules branch from 7acf91e to 4131ee1 Compare November 16, 2026 17:18
@sentry-junior

sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (4131ee1). One conflict: main's #2209 added query support to search_attributes, so I rewrote its description, query, and limit text under the new rules, and dropped the TODO. Definitions regenerated.

@dcramer
dcramer merged commit be1640b into main Nov 16, 2026
33 checks passed
@dcramer
dcramer deleted the feat/mcp-tool-description-rules branch November 16, 2026 17:42
dcramer added a commit that referenced this pull request Nov 16, 2026
Follow-ups from #2260, which removed description text
that carried behavior the handlers did not enforce.

**403 on Alert and Metric Monitor writes** (`create_alert_rule`,
`update_alert_rule`, `create_metric_monitor`, `update_metric_monitor`)

Today a denied write returns `API error (403): You do not have
permission to perform this action.` followed by "you may be able to
resolve this by trying again". `withAlertWritePermissionHint` wraps only
the write call and adds what Sentry checks to a bare 403:
- Alerts need `alerts:write` and permission to edit alerts in every
connected project. An Alert that uses the all-projects source also needs
`org:write`.
- Metric Monitors need `alerts:write` in their project.

The message also says that retrying with the same token will not help:
reconnect with those scopes, or ask an org Owner or Manager. The error
stays an `ApiPermissionError`, so it remains an expected 4xx with its
status. A 403 that names its missing scopes is unchanged, and
`formatErrorForUser` still reports it as **Missing Permission**.

These 403s are bare because of how the Sentry endpoints check
permissions. The workflow and detector endpoints let `org:read` tokens
through to object-level checks (`enforce_workflow_edit_permissions`,
`enforce_detector_workflow_connection_permissions`, `can_edit_detector`
in `workflow_engine/endpoints/validators/utils.py`). `enforce_scope`
sends an `insufficient_scope` challenge only to Seer agent tokens.

There is no `org:write` pre-check for all-project sources. The server
can't see the token's effective scopes (token scopes combined with the
member's role), so a pre-check would cost an extra API call and could
guess wrong. The 403 guidance covers that case instead.

**Other tools**
- `create_project` adds a `guidance` field. It tells the agent to give
the user the project slug and DSN, points to `create_dsn` when no DSN
was set up, and says when the repository did not link.
- `get_profile` adds optional `guidance` when there is no data: check
the exact transaction name with `search_traces`, try a longer period, or
confirm profiling is enabled. In comparison mode it names the period
with no profiles.
- `onboarding_status_update` rejects `status: "failed"` without
`eventNote`.

Nothing breaks. `guidance` is additive in both output schemas. The new
`eventNote` rule rejects only input that the description already called
invalid.

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC08J1NSPU6S%3A1794851244.179419 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC08J1NSPU6S%3A1794851244.179419)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC08J1NSPU6S%3A1794851244.179419/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <23610+dcramer@users.noreply.github.com>

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — 4131ee15 Deployed Nov 16, 2026 by vercel[bot]
Actions — 4131ee15 Deployed Nov 16, 2026 by sentry-junior[bot] via eval #1926
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.

1 participant