@@ -91,6 +91,41 @@ func TestIntentCapture(t *testing.T) {
9191 assert .Equal (t , "test intent description" , toolSpan .Meta ["intent" ])
9292}
9393
94+ func TestIntentCaptureConcurrentListTools (t * testing.T ) {
95+ tt := testTracer (t )
96+ defer tt .Stop ()
97+
98+ srv := server .NewMCPServer ("test-server" , "1.0.0" , WithMCPServerTracing (& TracingConfig {IntentCaptureEnabled : true }))
99+
100+ calcTool := mcp .NewTool ("calculator" ,
101+ mcp .WithDescription ("A simple calculator" ),
102+ mcp .WithString ("operation" , mcp .Required (), mcp .Description ("The operation to perform" )),
103+ mcp .WithNumber ("x" , mcp .Required (), mcp .Description ("First number" )),
104+ mcp .WithNumber ("y" , mcp .Required (), mcp .Description ("Second number" )))
105+
106+ srv .AddTool (calcTool , func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
107+ return mcp .NewToolResultText (`{"result":8}` ), nil
108+ })
109+
110+ ctx := context .Background ()
111+
112+ const numGoroutines = 10
113+ done := make (chan struct {})
114+
115+ for i := 0 ; i < numGoroutines ; i ++ {
116+ go func () {
117+ defer func () { done <- struct {}{} }()
118+ for j := 0 ; j < 100 ; j ++ {
119+ srv .HandleMessage (ctx , []byte (`{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}` ))
120+ }
121+ }()
122+ }
123+
124+ for i := 0 ; i < numGoroutines ; i ++ {
125+ <- done
126+ }
127+ }
128+
94129func mustMarshal (v interface {}) []byte {
95130 b , _ := json .Marshal (v )
96131 return b
0 commit comments