Title: search_code query description teaches incorrect syntax, causing repeated 422 errors · Issue #2390 · github/github-mcp-server · GitHub
Open Graph Title: search_code query description teaches incorrect syntax, causing repeated 422 errors · Issue #2390 · github/github-mcp-server
X Title: search_code query description teaches incorrect syntax, causing repeated 422 errors · Issue #2390 · github/github-mcp-server
Description: This came out of an analysis of github MCP server errors encountered in my past sessions across 5000 sessions. What the agent did In multiple sessions the agent called search_code with queries that look reasonable but are rejected with 4...
Open Graph Description: This came out of an analysis of github MCP server errors encountered in my past sessions across 5000 sessions. What the agent did In multiple sessions the agent called search_code with queries that...
X Description: This came out of an analysis of github MCP server errors encountered in my past sessions across 5000 sessions. What the agent did In multiple sessions the agent called search_code with queries that...
Opengraph URL: https://github.com/github/github-mcp-server/issues/2390
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"search_code query description teaches incorrect syntax, causing repeated 422 errors","articleBody":"This came out of an analysis of github MCP server errors encountered in my past sessions across 5000 sessions.\n\n**What the agent did**\n\nIn multiple sessions the agent called `search_code` with queries that look reasonable but are rejected with `422 ERROR_TYPE_QUERY_PARSING_FATAL`. Examples from real sessions:\n\n```json\n{\"query\": \"repo:dotnet/runtime \\\"GetAttributes\\\\|SetAttributes\\\" path:System.IO.FileSystem/tests\"}\n{\"query\": \"repo:dotnet/roslyn \\\"ProjectName\\\\|GeneratedFileName\\\\|FilePath\\\" language:csharp file:TestState\"}\n{\"query\": \"repo:dotnet/runtime (review OR agent OR copilot OR AI) path:docs OR path:.github\"}\n{\"query\": \"repo:dotnet/runtime (filename:AGENTS.md OR filename:*review*.md OR filename:*copilot*.md)\"}\n{\"query\": \"--statisticalTest parameter Mann-Whitney repo:dotnet/BenchmarkDotNet\"}\n```\n\n**What went wrong**\n\nEach reflects the agent guessing at syntax that looks plausible but is wrong:\n\n- `\\\"foo\\\\|bar\\\"` — used `\\|` for regex OR inside a quoted string; correct form is `/foo|bar/`\n- `path:docs OR path:.github` — `OR` between qualifier instances without parentheses has surprising precedence\n- `filename:*review*.md` — `filename:` is not a valid qualifier; correct is `path:*review*.md`\n- `--statisticalTest ...` — treated the tool like a shell command\n\n**Why it happens**\n\nThe [current `query` parameter description](https://github.com/github/github-mcp-server/blob/4bded57e02e9346cb1fd595156e07dea51f0fb29/pkg/github/search.go#L176) is:\n\n\u003e \"Search query using GitHub's powerful code search syntax. Examples: `content:Skill language:Java org:github`, `NOT is:archived language:Python OR language:go`, `repo:github/github-mcp-server`. Supports exact matching, language filters, path filters, and more.\"\n\nThis gives the model almost no useful guidance on syntax. It doesn't mention regex (slashes), path globs, `symbol:`, or how boolean operators interact with qualifiers. The example `NOT is:archived language:Python OR language:go` has ambiguous precedence and is likely misread by the model.\n\n**Suggested description**\n\n\u003e Search query using GitHub code search syntax. Qualifiers: repo:owner/repo, org:name, language:Go, path:src/*.js, path:/regex/, symbol:Name, content:term, is:archived|fork. Boolean: AND, OR, NOT, parentheses. Regex: surround with slashes e.g. /sparse.*index/. Glob in path: path:*.ts, path:/src/**/*.js. Examples: 'MyFunc language:go repo:owner/repo', 'symbol:WithContext language:go', '/GetAttributes|SetAttributes/ repo:owner/repo', '(Foo OR Bar) path:src repo:owner/repo'.\n\nThis gives clear and accurate information about the actual syntax without being too verbose. It explicitly names it \"GitHub code search syntax\" which may help the model connect it to the [the documentation page](https://docs.github.com/en/search-github/github-code-search/understanding-github-code-search-syntax) of that title that it has already been trained on.","author":{"url":"https://github.com/danmoseley","@type":"Person","name":"danmoseley"},"datePublished":"2026-04-26T07:27:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/2390/github-mcp-server/issues/2390"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b5b9918d-de86-5162-a507-404ebefeb9f8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C8BE:26785E:1365B2:1C433B:6A61DD98 |
| html-safe-nonce | 5367512dea08056fbdfbf9c33931238b06bd9ce47438e3bf2e0e2b7afdb2450c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEJFOjI2Nzg1RToxMzY1QjI6MUM0MzNCOjZBNjFERDk4IiwidmlzaXRvcl9pZCI6IjIzMTA2NzMzODAzMjc2NzczMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 87156b894fe579c02eb298a36bddf7ff385ba67d26819fff283a5175a5f0c8b9 |
| hovercard-subject-tag | issue:4330312950 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/github-mcp-server/2390/issue_layout |
| twitter:image | https://opengraph.githubassets.com/78ff9ac5ecd26eb174e16183bc9959f9f21eb837f77d04be0144eb05c89f7199/github/github-mcp-server/issues/2390 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/78ff9ac5ecd26eb174e16183bc9959f9f21eb837f77d04be0144eb05c89f7199/github/github-mcp-server/issues/2390 |
| og:image:alt | This came out of an analysis of github MCP server errors encountered in my past sessions across 5000 sessions. What the agent did In multiple sessions the agent called search_code with queries that... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danmoseley |
| hostname | github.com |
| expected-hostname | github.com |
| None | b2de8c74e5e61e893155ba46ee41bc66170c1644cb795adefa8386d490f7781c |
| turbo-cache-control | no-preview |
| go-import | github.com/github/github-mcp-server git https://github.com/github/github-mcp-server.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 942771284 |
| octolytics-dimension-repository_nwo | github/github-mcp-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 942771284 |
| octolytics-dimension-repository_network_root_nwo | github/github-mcp-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1866027ded575df8a15c731dd8b9986c9483ceb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width