|
217 | 217 | expect($toolListResult['statusCode'])->toBe(200);
|
218 | 218 | expect($toolListResult['body']['id'])->toBe('tool-list-json-1');
|
219 | 219 | expect($toolListResult['body']['result']['tools'])->toBeArray();
|
220 |
| - expect(count($toolListResult['body']['result']['tools']))->toBe(2); |
| 220 | + expect(count($toolListResult['body']['result']['tools']))->toBe(3); |
221 | 221 | expect($toolListResult['body']['result']['tools'][0]['name'])->toBe('greet_streamable_tool');
|
222 | 222 | expect($toolListResult['body']['result']['tools'][1]['name'])->toBe('sum_streamable_tool');
|
| 223 | + expect($toolListResult['body']['result']['tools'][2]['name'])->toBe('tool_reads_call_context'); |
| 224 | + })->group('integration', 'streamable_http_json'); |
| 225 | + |
| 226 | + it('passes request in CallContext', function () { |
| 227 | + await($this->jsonClient->sendRequest('initialize', [ |
| 228 | + 'protocolVersion' => Protocol::LATEST_PROTOCOL_VERSION, |
| 229 | + 'clientInfo' => ['name' => 'JsonModeClient', 'version' => '1.0'], |
| 230 | + 'capabilities' => [] |
| 231 | + ], 'init-json-callcontext')); |
| 232 | + await($this->jsonClient->sendNotification('notifications/initialized')); |
| 233 | + |
| 234 | + $toolResult = await($this->jsonClient->sendRequest('tools/call', [ |
| 235 | + 'name' => 'tool_reads_call_context', |
| 236 | + 'arguments' => [] |
| 237 | + ], 'tool-json-callcontext-1', ['X-Test-Header' => 'TestValue'])); |
| 238 | + |
| 239 | + expect($toolResult['statusCode'])->toBe(200); |
| 240 | + expect($toolResult['body']['id'])->toBe('tool-json-callcontext-1'); |
| 241 | + expect($toolResult['body'])->not->toHaveKey('error'); |
| 242 | + expect($toolResult['body']['result']['content'][0]['text'])->toBe('TestValue'); |
223 | 243 | })->group('integration', 'streamable_http_json');
|
224 | 244 |
|
225 | 245 | it('can read a registered resource', function () {
|
|
412 | 432 | expect($response3['error']['message'])->toContain("Method 'nonexistent/method' not found");
|
413 | 433 | })->group('integration', 'streamable_http_stream');
|
414 | 434 |
|
| 435 | + it('passes request in CallContext', function () { |
| 436 | + await($this->streamClient->sendInitializeRequest([ |
| 437 | + 'protocolVersion' => Protocol::LATEST_PROTOCOL_VERSION, |
| 438 | + 'clientInfo' => ['name' => 'StreamModeClient', 'version' => '1.0'], |
| 439 | + 'capabilities' => [] |
| 440 | + ], 'init-stream-callcontext')); |
| 441 | + expect($this->streamClient->sessionId)->toBeString()->not->toBeEmpty(); |
| 442 | + await($this->streamClient->sendHttpNotification('notifications/initialized')); |
| 443 | + |
| 444 | + $toolResult = await($this->streamClient->sendRequest('tools/call', [ |
| 445 | + 'name' => 'tool_reads_call_context', |
| 446 | + 'arguments' => [] |
| 447 | + ], 'tool-stream-callcontext-1', ['X-Test-Header' => 'TestValue'])); |
| 448 | + |
| 449 | + expect($toolResult['id'])->toBe('tool-stream-callcontext-1'); |
| 450 | + expect($toolResult)->not->toHaveKey('error'); |
| 451 | + expect($toolResult['result']['content'][0]['text'])->toBe('TestValue'); |
| 452 | + })->group('integration', 'streamable_http_stream'); |
| 453 | + |
415 | 454 | it('can handle tool list request', function () {
|
416 | 455 | await($this->streamClient->sendInitializeRequest(['protocolVersion' => Protocol::LATEST_PROTOCOL_VERSION, 'clientInfo' => []], 'init-stream-tools'));
|
417 | 456 | await($this->streamClient->sendHttpNotification('notifications/initialized'));
|
|
421 | 460 | expect($toolListResponse['id'])->toBe('tool-list-stream-1');
|
422 | 461 | expect($toolListResponse)->not->toHaveKey('error');
|
423 | 462 | expect($toolListResponse['result']['tools'])->toBeArray();
|
424 |
| - expect(count($toolListResponse['result']['tools']))->toBe(2); |
| 463 | + expect(count($toolListResponse['result']['tools']))->toBe(3); |
425 | 464 | expect($toolListResponse['result']['tools'][0]['name'])->toBe('greet_streamable_tool');
|
426 | 465 | expect($toolListResponse['result']['tools'][1]['name'])->toBe('sum_streamable_tool');
|
| 466 | + expect($toolListResponse['result']['tools'][2]['name'])->toBe('tool_reads_call_context'); |
427 | 467 | })->group('integration', 'streamable_http_stream');
|
428 | 468 |
|
429 | 469 | it('can read a registered resource', function () {
|
|
604 | 644 | expect($response3['error']['message'])->toContain("Method 'nonexistent/method' not found");
|
605 | 645 | })->group('integration', 'streamable_http_stateless');
|
606 | 646 |
|
| 647 | + it('passes request in CallContext', function () { |
| 648 | + $toolResult = await($this->statelessClient->sendRequest('tools/call', [ |
| 649 | + 'name' => 'tool_reads_call_context', |
| 650 | + 'arguments' => [] |
| 651 | + ], 'tool-stateless-callcontext-1', ['X-Test-Header' => 'TestValue'])); |
| 652 | + |
| 653 | + expect($toolResult['statusCode'])->toBe(200); |
| 654 | + expect($toolResult['body']['id'])->toBe('tool-stateless-callcontext-1'); |
| 655 | + expect($toolResult['body'])->not->toHaveKey('error'); |
| 656 | + expect($toolResult['body']['result']['content'][0]['text'])->toBe('TestValue'); |
| 657 | + })->group('integration', 'streamable_http_stateless'); |
| 658 | + |
607 | 659 | it('can handle tool list request', function () {
|
608 | 660 | $toolListResult = await($this->statelessClient->sendRequest('tools/list', [], 'tool-list-stateless-1'));
|
609 | 661 |
|
610 | 662 | expect($toolListResult['statusCode'])->toBe(200);
|
611 | 663 | expect($toolListResult['body']['id'])->toBe('tool-list-stateless-1');
|
612 | 664 | expect($toolListResult['body'])->not->toHaveKey('error');
|
613 | 665 | expect($toolListResult['body']['result']['tools'])->toBeArray();
|
614 |
| - expect(count($toolListResult['body']['result']['tools']))->toBe(2); |
| 666 | + expect(count($toolListResult['body']['result']['tools']))->toBe(3); |
615 | 667 | expect($toolListResult['body']['result']['tools'][0]['name'])->toBe('greet_streamable_tool');
|
616 | 668 | expect($toolListResult['body']['result']['tools'][1]['name'])->toBe('sum_streamable_tool');
|
| 669 | + expect($toolListResult['body']['result']['tools'][2]['name'])->toBe('tool_reads_call_context'); |
617 | 670 | })->group('integration', 'streamable_http_stateless');
|
618 | 671 |
|
619 | 672 | it('can read a registered resource', function () {
|
|
0 commit comments