v0.4.0
What's Changed
Added
- Attribute-based registration. Mark methods with
#[AsTool],#[AsPrompt],#[AsResource], or#[AsResourceTemplate], and a class with#[AsServer], then register the object viaServerBuilder::register(object ...$sources). A tool'sinputSchemaand a prompt'sargumentsare inferred from the method signature and@paramdocblocks (overridable per parameter with#[InputSchema]). AServerContextparameter is injected, and a plain return value (string, content block, or schema object) is adapted to the matching result. #[AsServer]supplies the server identity and instructions. An explicitsetServerInfo()/setInstructions()call wins per field and the attribute fills only the gaps, regardless of call order. More than one#[AsServer]across registered sources throwsDuplicateServerMetadataException.- A variadic parameter on an
#[AsTool]method maps to an array input and is spread back into the call. The same parameter on a prompt, resource, or resource template throwsUnsupportedVariadicParameterException. ServerBuilder::register()rejects a source that carries no#[AsServer]and no attribute-marked method withMissingDiscoveryAttributeException, catching typo'd attribute names and objects passed in by mistake.- An
#[AsTool]parameter typed as an instantiable class is expanded into an object input schema built from the class constructor, and the handler receives a constructed instance. Expansion is one level deep: a nested object, a list of objects, an interface, or an abstract class is not expanded and throws. ServerBuilder::setToolStore(),setPromptStore(),setResourceStore(), andsetResourceTemplateStore()swap in a custom store implementation, replacing the in-memory one built from the matchingaddTool()/addPrompt()/addResource()/addResourceTemplate()entries. These mirror the existingsetCompletionStore().
Changed
- Mutation testing no longer times out while covering the shutdown coroutine drain.
- Public accessors now follow a verb-first naming scheme:
Request/Notification::getMethod()(wasmethod()), the protocol exceptions'getErrorCode()(waserrorCode()),TransportInterface::getSessionId()(wassessionId()),BaseMetadata/Tool::getDisplayName()(wasdisplayName()), andInMemoryTransport::createPair()(waspair()).
Removed
- The static
Server::builder()/Client::builder()factories. Construct the builders directly withnew ServerBuilder()/new ClientBuilder().
Full Changelog: https://github.com/NexusPHP/mcp-sdk/compare/v0.3.0...v0.4.0