Skip to content

Commit 7fc694e

Browse files
fix: update tool name validation to match shipped SEP-986 spec
- Remove forward slash (/) from allowed characters - Keep 128 character limit and other restrictions - Align with final merged specification
1 parent 5b0d7da commit 7fc694e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/shared/toolNameValidation.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ describe('validateToolName', () => {
3737
expect(result.warnings).toHaveLength(0);
3838
});
3939

40-
test('should accept names with forward slashes', () => {
40+
test('should reject names with forward slashes', () => {
4141
const result = validateToolName('user/profile/update');
42-
expect(result.isValid).toBe(true);
43-
expect(result.warnings).toHaveLength(0);
42+
expect(result.isValid).toBe(false);
43+
expect(result.warnings).toContain('Tool name contains invalid characters: "/"');
4444
});
4545

4646
test('should accept mixed character names', () => {
@@ -222,10 +222,10 @@ describe('edge cases and robustness', () => {
222222
expect(result.warnings).toContain('Tool name starts or ends with a dash, which may cause parsing issues in some contexts');
223223
});
224224

225-
test('should warn about names with only forward slashes', () => {
225+
test('should reject names with only forward slashes', () => {
226226
const result = validateToolName('///');
227-
expect(result.isValid).toBe(true);
228-
expect(result.warnings).toContain('Tool name starts or ends with a slash, which may cause parsing issues in some contexts');
227+
expect(result.isValid).toBe(false);
228+
expect(result.warnings).toContain('Tool name contains invalid characters: "/"');
229229
});
230230

231231
test('should handle names with mixed valid and invalid characters', () => {

src/shared/toolNameValidation.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* Tool names SHOULD be between 1 and 128 characters in length (inclusive).
55
* Tool names are case-sensitive.
66
* Allowed characters: uppercase and lowercase ASCII letters (A-Z, a-z), digits
7-
* (0-9), underscore (_), dash (-), dot (.), and forward slash (/).
7+
* (0-9), underscore (_), dash (-), and dot (.).
88
* Tool names SHOULD NOT contain spaces, commas, or other special characters.
99
*/
1010

1111
/**
1212
* Regular expression for valid tool names according to SEP-986 specification
1313
*/
14-
const TOOL_NAME_REGEX = /^[A-Za-z0-9._/-]{1,128}$/;
14+
const TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
1515

1616
/**
1717
* Validates a tool name according to the SEP specification
@@ -56,21 +56,17 @@ export function validateToolName(name: string): {
5656
if (name.startsWith('.') || name.endsWith('.')) {
5757
warnings.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");
5858
}
59-
60-
if (name.startsWith('/') || name.endsWith('/')) {
61-
warnings.push("Tool name starts or ends with a slash, which may cause parsing issues in some contexts");
62-
}
63-
59+
6460
// Check for invalid characters
6561
if (!TOOL_NAME_REGEX.test(name)) {
6662
const invalidChars = name
6763
.split('')
68-
.filter(char => !/[A-Za-z0-9._/-]/.test(char))
64+
.filter(char => !/[A-Za-z0-9._-]/.test(char))
6965
.filter((char, index, arr) => arr.indexOf(char) === index); // Remove duplicates
70-
66+
7167
warnings.push(
7268
`Tool name contains invalid characters: ${invalidChars.map(c => `"${c}"`).join(', ')}`,
73-
"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), dot (.), and forward slash (/)"
69+
"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"
7470
);
7571

7672
return {

0 commit comments

Comments
 (0)