@@ -230,6 +230,45 @@ func TestMCPServer_AddSessionTools(t *testing.T) {
230
230
assert .Contains (t , session .GetSessionTools (), "session-tool" )
231
231
}
232
232
233
+ func TestMCPServer_AddSessionTool (t * testing.T ) {
234
+ server := NewMCPServer ("test-server" , "1.0.0" , WithToolCapabilities (true ))
235
+ ctx := context .Background ()
236
+
237
+ // Create a session
238
+ sessionChan := make (chan mcp.JSONRPCNotification , 10 )
239
+ session := & sessionTestClientWithTools {
240
+ sessionID : "session-1" ,
241
+ notificationChannel : sessionChan ,
242
+ initialized : true ,
243
+ }
244
+
245
+ // Register the session
246
+ err := server .RegisterSession (ctx , session )
247
+ require .NoError (t , err )
248
+
249
+ // Add session-specific tool using the new helper method
250
+ err = server .AddSessionTool (
251
+ session .SessionID (),
252
+ mcp .NewTool ("session-tool-helper" ),
253
+ func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
254
+ return mcp .NewToolResultText ("helper result" ), nil
255
+ },
256
+ )
257
+ require .NoError (t , err )
258
+
259
+ // Check that notification was sent
260
+ select {
261
+ case notification := <- sessionChan :
262
+ assert .Equal (t , "notifications/tools/list_changed" , notification .Method )
263
+ case <- time .After (100 * time .Millisecond ):
264
+ t .Error ("Expected notification not received" )
265
+ }
266
+
267
+ // Verify tool was added to session
268
+ assert .Len (t , session .GetSessionTools (), 1 )
269
+ assert .Contains (t , session .GetSessionTools (), "session-tool-helper" )
270
+ }
271
+
233
272
func TestMCPServer_DeleteSessionTools (t * testing.T ) {
234
273
server := NewMCPServer ("test-server" , "1.0.0" , WithToolCapabilities (true ))
235
274
ctx := context .Background ()
0 commit comments