@@ -56,3 +56,54 @@ test("getMCPToolName - handles mixed case in server names", () => {
5656 const result = getMCPToolName ( server , tool ) ;
5757 expect ( result ) . toBe ( "gitlab_create_merge_request" ) ;
5858} ) ;
59+
60+ test ( "getMCPToolName - handles server names with special characters (parentheses)" , ( ) => {
61+ const server = createMcpServer ( "Linear MCP (SSE)" ) ;
62+ const tool = createMCPTool ( "create_issue" ) ;
63+
64+ const result = getMCPToolName ( server , tool ) ;
65+ // Should only contain alphanumeric characters and underscores
66+ expect ( result ) . toMatch ( / ^ [ a - z A - Z 0 - 9 _ ] + $ / ) ;
67+ expect ( result ) . toBe ( "linear_mcp_sse_create_issue" ) ;
68+ } ) ;
69+
70+ test ( "getMCPToolName - handles server names with dots and other special characters" , ( ) => {
71+ const server = createMcpServer ( "My.Server@Test!" ) ;
72+ const tool = createMCPTool ( "test_action" ) ;
73+
74+ const result = getMCPToolName ( server , tool ) ;
75+ // Should only contain alphanumeric characters and underscores
76+ expect ( result ) . toMatch ( / ^ [ a - z A - Z 0 - 9 _ ] + $ / ) ;
77+ expect ( result ) . toBe ( "my_server_test_test_action" ) ;
78+ } ) ;
79+
80+ test ( "getMCPToolName - handles server names with multiple consecutive special characters" , ( ) => {
81+ const server = createMcpServer ( "Server@@##Name" ) ;
82+ const tool = createMCPTool ( "action" ) ;
83+
84+ const result = getMCPToolName ( server , tool ) ;
85+ // Should only contain alphanumeric characters and underscores (no hyphens or multiple underscores)
86+ expect ( result ) . toMatch ( / ^ [ a - z A - Z 0 - 9 _ ] + $ / ) ;
87+ expect ( result ) . toBe ( "server_name_action" ) ;
88+ } ) ;
89+
90+ test ( "getMCPToolName - handles server names with hyphens" , ( ) => {
91+ const server = createMcpServer ( "My-Server-Name" ) ;
92+ const tool = createMCPTool ( "test_action" ) ;
93+
94+ const result = getMCPToolName ( server , tool ) ;
95+ // Should only contain alphanumeric characters and underscores
96+ expect ( result ) . toMatch ( / ^ [ a - z A - Z 0 - 9 _ ] + $ / ) ;
97+ expect ( result ) . toBe ( "my_server_name_test_action" ) ;
98+ } ) ;
99+
100+ test ( "getMCPToolName - handles multiple consecutive underscores in server name" , ( ) => {
101+ const server = createMcpServer ( "Linear__MCP" ) ;
102+ const tool = createMCPTool ( "create_issue" ) ;
103+
104+ const result = getMCPToolName ( server , tool ) ;
105+ // Should only contain alphanumeric characters and single underscores
106+ expect ( result ) . toMatch ( / ^ [ a - z A - Z 0 - 9 _ ] + $ / ) ;
107+ expect ( result ) . not . toMatch ( / _ _ / ) ;
108+ expect ( result ) . toBe ( "linear_mcp_create_issue" ) ;
109+ } ) ;
0 commit comments