Commit graph

72 commits

Author SHA1 Message Date
Christopher Hertel
67cc641247
fix(server): consistent arg name in session store impl (#127) 2025-10-31 21:02:54 +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
8885d29a4e
fix(server): add completion handler to builder (#126) 2025-10-30 11:49:13 +01:00
Kyrian Obikwelu
55f860808c
fix: extract and pass URI template variables to resource handlers (#123) 2025-10-27 22:20:48 +01:00
落月
f41ea86608
feat(session): implement PSR-16 cache based session storage (#114) 2025-10-27 08:40:26 +01:00
Christopher Hertel
7190bee153
Add more inspector tests for functionality tests of STDIO examples (#115) 2025-10-27 01:09:25 +01:00
Kyrian Obikwelu
48a19b93a7
[Server] Make CORS headers configurable in StreamableHttpTransport (#118)
* feat: make CORS headers configurable in StreamableHttpTransport

* docs: add CORS configuration documentation for HTTP transport

* refactor: streamline request creation and transport initialization in HTTP client example
2025-10-26 23:58:26 +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
Kyrian Obikwelu
0963d243bc
feat: add PSR-17 factory auto-discovery to HTTP transport (#119) 2025-10-26 22:06:10 +01:00
Christopher Hertel
e5a4cb5906
Actually use cache across example runs (#116) 2025-10-26 21:49:45 +01:00
Antoine Bluchet
e4a82f7474
refactor: registry loader (#111) 2025-10-24 21:43:16 +02:00
ineersa
d347c84472
StructuredContent call tool result, added ability to return error from tool (#93) 2025-10-24 21:18:42 +02:00
Antoine Bluchet
6100ffcf3f
Missing Mcp-Protocol-Version to access control (#110) 2025-10-20 22:41:24 +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
Adebayo120
4486776e7d
[Server] Remove redundant Builder.setServerCapabilities method (#107) 2025-10-12 13:51:21 +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
Christopher Hertel
e2243bc2d9
[Server] Remove dead resource template handler code (#102) 2025-10-10 18:38:42 +01:00
ineersa
415f8dd360
Fixed Discoverer file processing for PHAR (#94) 2025-10-08 03:56:10 +02: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
Christopher Hertel
e94fd82061
docs: add more about building servers and updating front readme (#81)
* docs: add more about building servers and updating front readme

* Overhaul documentation structure and content

* fix: remove redundant emoji on docs

* Remove composer install --dev hint

* Add linebreak to make it readable in IDE

* rebase after example renaming

---------

Co-authored-by: Kyrian Obikwelu <koshnawaza@gmail.com>
2025-10-07 23:42:02 +02:00
Christopher Hertel
cbd1b298e9
Fix missing instructions from builder to handler (#90) 2025-10-07 23:32:51 +02:00
Christopher Hertel
d06b57d285
Address open PHPStan issues from baseline (#92) 2025-10-07 23:16:47 +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
Kyrian Obikwelu
3dcd2f717a
refactor: rename ServerBuilder to Builder (#85)
Remove redundant "Server" prefix since class is already in Server namespace.
2025-09-28 17:59:48 +01:00
Kyrian Obikwelu
38441b8dc7
refactor: rename Server::make() to Server::builder() (#84) 2025-09-28 17:51:44 +01:00
Sule-Balogun Olanrewaju
095ea2af50
Address issue with pagination limit builder class class (#83) 2025-09-27 13:43:40 +02:00
Christopher Hertel
3ec4cf612a
Split testsuite for unit and inspector based tests (#82) 2025-09-25 22:27:41 +01:00
xentixar
7d599f4f64
refactor: integrate cache parameter into setDiscovery() method (#80)
* refactor: integrate cache parameter into setDiscovery() method

- Add cache as 4th parameter to setDiscovery()
- Rename $cache to $discoveryCache for clarity
- Remove separate setCache() method
- Update example to use new API

* docs: update discovery caching documentation to use new API

- Update examples to use cache parameter in setDiscovery() method
- Remove references to separate setCache() method calls
2025-09-25 16:41:11 +02:00
Christopher Hertel
e46b7c139d
Support for Symfony 8.0 (#79) 2025-09-25 08:53:09 +02:00
Christopher Hertel
8defd9b17f
Fix & clean up examples (#78) 2025-09-24 21:50:06 +02:00
Kyrian Obikwelu
32b8b2ea61
[Server] Fix: ensure JSON-RPC error responses include message IDs (#77)
* fix: ensure JSON-RPC error responses include message IDs

* fix: replace method_exists with instanceof for message ID extraction
2025-09-24 21:45:50 +02:00
Sule-Balogun Olanrewaju
325b4aaf9c
Add support for pagination on list requests (#55)
10 - Added the list resources handler with test class

10 - Update the ListPromptsHandler to use annotations

10 - Add the list resource handler, and it's test as well

10 - Added the registry logic

10 - Added the list tools handler logic

10 - Fix all php-cs-fixer related issues

10 - Resolved phpstan issues for ListPromptsHandlerTest

10 - Resolved phpstan issues for ListToolsHandlerTest

10 - Resolved phpstan issues for ListResourcesHandlerTest

10 - Resolved phpstan issues in registry class

10 - Resolved phpstan issues for the handler class

10 - Resolved php cs fixer issues

10 - Resolved all phpstan issues by generating the baseline again

10 - Remove the two loop operation and use foreach for optimization

10 - Removed unused code and resolved namespace

10 - Add signatures to interface and registry

10 - Add updated phpstan rule set

10 - Arranged according to property type

10 - Introduce reference page DTO, fix all failing test

10 - Resolve cs-fixer issues

10 - Resolve phpstan issues

10 - Resolve php cs fixer issues

10 - Created a reference directory for the Page DTO

10 - Remove manual loop for clean code readability

Co-authored-by: larry.sulebalogun <larry.sulebalogun@tillo.io>
2025-09-24 21:44:32 +02:00
xentixar
4db831778b
[Server] Implement discovery caching for improved performance (#39)
* feat: implement discovery caching with state-based approach

- Add DiscoveryState class to encapsulate discovered MCP capabilities
- Add exportDiscoveryState and importDiscoveryState methods to Registry
- Modify Discoverer to return DiscoveryState instead of void
- Create CachedDiscoverer decorator for caching discovery results
- Add importDiscoveryState method to ReferenceRegistryInterface
- Update ServerBuilder to use caching with withCache() method
- Update tests to work with new state-based approach
- Add example demonstrating cached discovery functionality
- Add PSR-16 SimpleCache and Symfony Cache dependencies

* docs: add comprehensive discovery caching documentation

- Add detailed documentation explaining discovery caching architecture
- Include usage examples for different cache implementations
- Document performance benefits and best practices
- Add troubleshooting guide and migration instructions
- Include complete API reference for all caching components
- Fix PHPStan issues by regenerating baseline
- Apply PHP CS Fixer formatting to all new files

* refactor: address reviewer feedback and clean up discovery caching

- Make DiscoveryState class final
- Cache DiscoveryState objects directly instead of arrays (no serialization needed)
- Rename exportDiscoveryState/importDiscoveryState to getDiscoveryState/setDiscoveryState
- Add getDiscoveryState method to ReferenceRegistryInterface
- Remove TTL parameter from CachedDiscoverer (no expiration by default)
- Remove unused methods from DiscoveryState (toArray, fromArray, merge)
- Simplify ServerBuilder to handle decoration internally
- Make Discoverer.applyDiscoveryState() internal (no longer public API)
- Simplify documentation to focus on user perspective
- Remove unnecessary development comments
- Update all tests to work with new architecture
- All tests pass, PHPStan clean, code formatting applied

* refactor: clean up comments and formatting in server.php example

* refactor: improve code formatting and consistency in discovery classes and example server

* Fix method names in cached discovery example

- Change withServerInfo() to setServerInfo()
- Change withDiscovery() to setDiscovery()
- Change withLogger() to setLogger()
- Fixes PHPStan static analysis errors

* refactor: update method names in ServerBuilder for consistency

- Change withCache() to setCache() in ServerBuilder
- Update example and documentation to reflect method name changes
- Ensure consistency across caching implementation in examples and documentation

* refactor: reorganize examples and fix PHPStan baseline

- Move cached discovery example from examples/10 to examples/09
- Update composer.json autoload-dev namespace mapping
- Fix PHPStan baseline by removing invalid entries for non-existent files
- Update server.php to follow proper example pattern with logging and lifecycle

* fix: correct formatting in server.php
2025-09-24 20:54:27 +02:00
Kyrian Obikwelu
9e168832ca
refactor: remove dead code and obsolete examples (#76)
- Remove ToolChain, ResourceChain, PromptChain classes
- Remove Collection/Identifier/Metadata interfaces (only used by old Chains)
- Remove ToolCollectionInterface (unused)
- Delete obsolete examples 09-standalone-cli and 10-simple-http-transport
- Fix STDERR handling in bootstrap.php for web environments
- Clean up CHANGELOG.md
2025-09-21 20:23:59 +02:00
Kyrian Obikwelu
719262b15d
feat(server): Rework transport architecture and add StreamableHttpTransport (#49)
* feat(server): Rework transport architecture and add StreamableHttpTransport

- `Server::connect()` no longer contains a processing loop.
- `TransportInterface` is updated with `setMessageHandler()` and `listen()`.
- `StdioTransport` is updated to implement the new interface.
- A new, minimal `StreamableHttpTransport` is added for stateless HTTP.

* refactor(server): use  event-driven message handling

* feat(server): Introduce a formal session management system

* fix: ensure session elements are preserved when building server (regression from #46)

* refactor: consolidate HTTP example to use shared dependencies

* feat(server): Enhance message handling with session support

- Updated `TransportInterface` to use `onMessage` for handling incoming messages with session IDs.
- Refactored `Server`, `Handler`, and transport classes to accommodate session management using `Uuid`.
- Introduced methods for creating sessions with auto-generated and specific UUIDs in `SessionFactory` and `SessionFactoryInterface`.

* feat(server): Integrate session management in message handling

- Added session support to the `Server` and `Handler` classes, allowing for session data to be managed during message processing.
- Updated `TransportInterface` to include session context in the `send` method.
- Refactored various request handlers to utilize session information, ensuring proper session handling for incoming requests.
- Introduced a file-based session store for persistent session data management

* feat: Update session builder method to use set* instead of with*

* feat: Fix test compatibility with new session management architecture

* chore: apply code style fixes

* fix: remove deprecated SSE transport and resolve PHPStan issues
2025-09-21 12:12:40 +02:00
Christopher Hertel
b1e54f1f86
Switch to set* and add* on ServerBuilder instead of with* (#71) 2025-09-15 08:30:41 +02:00
Pavel Buchnev
99bf56eef8
Registry Architecture Refactoring - Enhanced Separation of Concerns (#46)
* refactor: Separate Registry concerns following SOLID principles [WIP]

- Extract ReferenceProvider and ReferenceRegistryInterface interfaces
- Create DefaultToolExecutor with ReferenceHandlerInterface
- Remove execution responsibility from Registry class
- Enable custom handler and executor implementations

* refactor: implement SOLID principles with separated execution concerns

* Create DefaultResourceReader, DefaultPromptGetter
* Refactor JsonRpc Handler and RequestHandlers to use dedicated executors
* Update ServerBuilder to support custom executors via dependency injection

* chore: remove extra comments

* feat: introduce DispatchableRegistry for enhanced tool and resource management

* refactor: use proper interfaces

* refactor: implement HandlerInterface for improved abstraction and flexibility

* test: add unit tests for DispatchableRegistry and Registry classes

* refactor: cover with unit tests Resource reader, Prompt getter and Tool executor

* cs fix

* phpstan fix

* test: add unit tests for CallToolHandler, GetPromptHandler, PingHandler, and ReadResourceHandler

* refactor: revert Handler

* chore: remove style guide for tests

* refactor: remove "Default" prefix from classes

* refactor: remove DispatchableRegistry

* refactor: use package specific exception classes

* refactor: remove DispatchableRegistry

* refactor: add logger support to PromptGetter and ResourceReader classes

* Update src/Capability/Prompt/PromptGetter.php

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

* refactor: Use FQN for Resource class to avoid cs-fixer misinterpreting it as `resource`

* refactor: rename ToolExecutor to ToolCaller and related classes for clarity and consistency

* refactor: add missed docblock

* refactor: rename ToolExecutor references to ToolCaller

* refactor: rename ToolCallerTest property and variable references

* cs fix

* ignore some phpstan errors

---------

Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
2025-09-14 20:44:18 +02:00
Aleksei Gagarin
bfc3b82d19
Add Makefile to export-ignore in .gitattributes (#56)
* Add Makefile to export-ignore in .gitattributes

* Update .gitattributes to export-ignore all phpstan configuration files
2025-09-09 22:32:02 +02:00
Igor Markin
20e789d402
Fix return type in abstract methods from self to static (#53)
* Change return type of abstract request methods

* Change return type of `fromParams` method to `static` in request classes

(cherry picked from commit 94799ab66ff60d4b2305aadb6b73aaa4c805221e)

* Make request classes final and update `getParams` return types for improved type safety

(cherry picked from commit d6be496f89cc0e6d30f519792d0dc902685c4178)
2025-09-09 18:22:29 +02:00
Oskar Stark
4b667327e7
Remove --no-scripts option from composer install (#30) 2025-09-07 01:47:53 +02:00
Adebayo120
f457802371
Updated README.md to clarify grammar in "Important" section (#41) 2025-09-06 22:34:51 +02:00
Sapayth Hossain
952cd2420b
Update README for clarity and consistency (#38)
Improved capitalization and wording in the roadmap and credits sections for better readability and consistency.
2025-09-06 21:21:32 +02:00