fix(core): sanitize and length-check MCP tool qualified names (#20987)

This commit is contained in:
Abhi
2026-03-03 16:38:52 -05:00
committed by GitHub
parent 52887f712f
commit de0f56aee5
4 changed files with 115 additions and 14 deletions
+4 -2
View File
@@ -260,8 +260,10 @@ export function isValidToolName(
return !!options.allowWildcards;
}
// Basic slug validation for server and tool names
const slugRegex = /^[a-z0-9-_]+$/i;
// Basic slug validation for server and tool names.
// We allow dots (.) and colons (:) as they are valid in function names and
// used for truncation markers.
const slugRegex = /^[a-z0-9_.:-]+$/i;
return slugRegex.test(server) && slugRegex.test(tool);
}