Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reject @filepath local file references in safe-output MCP tool calls#33919

Merged
pelikhan merged 2 commits into
mainfrom
copilot/update-mcp-server-file-reference-detection
May 22, 2026
Merged

Reject @filepath local file references in safe-output MCP tool calls#33919
pelikhan merged 2 commits into
mainfrom
copilot/update-mcp-server-file-reference-detection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

Safe-output MCP currently accepts tool arguments that can contain local file references like @/tmp/..., which should be rejected. This change adds explicit protocol-level validation to refuse @filepath notation and return a clear, actionable error to the agent.

  • Request validation hardening (shared MCP core)

    • Added centralized detection for local file reference notation in tools/call arguments.
    • Validation is recursive across argument payloads (strings, arrays, nested objects).
  • Behavior change across both transports

    • Applied the same rejection path in both request handlers:
      • HTTP (handleRequest)
      • stdio (handleMessage)
    • Error text now explicitly states:
      • @filepath notation is unsupported
      • do not inline files
      • provide content directly in arguments
  • Coverage updates

    • Added transport-level tests for absolute and relative forms:
      • @/tmp/...
      • @./...
      • @../...
if (containsAtFilepathReference(args)) {
  throw {
    code: -32602,
    message:
      "Invalid params: local file references using @filepath notation are not supported by this MCP server. Do not attempt to inline files. Provide the needed content directly in arguments instead.",
  };
}

Copilot AI changed the title Reject @filepath local file references in safe output MCP server Reject @filepath local file references in safe-output MCP tool calls May 22, 2026
Copilot AI requested a review from pelikhan May 22, 2026 03:53
@pelikhan pelikhan marked this pull request as ready for review May 22, 2026 03:55
Copilot AI review requested due to automatic review settings May 22, 2026 03:55
@pelikhan pelikhan merged commit f460283 into main May 22, 2026
2 checks passed
@pelikhan pelikhan deleted the copilot/update-mcp-server-file-reference-detection branch May 22, 2026 03:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens MCP tools/call request validation by rejecting local file references using @filepath notation in tool arguments, returning a clearer error across both HTTP and stdio transports.

Changes:

  • Added recursive detection for @/…, @./…, and @../… patterns in tool-call arguments.
  • Applied the same rejection behavior in both handleRequest (HTTP) and handleMessage (stdio) with a consistent invalid-params error.
  • Added transport-level tests covering absolute and relative @filepath forms.
Show a summary per file
File Description
actions/setup/js/mcp_server_core.cjs Adds recursive @filepath detection and rejects such tool-call arguments in both HTTP and stdio handlers.
actions/setup/js/mcp_server_core.test.cjs Adds stdio/handleMessage tests asserting @filepath arguments are rejected.
actions/setup/js/mcp_http_transport.test.cjs Adds HTTP/handleRequest tests asserting @filepath arguments are rejected.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

*/
function containsAtFilepathReference(value) {
if (typeof value === "string") {
return /(?:^|\s)@(?:\/|\.{1,2}\/)[^\s]+/.test(value);
expect(results[0].error.message).toContain("not supported");
expect(results[0].error.message).toContain("Do not attempt to inline files");
});

Comment on lines +613 to +618
if (containsAtFilepathReference(args)) {
throw {
code: -32602,
message:
"Invalid params: local file references using @filepath notation are not supported by this MCP server. Do not attempt to inline files. Provide the needed content directly in arguments instead.",
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants