Reject @filepath local file references in safe-output MCP tool calls#33919
Merged
pelikhan merged 2 commits intoMay 22, 2026
Conversation
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
Copilot
AI
changed the title
Reject @filepath local file references in safe output MCP server
Reject May 22, 2026
@filepath local file references in safe-output MCP tool calls
Copilot created this pull request from a session on behalf of
pelikhan
May 22, 2026 03:53
View session
Contributor
There was a problem hiding this comment.
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) andhandleMessage(stdio) with a consistent invalid-params error. - Added transport-level tests covering absolute and relative
@filepathforms.
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.", | ||
| }; |
This was referenced May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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@filepathnotation and return a clear, actionable error to the agent.Request validation hardening (shared MCP core)
tools/callarguments.Behavior change across both transports
handleRequest)handleMessage)@filepathnotation is unsupportedCoverage updates
@/tmp/...@./...@../...