Skip to content

search_code tool: path: qualifier silently returns 0 results when used as a filename filter — no error or warning shown #2343

@mikejohnstonPremierinc

Description

@mikejohnstonPremierinc

Description

The search_code MCP tool passes search queries to GET /search/code (GitHub Legacy REST API). The path: qualifier in this API filters by directory path, not by filename. However, many users and AI agents naturally use path: to target a specific file (e.g., path:WaitUtils.cs).

When path: is used this way, the API returns 0 results silently — no error, no warning, no indication that the qualifier was used incorrectly. This causes AI agents to conclude the file or content does not exist, when it actually does.

The correct qualifier for filename filtering is filename:, but nothing in the tool's behavior or output signals this distinction when path: fails.

Steps to Reproduce

  1. Configure the GitHub MCP server and use the search_code tool
  2. Search for a term known to exist in a specific file, using path: as a filename filter:
    query: "WaitForElement path:WaitUtils.cs repo:PremierInc/pqa-browser-base-framework"
    
  3. Observe: 0 results returned — no error, no warning
  4. Now repeat the same search using filename: instead:
    query: "WaitForElement filename:WaitUtils.cs repo:PremierInc/pqa-browser-base-framework"
    
  5. Observe: 1 result returned — correct file found

Empirically confirmed April 17, 2026 against PremierInc/pqa-browser-base-framework.

Expected Behavior

One of:

  • (a) When path: is used with a value that looks like a filename (contains a . extension), the tool returns a warning or note explaining that path: filters directories and filename: should be used for files, OR
  • (b) The tool documentation/description clearly calls out this distinction, OR
  • (c) The MCP server internally rewrites path:Foo.cs to filename:Foo.cs when a file extension is detected

Actual Behavior

path:WaitUtils.cs returns 0 results with no indication of why. The user/agent has no way to know the qualifier is the problem without knowing the underlying Legacy REST API's distinction between path: and filename:.

Additional Context

Affected version

Environment:

  • VS Code: (check Help > About for exact version)
  • GitHub Copilot Chat extension: 0.44.1
  • GitHub MCP server: Hosted endpoint (https://api.githubcopilot.com/mcp) — powered by github/github-mcp-server; server version is managed by GitHub

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions