Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"packages/cli/AGENTS.md",
"packages/mcp-server-mocks/src/fixtures/**",
"**/worker-configuration.d.ts",
"**/tsconfig*.json",
"packages/toolkit-core/src/generated/**",
"packages/toolkit-core/test/fixtures/**"
"**/tsconfig*.json"
]
}
2 changes: 0 additions & 2 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"apps/cli-docs/**",
"**/worker-configuration.d.ts",
"**/tsconfig*.json",
"packages/toolkit-core/src/generated/**",
"packages/toolkit-core/test/fixtures/**",
"packages/mcp-server-mocks/src/fixtures/**",
"packages/cli/test/init-eval/templates/sveltekit-app/**"
],
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"dev:stdio": "pnpm --filter '@sentry/mcp-server...' --if-present run build && dotenv -e .env -e .env.local -- pnpm --parallel --filter @sentry/mcp-server --filter @sentry/mcp-core --filter @sentry/mcp-server-mocks --if-present run dev",
"build": "dotenv -e .env -e .env.local -- pnpm -r --filter '!sentry' --filter '!sentry-cli-docs' --if-present run build",
"build:cli": "dotenv -e .env -e .env.local -- pnpm --filter sentry run build && pnpm --filter sentry-cli-docs run build",
"check:generated": "pnpm --filter @sentry/mcp-core generate-definitions && pnpm run generate:parsers && git diff --exit-code -- packages/mcp-core/src/toolDefinitions.json packages/mcp-core/src/skillDefinitions.json plugins/sentry-mcp/agents/sentry-mcp.md plugins/sentry-mcp-experimental/agents/sentry-mcp.md packages/toolkit-core/src/generated",
"generate:parsers": "node scripts/generate-parsers.mjs packages/toolkit-core",
"check:generated": "pnpm --filter @sentry/mcp-core generate-definitions && git diff --exit-code -- packages/mcp-core/src/toolDefinitions.json packages/mcp-core/src/skillDefinitions.json plugins/sentry-mcp/agents/sentry-mcp.md plugins/sentry-mcp-experimental/agents/sentry-mcp.md",
"deploy:docs": "pnpm --filter sentry run generate:schema && pnpm --filter sentry run generate:docs && pnpm --filter sentry-cli-docs run build && pnpm --filter sentry-cli-docs run deploy",
"eval": "pnpm --filter '@sentry/mcp-server-evals...' --if-present run build && dotenv -e .env -e .env.local -- pnpm --filter @sentry/mcp-server-evals run eval",
"eval:ci": "pnpm --filter '@sentry/mcp-server-evals...' --if-present run build && CI=true dotenv -e .env -e .env.local -- pnpm --stream -r run eval:ci",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/lib/search-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe("sanitizeQuery: edge cases", () => {

describe("sanitizeQuery: regex filters", () => {
// How the grammar reads regex patterns and keys is tested in
// packages/toolkit-core/src/search-syntax.test.ts. These cover the
// @sentry/search-syntax (getsentry/sentry). These cover the
// sanitizer: patterns survive AND stripping and OR rewriting untouched.
test("preserves repeated whitespace inside a pattern", () => {
expect(sanitizeQuery("message://a AND b//")).toBe(
Expand Down
1 change: 1 addition & 0 deletions packages/mcp-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"@modelcontextprotocol/server": "catalog:",
"@sentry/api": "catalog:",
"@sentry/core": "catalog:",
"@sentry/search-syntax": "catalog:",
"@sentry/toolkit-core": "workspace:*",
"ai": "catalog:",
"dotenv": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ describe("search query helpers", () => {
});

// Which key shapes can carry a regex is tested with the grammar in
// packages/toolkit-core/src/search-syntax.test.ts.
// @sentry/search-syntax (getsentry/sentry).
it("should detect regex filters and other filters inside parentheses", () => {
expect(looksLikeSentrySearchSyntax("(message://a b//)", "logs")).toBe(true);
// The parser reads filters inside parentheses like any other filter.
Expand Down
5 changes: 2 additions & 3 deletions packages/mcp-core/src/tools/support/search-events/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import {
type FilterToken,
type ParseResultToken,
parseSearch,
TermOperator,
Token,
} from "@sentry/toolkit-core/search-syntax";
} from "@sentry/search-syntax/parser";
import { TermOperator, Token } from "@sentry/search-syntax/tokens";
import { getActiveSpan } from "@sentry/core";
import { z } from "zod";
import type {
Expand Down
22 changes: 6 additions & 16 deletions packages/toolkit-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,16 @@ types. Each product keeps its own response validation.

## Search syntax

`search-syntax` parses Sentry search queries with the Sentry frontend's own
grammar. `grammar/search-syntax.pegjs` is an unchanged copy of
[`static/app/components/searchSyntax/grammar.pegjs`](https://github.com/getsentry/sentry/blob/master/static/app/components/searchSyntax/grammar.pegjs),
and `test/fixtures/search-syntax/` is a copy of the `fixtures/search-syntax`
cases the frontend and `event_search.py` both test against. `parseSearch`
returns the frontend's token tree, minus validation: `TokenConverter` never
marks tokens invalid or fills `parsed` values. A product that needs those
subclasses `TokenConverter` and passes it as `converter`.
Search queries are parsed with
[`@sentry/search-syntax`](https://www.npmjs.com/package/@sentry/search-syntax),
the Sentry frontend's own grammar and structural parser, published from
[`static/packages/search-syntax`](https://github.com/getsentry/sentry/tree/master/static/packages/search-syntax)
in getsentry/sentry. Grammar changes and their tests (including the
`fixtures/search-syntax` cases shared with `event_search.py`) live there.

`search-query` uses that parser to rewrite queries the API would reject:
explicit `AND` is dropped, and `OR` on one key becomes an in-list. With
`issueSearch: true` it also turns `is:` OR groups into `status:[…]` or
`substatus:[…]` and unwraps parentheses, which the issues endpoint doesn't
support. It returns the rewrite notes and throws `SearchQueryError` for
anything it can't rewrite; each product decides how to report them.

The parser is compiled ahead of time into `src/generated/` and committed,
since this package has no build step. Its types live in
`grammar/search-syntax.d.ts`. After editing either file, run
`pnpm run generate:parsers`; the pre-commit hook does this for staged
grammar changes, and `pnpm run check:generated` fails in CI when
the committed parser is out of date. When updating the grammar from upstream,
copy the fixtures too.
25 changes: 0 additions & 25 deletions packages/toolkit-core/grammar/search-syntax.d.ts

This file was deleted.

Loading
Loading