@@ -109,7 +109,7 @@ func TestSessionWithTools_Integration(t *testing.T) {
109109 // Check if the session can be cast to SessionWithTools
110110 swt , ok := s .(SessionWithTools )
111111 require .True (t , ok , "Session should implement SessionWithTools" )
112-
112+
113113 // Check if the tools are accessible
114114 tools := swt .GetSessionTools ()
115115 require .NotNil (t , tools , "Session tools should be available" )
@@ -121,13 +121,13 @@ func TestSessionWithTools_Integration(t *testing.T) {
121121 tool , exists := tools ["session-tool" ]
122122 require .True (t , exists , "Session tool should exist in the map" )
123123 require .NotNil (t , tool , "Session tool should not be nil" )
124-
124+
125125 // Now test calling directly with the handler
126126 result , err := tool .Handler (sessionCtx , testReq )
127127 require .NoError (t , err , "No error calling session tool handler directly" )
128128 require .NotNil (t , result , "Result should not be nil" )
129129 require .Len (t , result .Content , 1 , "Result should have one content item" )
130-
130+
131131 textContent , ok := result .Content [0 ].(mcp.TextContent )
132132 require .True (t , ok , "Content should be TextContent" )
133133 assert .Equal (t , "session-tool result" , textContent .Text , "Result text should match" )
@@ -137,13 +137,13 @@ func TestSessionWithTools_Integration(t *testing.T) {
137137func TestMCPServer_ToolsWithSessionTools (t * testing.T ) {
138138 // Basic test to verify that session-specific tools are returned correctly in a tools list
139139 server := NewMCPServer ("test-server" , "1.0.0" , WithToolCapabilities (true ))
140-
140+
141141 // Add global tools
142142 server .AddTools (
143143 ServerTool {Tool : mcp .NewTool ("global-tool-1" )},
144144 ServerTool {Tool : mcp .NewTool ("global-tool-2" )},
145145 )
146-
146+
147147 // Create a session with tools
148148 session := & fakeSessionWithTools {
149149 sessionID : "session-1" ,
@@ -154,28 +154,28 @@ func TestMCPServer_ToolsWithSessionTools(t *testing.T) {
154154 "global-tool-1" : {Tool : mcp .NewTool ("global-tool-1" , mcp .WithDescription ("Overridden" ))},
155155 },
156156 }
157-
157+
158158 // Register the session
159159 err := server .RegisterSession (context .Background (), session )
160160 require .NoError (t , err )
161-
161+
162162 // List tools with session context
163163 sessionCtx := server .WithContext (context .Background (), session )
164164 resp := server .HandleMessage (sessionCtx , []byte (`{
165165 "jsonrpc": "2.0",
166166 "id": 1,
167167 "method": "tools/list"
168168 }` ))
169-
169+
170170 jsonResp , ok := resp .(mcp.JSONRPCResponse )
171171 require .True (t , ok , "Response should be a JSONRPCResponse" )
172-
172+
173173 result , ok := jsonResp .Result .(mcp.ListToolsResult )
174174 require .True (t , ok , "Result should be a ListToolsResult" )
175-
175+
176176 // Should have 3 tools - 2 global tools (one overridden) and 1 session-specific tool
177177 assert .Len (t , result .Tools , 3 , "Should have 3 tools" )
178-
178+
179179 // Find the overridden tool and verify its description
180180 var found bool
181181 for _ , tool := range result .Tools {
@@ -205,7 +205,7 @@ func TestMCPServer_AddSessionTools(t *testing.T) {
205205 require .NoError (t , err )
206206
207207 // Add session-specific tools
208- err = server .AddSessionTools (session .SessionID (),
208+ err = server .AddSessionTools (session .SessionID (),
209209 ServerTool {Tool : mcp .NewTool ("session-tool" )},
210210 )
211211 require .NoError (t , err )
@@ -321,57 +321,57 @@ func TestMCPServer_ToolFiltering(t *testing.T) {
321321 }` ))
322322 resp , ok := response .(mcp.JSONRPCResponse )
323323 require .True (t , ok )
324-
324+
325325 result , ok := resp .Result .(mcp.ListToolsResult )
326326 require .True (t , ok )
327-
327+
328328 // Should only include tools with the "allow-" prefix
329329 assert .Len (t , result .Tools , 3 )
330-
330+
331331 // Verify all tools start with "allow-"
332332 for _ , tool := range result .Tools {
333- assert .True (t , len (tool .Name ) >= 6 && tool .Name [:6 ] == "allow-" ,
333+ assert .True (t , len (tool .Name ) >= 6 && tool .Name [:6 ] == "allow-" ,
334334 "Tool should start with 'allow-', got: %s" , tool .Name )
335335 }
336336}
337337
338338func TestMCPServer_SendNotificationToSpecificClient (t * testing.T ) {
339339 server := NewMCPServer ("test-server" , "1.0.0" )
340-
340+
341341 session1Chan := make (chan mcp.JSONRPCNotification , 10 )
342342 session1 := & fakeSession {
343343 sessionID : "session-1" ,
344344 notificationChannel : session1Chan ,
345345 initialized : true ,
346346 }
347-
347+
348348 session2Chan := make (chan mcp.JSONRPCNotification , 10 )
349349 session2 := & fakeSession {
350350 sessionID : "session-2" ,
351351 notificationChannel : session2Chan ,
352352 initialized : true ,
353353 }
354-
354+
355355 session3 := & fakeSession {
356356 sessionID : "session-3" ,
357357 notificationChannel : make (chan mcp.JSONRPCNotification , 10 ),
358358 initialized : false , // Not initialized
359359 }
360-
360+
361361 // Register sessions
362362 err := server .RegisterSession (context .Background (), session1 )
363363 require .NoError (t , err )
364364 err = server .RegisterSession (context .Background (), session2 )
365365 require .NoError (t , err )
366366 err = server .RegisterSession (context .Background (), session3 )
367367 require .NoError (t , err )
368-
368+
369369 // Send notification to session 1
370370 err = server .SendNotificationToSpecificClient (session1 .SessionID (), "test-method" , map [string ]any {
371371 "data" : "test-data" ,
372372 })
373373 require .NoError (t , err )
374-
374+
375375 // Check that only session 1 received the notification
376376 select {
377377 case notification := <- session1Chan :
@@ -380,22 +380,22 @@ func TestMCPServer_SendNotificationToSpecificClient(t *testing.T) {
380380 case <- time .After (100 * time .Millisecond ):
381381 t .Error ("Expected notification not received by session 1" )
382382 }
383-
383+
384384 // Verify session 2 did not receive notification
385385 select {
386386 case notification := <- session2Chan :
387387 t .Errorf ("Unexpected notification received by session 2: %v" , notification )
388388 case <- time .After (100 * time .Millisecond ):
389389 // Expected, no notification for session 2
390390 }
391-
391+
392392 // Test sending to non-existent session
393393 err = server .SendNotificationToSpecificClient ("non-existent" , "test-method" , nil )
394394 assert .Error (t , err )
395395 assert .Contains (t , err .Error (), "not found" )
396-
396+
397397 // Test sending to uninitialized session
398398 err = server .SendNotificationToSpecificClient (session3 .SessionID (), "test-method" , nil )
399399 assert .Error (t , err )
400400 assert .Contains (t , err .Error (), "not properly initialized" )
401- }
401+ }
0 commit comments