@@ -33,7 +33,7 @@ describe("mcp-name utilities", () => {
3333 } )
3434
3535 it ( "should have correct max tool name length" , ( ) => {
36- expect ( MAX_TOOL_NAME_LENGTH ) . toBe ( 128 )
36+ expect ( MAX_TOOL_NAME_LENGTH ) . toBe ( 64 )
3737 } )
3838
3939 it ( "should have correct hash suffix length" , ( ) => {
@@ -165,24 +165,24 @@ describe("mcp-name utilities", () => {
165165 expect ( buildMcpToolName ( "server@name" , "tool!name" ) ) . toBe ( "mcp--servername--toolname" )
166166 } )
167167
168- it ( "should truncate long names to 128 characters with hash suffix" , ( ) => {
169- const longServer = "a" . repeat ( 80 )
170- const longTool = "b" . repeat ( 80 )
168+ it ( "should truncate long names to 64 characters with hash suffix" , ( ) => {
169+ const longServer = "a" . repeat ( 50 )
170+ const longTool = "b" . repeat ( 50 )
171171 const result = buildMcpToolName ( longServer , longTool )
172- expect ( result . length ) . toBeLessThanOrEqual ( 128 )
173- expect ( result . length ) . toBe ( 128 )
172+ expect ( result . length ) . toBeLessThanOrEqual ( 64 )
173+ expect ( result . length ) . toBe ( 64 )
174174 expect ( result . startsWith ( "mcp--" ) ) . toBe ( true )
175175 // Should end with underscore + 8 char hash suffix
176176 expect ( result ) . toMatch ( / _ [ a - f 0 - 9 ] { 8 } $ / )
177177 } )
178178
179179 it ( "should use hash suffix for long names and cache them" , ( ) => {
180- const longServer = "a" . repeat ( 80 )
181- const longTool = "b" . repeat ( 80 )
180+ const longServer = "a" . repeat ( 50 )
181+ const longTool = "b" . repeat ( 50 )
182182 const result = buildMcpToolName ( longServer , longTool )
183183
184184 // The shortened name should be deterministic
185- expect ( result . length ) . toBe ( 128 )
185+ expect ( result . length ) . toBe ( 64 )
186186 expect ( result ) . toMatch ( / _ [ a - f 0 - 9 ] { 8 } $ / )
187187
188188 // Building again should return the same result (from cache)
@@ -191,8 +191,8 @@ describe("mcp-name utilities", () => {
191191 } )
192192
193193 it ( "should produce deterministic hash suffixes" , ( ) => {
194- const longServer = "a" . repeat ( 80 )
195- const longTool = "b" . repeat ( 80 )
194+ const longServer = "a" . repeat ( 50 )
195+ const longTool = "b" . repeat ( 50 )
196196 // Build the same name twice with cache cleared between
197197 clearEncodedNameCache ( )
198198 const result1 = buildMcpToolName ( longServer , longTool )
@@ -203,12 +203,12 @@ describe("mcp-name utilities", () => {
203203 } )
204204
205205 it ( "should produce unique hash suffixes for different tools" , ( ) => {
206- const longServer = "a" . repeat ( 80 )
207- const result1 = buildMcpToolName ( longServer , "tool1_" + "x" . repeat ( 70 ) )
208- const result2 = buildMcpToolName ( longServer , "tool2_" + "y" . repeat ( 70 ) )
206+ const longServer = "a" . repeat ( 50 )
207+ const result1 = buildMcpToolName ( longServer , "tool1_" + "x" . repeat ( 40 ) )
208+ const result2 = buildMcpToolName ( longServer , "tool2_" + "y" . repeat ( 40 ) )
209209 // Both should be truncated
210- expect ( result1 . length ) . toBe ( 128 )
211- expect ( result2 . length ) . toBe ( 128 )
210+ expect ( result1 . length ) . toBe ( 64 )
211+ expect ( result2 . length ) . toBe ( 64 )
212212 // Should have different hash suffixes
213213 expect ( result1 ) . not . toBe ( result2 )
214214 } )
@@ -437,7 +437,7 @@ describe("mcp-name utilities", () => {
437437
438438 // Should NOT have hash suffix
439439 expect ( builtName ) . toBe ( "mcp--server--get___data" )
440- expect ( builtName . length ) . toBeLessThan ( 128 )
440+ expect ( builtName . length ) . toBeLessThan ( 64 )
441441
442442 // Normal decode path should work
443443 const parsed = parseMcpToolName ( builtName )
@@ -456,7 +456,7 @@ describe("mcp-name utilities", () => {
456456 const encodedName = buildMcpToolName ( serverName , toolName )
457457
458458 // Should be truncated to 128 chars with hash suffix
459- expect ( encodedName . length ) . toBe ( 128 )
459+ expect ( encodedName . length ) . toBe ( 64 )
460460 expect ( encodedName ) . toMatch ( / _ [ a - f 0 - 9 ] { 8 } $ / )
461461
462462 // The new approach: use findToolByEncodedMcpName to find the matching tool
@@ -487,8 +487,8 @@ describe("mcp-name utilities", () => {
487487 } )
488488
489489 it ( "should find tool for shortened names with hash suffix" , ( ) => {
490- const serverName = "a" . repeat ( 80 )
491- const toolName = "b" . repeat ( 80 ) + "-hyphen"
490+ const serverName = "a" . repeat ( 50 )
491+ const toolName = "b" . repeat ( 50 ) + "-hyphen"
492492 const encodedName = buildMcpToolName ( serverName , toolName )
493493
494494 // The encoded name should have a hash suffix
@@ -541,8 +541,8 @@ describe("mcp-name utilities", () => {
541541 describe ( "clearEncodedNameCache" , ( ) => {
542542 it ( "should clear the encoded name cache" , ( ) => {
543543 // Build some names to populate cache
544- const longServer = "a" . repeat ( 80 )
545- const longTool = "b" . repeat ( 80 )
544+ const longServer = "a" . repeat ( 50 )
545+ const longTool = "b" . repeat ( 50 )
546546 buildMcpToolName ( longServer , longTool )
547547 buildMcpToolName ( "server" , "tool" )
548548
@@ -552,7 +552,7 @@ describe("mcp-name utilities", () => {
552552 // Verify cache is cleared by checking that rebuilding takes the same path
553553 // (we can't directly access the cache, but the function should work)
554554 const result = buildMcpToolName ( longServer , longTool )
555- expect ( result . length ) . toBe ( 128 )
555+ expect ( result . length ) . toBe ( 64 )
556556 expect ( result ) . toMatch ( / _ [ a - f 0 - 9 ] { 8 } $ / )
557557 } )
558558 } )
0 commit comments