Repository navigation
feat(tools): Return structured output from search_docs - #2040
Merged
Merged
Conversation
Add a vitest linter for the initialize and tools/list surface in mcp-core, a structured-output guard for the mcp-core suite, and server.json checks in @sentry/mcp-server, so the MCP metadata we just added does not drift back. The guard mirrors the SDK's tools/call validation: a tool with an outputSchema must return structuredContent that matches it. Tools whose outputSchema PR is still open are listed as pending, and their entry fails once the schema lands, so the PR that lands it deletes the entry. Co-Authored-By: David Cramer <[email protected]>
The metadata linter only sees listed tools, so deprecated aliases and the DSN-gated feedback tool lost their title-uniqueness check when it moved out of tools.test.ts. Check those definitions directly. Co-Authored-By: David Cramer <[email protected]>
Drop the pending entries whose outputSchema PRs have merged, move the search_metrics, search_profiles and search_replays tests to structured search stubs, and mark the guard probe's deliberately invalid result as a type error now that handler results are typed from outputSchema.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
search_docs returns a list of search hits, so give it an outputSchema and return structuredContent instead of markdown. Each result carries its get_doc path, docs URL, relevance score, and snippet (first three results only, as before). The get_doc follow-up for the top result becomes a suggestedActions entry, and empty searches return results: []. An error inside a 2xx search response used to be returned as success text. It now throws ApiServerError so it surfaces as a tool error and is reported to Sentry. Co-Authored-By: David Cramer <[email protected]>
Throw createApiError for non-2xx search responses so 5xx errors reach Sentry and 429s become ApiRateLimitError, and use it for the in-body error too. Suggest get_doc for the first result with a non-empty path, since the search route sends an empty path when a hit has no filename. Co-Authored-By: David Cramer <[email protected]>
search_docs now declares an outputSchema, so the metadata lint fails while it stays on the exempt list.
sentry-junior
Bot
force-pushed
the
feat/search-docs-structured-output
branch
from
November 6, 2026 00:32
6fabdaa to
2402844
Compare
dcramer
enabled auto-merge (squash)
November 6, 2026 00:37
Resolve server.metadata.test.ts add/add conflict after #2039 squash-merged: keep this branch's removal of search_docs from OUTPUT_SCHEMA_EXEMPT.
7 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
search_docsnow has anoutputSchemaand returnsstructuredContentinstead of markdown. It returns a list of search hits, so it belongs with the structured tools.get_doc(full page markdown) stays markdown on purpose and is unchanged.Payload
/api/searchresponse, with no spreads. A test checks both the top-level keys and the result keys.suggestedActionsentry. It's built withbuildSuggestedToolActionand callsget_docfor the first result that has a path. The search route sends""when a hit has no filename, so those hits are skipped. The entry is left out whenget_doccan't be called in the session.results: []with no follow-up action.Snippets: only the first 3
The first-3 rule from the markdown version stays. Snippets are search chunks of about 250 tokens each. Keeping them for every result would add about 1.75k tokens at
maxResults=10, and results past the third are mostly useful for theirpath.maxResultsdefaults to 3, so most calls aren't affected.Tokens
Measured with tiktoken (gpt-4o) on a realistic fixture: 1000-char chunks of the real docs.sentry.io markdown for Django, sampling, and Next.js sourcemaps. The old markdown handler is compared with the pretty JSON the server generates:
Errors
createApiError(message, status, undefined, body)instead of the baseApiError. A 5xx becomesApiServerErrorand gets logged to Sentry. A 429 becomesApiRateLimitError. Before, every status got the generic "address the concern" text and nothing was logged.createApiError(data.error, 502), which is anApiServerError, so it shows up as a tool error. The route only reports errors with non-2xx statuses, so this path is defensive.#788 stays fixed
When
guideis omitted, the request body has noguidekey. A test asserts that the parsed request body has noguideproperty, because the route rejectsguide: null.Tests
structuredContent, plus a schema parse.pathbeing skipped for the action, empty results,get_docunavailable, the in-body error, a 500 (ApiServerError), a 429 (ApiRateLimitError), and a timeout.toolDefinitions.jsonis regenerated, anddocs/contributing/tool-responses.mdhas a new "Documentation Search" section.Checks run with
SENTRY_AUTH_TOKENunset: mocks build,generate-definitions, mcp-coretsc, full mcp-core vitest, and rootpnpm run lint. Full vitest ran before a final test-only lint fix, a cast in the #788 assertion. After that fix, the search_docs tests,tsc, and lint were rerun and passed. I did not run stdio MCP QA.An independent reviewer passed this change with no must-fix items. Its should-fix item (typed HTTP errors) and two nits (the empty-path action, the top-level key check) are applied here.
Whichever of this and #2039 merges second removes the search_docs entry from OUTPUT_SCHEMA_EXEMPT.
via @dcramer.
--
View Session [Sentry]