Skip to content

v0.4.0

Choose a tag to compare

@paulbalandan paulbalandan released this 26 Jul 19:53
v0.4.0
3ced46e

What's Changed

Added

  • Attribute-based registration. Mark methods with #[AsTool], #[AsPrompt], #[AsResource], or #[AsResourceTemplate], and a class with #[AsServer], then register the object via ServerBuilder::register(object ...$sources). A tool's inputSchema and a prompt's arguments are inferred from the method signature and @param docblocks (overridable per parameter with #[InputSchema]). A ServerContext parameter 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 explicit setServerInfo() / setInstructions() call wins per field and the attribute fills only the gaps, regardless of call order. More than one #[AsServer] across registered sources throws DuplicateServerMetadataException.
  • 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 throws UnsupportedVariadicParameterException.
  • ServerBuilder::register() rejects a source that carries no #[AsServer] and no attribute-marked method with MissingDiscoveryAttributeException, 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(), and setResourceTemplateStore() swap in a custom store implementation, replacing the in-memory one built from the matching addTool() / addPrompt() / addResource() / addResourceTemplate() entries. These mirror the existing setCompletionStore().

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() (was method()), the protocol exceptions' getErrorCode() (was errorCode()), TransportInterface::getSessionId() (was sessionId()), BaseMetadata/Tool::getDisplayName() (was displayName()), and InMemoryTransport::createPair() (was pair()).

Removed

  • The static Server::builder() / Client::builder() factories. Construct the builders directly with new ServerBuilder() / new ClientBuilder().

Full Changelog: https://github.com/NexusPHP/mcp-sdk/compare/v0.3.0...v0.4.0