Skip to content

Bug: search_issues tool creates duplicate filters causing 422 validation errors #817

@shreyabaid007

Description

@shreyabaid007

Describe the bug

The search_issues tool in the GitHub MCP Server incorrectly adds duplicate repo: and is: filters to user queries, causing GitHub API validation errors when users provide queries that already contain these filters.

Additional Context:
This issue also affects users who use complex queries with multiple OR operators, as the duplicate filters contribute to exceeding GitHub's 5 AND/OR/NOT operator limit.

Affected version

GitHub MCP Server: Current development version

Steps to reproduce the behavior

Use the search_issues tool with a query that already contains repo: and/or is:issue filters
Example request:

{
  "tool": "search_issues",
  "arguments": {
    "query": "repo:github/github-mcp-server is:issue is:open (label:critical OR label:urgent OR label:high-priority OR label:blocker OR label:bug OR label:enhancement)"
  }
}

Expected vs actual behavior

Expected Behavior
The tool should detect existing filters and avoid adding duplicates, producing a clean query like:

repo:github/github_mcp_server is:issue is:open (label:critical OR label:urgent OR label:high-priority OR label:blocker OR label:bug OR label:enhancement)

Actual Behavior
The tool adds duplicate filters, producing malformed queries like:

is:issue repo:github/github_mcp_server is:issue is:open (label:critical OR label:urgent OR label:high-priority OR label:blocker OR label:bug OR label:enhancement)

Logs

{
  "type": "text", 
  "text": "Error executing code: MCP error -32603: failed to search issues: GET https://api.github.com/search/issues?order=desc&page=1&per_page=10&q=is%3Aissue+repo%3Agithub%2Fgithub_mcp_server+is%3Aissue+is%3Aopen+%28label%3Acritical+OR+label%3Aurgent+OR+label%3Ahigh-priority+OR+label%3Ablocker+OR+label%3Abug+OR+label%3Aenhancement%29&sort=created: 422 Validation Failed [{Resource:Search Field:q Code:invalid Message:More than five AND / OR / NOT operators were used.}]"
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions