@@ -32,7 +32,7 @@ describe("mcp-name utilities", () => {
3232 } )
3333
3434 it ( "should have correct max tool name length" , ( ) => {
35- expect ( MAX_TOOL_NAME_LENGTH ) . toBe ( 64 )
35+ expect ( MAX_TOOL_NAME_LENGTH ) . toBe ( 128 )
3636 } )
3737
3838 it ( "should have correct hash suffix length" , ( ) => {
@@ -164,20 +164,20 @@ describe("mcp-name utilities", () => {
164164 expect ( buildMcpToolName ( "server@name" , "tool!name" ) ) . toBe ( "mcp--servername--toolname" )
165165 } )
166166
167- it ( "should truncate long names to 64 characters with hash suffix" , ( ) => {
168- const longServer = "a" . repeat ( 50 )
169- const longTool = "b" . repeat ( 50 )
167+ it ( "should truncate long names to 128 characters with hash suffix" , ( ) => {
168+ const longServer = "a" . repeat ( 80 )
169+ const longTool = "b" . repeat ( 80 )
170170 const result = buildMcpToolName ( longServer , longTool )
171- expect ( result . length ) . toBeLessThanOrEqual ( 64 )
172- expect ( result . length ) . toBe ( 64 )
171+ expect ( result . length ) . toBeLessThanOrEqual ( 128 )
172+ expect ( result . length ) . toBe ( 128 )
173173 expect ( result . startsWith ( "mcp--" ) ) . toBe ( true )
174174 // Should end with underscore + 8 char hash suffix
175175 expect ( result ) . toMatch ( / _ [ a - f 0 - 9 ] { 8 } $ / )
176176 } )
177177
178178 it ( "should use hash suffix for long names and register them" , ( ) => {
179- const longServer = "a" . repeat ( 50 )
180- const longTool = "b" . repeat ( 50 )
179+ const longServer = "a" . repeat ( 80 )
180+ const longTool = "b" . repeat ( 80 )
181181 const result = buildMcpToolName ( longServer , longTool )
182182
183183 // The shortened name should be registered
@@ -190,8 +190,8 @@ describe("mcp-name utilities", () => {
190190 } )
191191
192192 it ( "should produce deterministic hash suffixes" , ( ) => {
193- const longServer = "a" . repeat ( 50 )
194- const longTool = "b" . repeat ( 50 )
193+ const longServer = "a" . repeat ( 80 )
194+ const longTool = "b" . repeat ( 80 )
195195 // Build the same name twice
196196 clearMcpToolNameRegistry ( )
197197 const result1 = buildMcpToolName ( longServer , longTool )
@@ -202,12 +202,12 @@ describe("mcp-name utilities", () => {
202202 } )
203203
204204 it ( "should produce unique hash suffixes for different tools" , ( ) => {
205- const longServer = "a" . repeat ( 50 )
206- const result1 = buildMcpToolName ( longServer , "tool1_" + "x" . repeat ( 40 ) )
207- const result2 = buildMcpToolName ( longServer , "tool2_" + "y" . repeat ( 40 ) )
205+ const longServer = "a" . repeat ( 80 )
206+ const result1 = buildMcpToolName ( longServer , "tool1_" + "x" . repeat ( 70 ) )
207+ const result2 = buildMcpToolName ( longServer , "tool2_" + "y" . repeat ( 70 ) )
208208 // Both should be truncated
209- expect ( result1 . length ) . toBe ( 64 )
210- expect ( result2 . length ) . toBe ( 64 )
209+ expect ( result1 . length ) . toBe ( 128 )
210+ expect ( result2 . length ) . toBe ( 128 )
211211 // Should have different hash suffixes
212212 expect ( result1 ) . not . toBe ( result2 )
213213 } )
@@ -429,15 +429,15 @@ describe("mcp-name utilities", () => {
429429 describe ( "hash suffix roundtrip - fixes issue #10766" , ( ) => {
430430 it ( "should preserve original names through roundtrip with long hyphenated tool names" , ( ) => {
431431 // This is the exact scenario from issue #10766
432- // Tool name with many hyphens that exceeds 64 chars when encoded
433- const serverName = "abcdefghij-kl-mnop-qrs-tuv"
434- const toolName = "wxyz-abcd-efghijk-lmno"
432+ // Tool name with many hyphens that exceeds 128 chars when encoded
433+ const serverName = "abcdefghij-kl-mnop-qrs-tuv-with-extra-long-suffix-to-exceed-limit "
434+ const toolName = "wxyz-abcd-efghijk-lmno-plus-additional-long-suffix-here "
435435
436436 // Build the tool name
437437 const builtName = buildMcpToolName ( serverName , toolName )
438438
439- // Should be truncated to 64 chars with hash suffix
440- expect ( builtName . length ) . toBe ( 64 )
439+ // Should be truncated to 128 chars with hash suffix
440+ expect ( builtName . length ) . toBe ( 128 )
441441 expect ( builtName ) . toMatch ( / _ [ a - f 0 - 9 ] { 8 } $ / )
442442
443443 // The critical fix: parsing should return the ORIGINAL names
@@ -450,14 +450,14 @@ describe("mcp-name utilities", () => {
450450
451451 it ( "should not corrupt hyphen encoding when truncation is needed" , ( ) => {
452452 // Long server and tool names that would cause truncation mid-encoding
453- const serverName = "very-long-server-name-with-many-hyphens"
454- const toolName = "another-long-tool-name-with-hyphens"
453+ const serverName = "very-long-server-name-with-many-hyphens-and-extra-content-to-exceed "
454+ const toolName = "another-long-tool-name-with-hyphens-and-extra-content-to-exceed "
455455
456456 // Build the tool name
457457 const builtName = buildMcpToolName ( serverName , toolName )
458458
459- // Should be truncated to 64 chars
460- expect ( builtName . length ) . toBe ( 64 )
459+ // Should be truncated to 128 chars
460+ expect ( builtName . length ) . toBe ( 128 )
461461
462462 // Parse should return original names (via registry lookup)
463463 const parsed = parseMcpToolName ( builtName )
@@ -476,7 +476,7 @@ describe("mcp-name utilities", () => {
476476
477477 // Should NOT have hash suffix
478478 expect ( builtName ) . toBe ( "mcp--server--get___data" )
479- expect ( builtName . length ) . toBeLessThan ( 64 )
479+ expect ( builtName . length ) . toBeLessThan ( 128 )
480480
481481 // Normal decode path should work
482482 const parsed = parseMcpToolName ( builtName )
@@ -487,8 +487,8 @@ describe("mcp-name utilities", () => {
487487 } )
488488
489489 it ( "should handle the registry lookup for shortened names" , ( ) => {
490- const serverName = "a" . repeat ( 30 )
491- const toolName = "b" . repeat ( 30 ) + "-hyphen"
490+ const serverName = "a" . repeat ( 80 )
491+ const toolName = "b" . repeat ( 80 ) + "-hyphen"
492492
493493 // Build registers the shortened name
494494 const builtName = buildMcpToolName ( serverName , toolName )
@@ -508,8 +508,8 @@ describe("mcp-name utilities", () => {
508508 describe ( "clearMcpToolNameRegistry" , ( ) => {
509509 it ( "should clear all registered tool names" , ( ) => {
510510 // Register some tool names via buildMcpToolName
511- const longServer = "a" . repeat ( 50 )
512- const longTool = "b" . repeat ( 50 )
511+ const longServer = "a" . repeat ( 80 )
512+ const longTool = "b" . repeat ( 80 )
513513 buildMcpToolName ( longServer , longTool )
514514
515515 expect ( mcpToolNameRegistry . size ) . toBeGreaterThan ( 0 )
0 commit comments