Commit graph php-sdk/tests
Author SHA1 Message Date
Christopher Hertel
e8f5a8ba22
Extend elicitation enum schema compliance (#261) 2026-03-22 18:46:40 +01:00
simon chrzanowski
faac4a525c
[Server] add a reference handler setter to server builder (#265)
* feat: add setReferenceHandler to Builder

Allow consumers to provide a custom ReferenceHandlerInterface
implementation (e.g. a security-aware decorator) instead of
always using the default ReferenceHandler.

* test: add BuilderTest for setReferenceHandler

- Fluent API returns builder instance
- build() succeeds with and without custom handler
- Integration test verifies custom handler intercepts tool calls

* style: fix codestyle in BuilderTest

* style: use imports instead of inline FQCNs in BuilderTest

* docs: add changelog entry for setReferenceHandler
2026-03-13 14:39:13 +01:00
dependabot[bot]
591abb4620
chore(deps): update phpdocumentor/reflection-docblock requirement || ^6.0 (#256)
Updates the requirements on [phpdocumentor/reflection-docblock](https://github.com/phpDocumentor/ReflectionDocBlock) to permit the latest version.
- [Release notes](https://github.com/phpDocumentor/ReflectionDocBlock/releases)
- [Commits](https://github.com/phpDocumentor/ReflectionDocBlock/compare/5.6.0...6.0.2)

---
updated-dependencies:
- dependency-name: phpdocumentor/reflection-docblock
  dependency-version: 6.0.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-10 23:52:01 +01:00
Christopher Hertel
ae320646bf
Encapsulate session handling from protocol to new SessionManager (#247) 2026-03-10 18:09:15 +01:00
Volodymyr Panivko
e3f4b88768
[Server] Oauth2 based on middleware (#221)
* Add Middleware handlers to StreamableHttpTransport

* OAuth Implementation based on middleware

* OAuth Implementation based on middleware

* Add Middleware handlers to StreamableHttpTransport

* OAuth Implementation based on middleware

* OAuth Implementation based on middleware

Signed-off-by: Volodymyr Panivko <sveneld300@gmail.com>

* Address PR review feedback for OAuth middleware

* Apply php-cs-fixer to satisfy QA

* Use Mcp exception classes in OAuth middleware

* Refactor OAuth HTTP stack and add Microsoft example policies

* Fix QA PHPStan findings in OAuth examples and auth middleware

* Require OIDC discovery in JWKS provider and refine OAuth proxy behavior

* Remove local development docker artifacts from VCS

* Revert .gitignore changes for local docker files

* Fix body retrieval in OAuthRequestMetaMiddleware for proper string conversion

Signed-off-by: Volodymyr Panivko <sveneld300@gmail.com>

* Address OAuth PR review feedback and align example configs

* Fix QA style issues and add authorization docs

* Fix PHPStan typing issues in OAuth middleware

* Remove duplicate Middleware namespace, consolidate under Http\Middleware

Remove old Mcp\Server\Transport\Middleware\ classes that were duplicated
in Mcp\Server\Transport\Http\Middleware\ and Http\OAuth\. Update docs
to reference the correct namespaces.

* Address PR review: replace Throwable catch with specific exceptions, add JSON_THROW_ON_ERROR

- JwtTokenValidator: replace catch(\Throwable) with explicit
  \InvalidArgumentException|\UnexpectedValueException|\DomainException,
  letting RuntimeException from JwksProvider propagate as infrastructure errors
- OAuthProxyMiddleware: add \JSON_THROW_ON_ERROR to json_encode for metadata response
- Update tests to expect RuntimeException for JWKS infrastructure failures

---------

Signed-off-by: Volodymyr Panivko <sveneld300@gmail.com>
Co-authored-by: Volodymyr Panivko <volodymyr.panivko@togethernetworks.com>
2026-03-10 17:10:07 +01:00
Antoine Bluchet
61c20f1450
fix(session): initialize data lazily in save() to prevent uninitialized property access (#252) 2026-03-05 00:07:49 +01:00
Edouard Courty
1f5f7e16a3
chore(http): create constant for session id header (#246) 2026-02-23 22:42:54 +01:00
Edouard Courty
158e64627f
feat(server): add server lifecycle events (#175)
Signed-off-by: Edouard Courty <edouard.courty2@gmail.com>
2026-02-23 22:40:43 +01:00
Sule-Balogun Olanrewaju
2166b38d56
Add missing handler for resource subscribe and unsubscribe (#220) 2026-02-18 00:11:35 +01:00
Johannes Wachter
02e86377e4
Add elicitation support for server-to-client user input requests (#228)
- Add ElicitAction enum (accept/decline/cancel)
- Add schema definitions for elicitation fields (string, number, boolean, enum)
- Add ElicitationSchema wrapper for requestedSchema
- Add ElicitRequest and ElicitResult for elicitation/create method
- Update ClientCapabilities to support elicitation capability
- Add elicit() method to ClientGateway
- Store client capabilities in session during initialization
- Add comprehensive unit tests
- Add elicitation example server with book_restaurant, confirm_action, and collect_feedback tools
2026-02-15 23:34:19 +01:00
Sule-Balogun Olanrewaju
aafac3ddf5
Feat: Improve invalid resource template messages (#245) 2026-02-13 21:46:03 +01:00
Alexis Lefebvre
6e97aafb9c
feat: improve invalid resource messages (#242) 2026-02-13 18:02:43 +01:00
Volodymyr Panivko
8f8af90007
Fix Invalid data in Session (#241)
Signed-off-by: Volodymyr Panivko <sveneld300@gmail.com>
2026-02-11 20:35:41 +01:00
Volodymyr Panivko
43e7a39a21
Add Middleware handlers to StreamableHttpTransport (#218) 2026-02-11 20:33:31 +01:00
Christopher Hertel
c19d550c27
[Server] Shift away session decode from constructor (#238)
* Shift away session decode from constructor

* add a small test

---------

Co-authored-by: Tobias Nyholm <tobias.nyholm@gmail.com>
2026-02-08 15:49:14 +01:00
Christopher Hertel
2fe982505f
Switch pipeline to conformance baseline (#230) 2026-02-01 11:59:44 +01:00
Christopher Hertel
c081b90d74
Update codestyle based on updated Symfony rules (#229) 2026-02-01 11:54:31 +01:00
Mateu Aguiló Bosch
ab4f686e18
refactor: put formatters into dedicated classes (#224)
Split formatting logic from Reference classes into dedicated formatter classes:
- ToolResultFormatter: Formats tool execution results into Content items
- PromptResultFormatter: Formats prompt results into PromptMessage items
- ResourceResultFormatter: Formats resource results into ResourceContents items

This refactor:
- Eliminates 122 lines of code duplication between ResourceReference and
  ResourceTemplateReference (identical formatting logic)
- Improves code organization by separating formatting concerns from
  capability reference management
- Makes formatters independently testable and reusable
- Reduces Reference classes by ~450 lines while maintaining all functionality

Changes:
- Create src/Capability/Formatter/* with three formatter classes
- Update Reference classes to delegate to formatters instead of inline logic
- Add comprehensive test coverage for all formatter classes
- All existing tests pass; no behavioral changes
2026-01-18 22:17:44 +01:00
落月
2c16b3e084
[Server] Use getDescription to get all descriptions. (#188)
* Remove `getSummary` method and update descriptions in snapshots and code

* Add changelog entry

---------

Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
2026-01-11 22:08:05 +01:00
落月
1de4ea933f
Rename schema to resource in Capability and related classes (#217) 2026-01-11 21:52:04 +01:00
Tobias Nyholm
ed205ef793
Use SchemaValidator to validate tool input (#203)
* Use SchemaValidator to validate tool input

* add test

* add changelog

* fix cs

* Improve error message

* fix tests

* fix tests

* fix baseline

* update snapshot files

* Remove BC compat while switching to v0.3.0

---------

Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
2026-01-11 21:46:53 +01:00
Sule-Balogun Olanrewaju
c0938a19bd
feat: Add output schema support to MCP tools (#153) 2026-01-11 21:14:48 +01:00
Kyrian Obikwelu
4c3e5e61c7
fix: use Docker PHP-FPM to support sampling in conformance tests (#219) 2026-01-02 15:59:56 +01:00
Tobias Nyholm
abd0ddf13d
Remove ability to use parameter name _session and _request (#206)
* Remove ability to use parameter name _session and _request

These are reserved for internal use. This will fix https://github.com/modelcontextprotocol/php-sdk/issues/168

* fix cs

* add changelog

* add test
2025-12-27 23:16:44 +01:00
Tobias Nyholm
6dac6f3b4a
Move examples to server directory (#198)
* move examples to server directory

This will prepare for the client implementation in https://github.com/modelcontextprotocol/php-sdk/pull/192

* fix move bootstrap too
2025-12-27 15:39:05 +01:00
Tobias Nyholm
a1e0f61b6b
Add RequestContext and logging (#176)
* Implemented MCP logging specification with auto-injection

* Add RequestContext

* fix tests and style

* Better deprecation

* fix: minor

* Remove ClientAwareInterface

* fix cs

* fix docs

---------

Co-authored-by: Adam Jamiu <jamiuadam120@gmail.com>
2025-12-16 00:12:02 +01:00
落月
280e8b62be
Decouple Server from TransportInterface for reusability (#160) 2025-11-30 11:21:21 +01:00
Christopher Hertel
7cd281d0c7
Rework registry to combine provider and registry interface, move capabilities out and enable Registry injection in Builder (#150) 2025-11-20 19:36:57 +01:00
Christopher Hertel
056c7b6103
[Server] Add support for icons on explicit builder registration and attributes (#142)
* Add support for icons on explicit builder registration and attributes

* Update docs/server-builder.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-13 22:39:18 +01:00
Christopher Hertel
7a8fbe9b20
Add tool name validation for SEP-986 (#140) 2025-11-13 21:42:30 +01:00
Christopher Hertel
5804ba9773
Add support for icons and website url (#141) 2025-11-09 14:53:36 +01:00
ineersa
09596c0382
Ability to set custom protocol version (#117) 2025-11-08 00:37:01 +01:00
Christopher Hertel
ff26b4ff61
refactor: transport agnostic examples (#131) 2025-11-02 18:07:43 +01:00
Christopher Hertel
fb3c1e65a6
Enable servers to send sampling messages to clients (#101) 2025-11-01 09:02:24 +01:00
Kyrian Obikwelu
757b959bfd
[Server] Feat: Add comprehensive HTTP inspector tests with improved framework (#125)
* feat: add comprehensive HTTP inspector tests and improve test framework

* chore: remove debug flag from server configuration
2025-10-30 17:47:53 +01:00
Kyrian Obikwelu
ca18caf29d
[Server] Fix: standardize error handling across handlers with MCP specificatio… (#124)
* fix: standardize error handling across handlers with MCP specification compliance

* Update mcp-elements.md

Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>

* docs: clarify error handling behavior for all element types

* docs: remove unnecessary whitespace in mcp-elements.md

* fix: simplify exception signatures to accept simple messages

* refactor: use specific exceptions in examples for better error handling

* feat: throw exceptions from reference provider instead of returning null

---------

Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
2025-10-30 17:30:58 +01:00
Christopher Hertel
7190bee153
Add more inspector tests for functionality tests of STDIO examples (#115) 2025-10-27 01:09:25 +01:00
OK Xaas
42b5261612
fix: because the cached discoveryState does not use ->setDiscoveryState(), it is found that the discoveryState cannot be used (#120)
Co-authored-by: X2NX <x2nx@qq.com>
2025-10-26 23:25:09 +01:00
Kyrian Obikwelu
f1b471a219
[Server] Add Bidirectional Client Communication Support (#109)
* feat(server): add bidirectional client communication support

* fix(server): use correct session ID string conversion method

* fix: clean up docblocks for request handler methods in Builder

* fix: merge artifacts
2025-10-26 22:48:17 +01:00
ineersa
d347c84472
StructuredContent call tool result, added ability to return error from tool (#93) 2025-10-24 21:18:42 +02:00
Kyrian Obikwelu
54a5d1495c
[Server] Refactor protocol pipeline to separate request and notification handling (#106) 2025-10-12 13:53:41 +01:00
Christopher Hertel
9ff6516e5b
Add happy cases for functional tests of example 1 (#91) 2025-10-12 13:52:58 +01:00
ineersa
709a815cde
Add possibility to set custom ServerCapabilities. (#95) 2025-10-11 02:37:58 +02:00
Kyrian Obikwelu
2dbd411194
[Server] Simplify server entrypoint with run-based transport lifecycle (#103)
* feat: replace connect/listen flow with run lifecycle

* feat(transport): add phpstan generics for typed transport returns

* refactor: standardize variable naming for MCP server instances in transport handling

* test: remove unnecessary phpstan-ignore annotation in DocBlockTestFixture
2025-10-10 18:52:06 +01:00
Kyrian Obikwelu
fcf605d5d7
[Server] Simplify server extensibility with pluggable method handlers (#100)
* refactor: use a custom method handler registration system

* refactor: remove redundant Completer and CompleterInterface

* docs: update server-builder documentation to reflect custom method handler changes
2025-10-08 00:25:06 +02:00
Kyrian Obikwelu
4b91567dbd
feat: add completion/complete handler, centralize provider logic, and move completion capability (#97) 2025-10-07 10:34:50 +01:00
Christopher Hertel
f0807f149e
Avoid broken inspector cli version by pinning (#98) 2025-10-07 00:42:26 +02:00
Christopher Hertel
345b94dfbb
Rename example folders (#87) 2025-10-04 19:45:40 +02:00
Christopher Hertel
cecfa0c3c6
Add request handler for resource templates (#89) 2025-10-04 19:43:41 +02:00
Kyrian Obikwelu
41486bfaa4
[Server] Reorganize server handlers and transport structure for better organization (#86)
* refactor: reorganize server handlers and transport structure

* feat: move the test files to corresponding directories

* fix: linter issues

* fix: correct PHPDoc formatting and streamline handler imports

* refactor: update import statement for ServerBuilder to Builder
2025-09-29 00:58:04 +02:00