Skip to content

Commit d489d41

Browse files
committed
fix: update tool name validation to enforce 1-64 character length limit
- Adjusted validation logic and regex to accept tool names between 1 and 64 characters - Updated test cases to reflect new character length requirements - Modified warnings to align with the updated maximum length modelcontextprotocol/modelcontextprotocol#986 (comment)
1 parent f807421 commit d489d41

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/shared/toolNameValidation.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ describe('validateToolName', () => {
5555
expect(result.warnings).toHaveLength(0);
5656
});
5757

58-
test('should accept 128 character names', () => {
59-
const name = 'a'.repeat(128);
58+
test('should accept 64 character names', () => {
59+
const name = 'a'.repeat(64);
6060
const result = validateToolName(name);
6161
expect(result.isValid).toBe(true);
6262
expect(result.warnings).toHaveLength(0);
@@ -70,11 +70,11 @@ describe('validateToolName', () => {
7070
expect(result.warnings).toContain('Tool name cannot be empty');
7171
});
7272

73-
test('should reject names longer than 128 characters', () => {
74-
const name = 'a'.repeat(129);
73+
test('should reject names longer than 64 characters', () => {
74+
const name = 'a'.repeat(65);
7575
const result = validateToolName(name);
7676
expect(result.isValid).toBe(false);
77-
expect(result.warnings).toContain('Tool name exceeds maximum length of 128 characters (current: 129)');
77+
expect(result.warnings).toContain('Tool name exceeds maximum length of 64 characters (current: 129)');
7878
});
7979

8080
test('should reject names with spaces', () => {

src/shared/toolNameValidation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Tool name validation utilities according to SEP: Specify Format for Tool Names
33
*
4-
* Tool names SHOULD be between 1 and 128 characters in length (inclusive).
4+
* Tool names SHOULD be between 1 and 64 characters in length (inclusive).
55
* Tool names are case-sensitive.
66
* Allowed characters: uppercase and lowercase ASCII letters (A-Z, a-z), digits
77
* (0-9), underscore (_), dash (-), dot (.), and forward slash (/).
@@ -11,7 +11,7 @@
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,64}$/;
1515

1616
/**
1717
* Validates a tool name according to the SEP specification
@@ -32,10 +32,10 @@ export function validateToolName(name: string): {
3232
};
3333
}
3434

35-
if (name.length > 128) {
35+
if (name.length > 64) {
3636
return {
3737
isValid: false,
38-
warnings: [`Tool name exceeds maximum length of 128 characters (current: ${name.length})`]
38+
warnings: [`Tool name exceeds maximum length of 64 characters (current: ${name.length})`]
3939
};
4040
}
4141

0 commit comments

Comments
 (0)