wordpress/php-mcp-schema
PHP implementation of the Model Context Protocol (MCP) schema, offering lightweight, strictly typed classes, enums, and helpers for building MCP servers and clients. Use it to connect WordPress and PHP applications with MCP-compatible AI tools, agents, and services.
Architecture fit
2025-11-25, 2026-07-28). It is framework-agnostic PHP — there is no Laravel service provider, facade, or config file. In a Laravel app it sits in the library layer, called from the controllers/jobs that implement MCP transport and tool dispatch.Schemas::create()->forVersion($revision) entry point forces explicit revision selection, which maps well onto a JSON-RPC middleware that resolves the negotiated revision per request. Immutable records with fromArray() / fromValue() / fromJson() are a clean fit for request-payload hydration.Record for protocol objects, Contract for unions, Value for enum-like constants) give an obvious mapping to our own domain boundaries and make the anti-corruption layer thin.Integration feasibility
Schema instance per revision in a service provider is a few lines of code. No adapter layer required.fromArray() takes validated request arrays, fromJson() takes raw Http client bodies, fromValue() handles scalar unions.\InvalidArgumentException. Laravel's default handler renders that as a 500, so exception-to-JSON-RPC error code mapping (parse error, invalid params, method not found) must be written by us — it is not provided.Technical risk
Client/Common/Server namespaces, DTO constructors and factories, class-based enums, validation flags, and toArray() variants — with no compatibility aliases. Any existing call site is a rewrite, not a bump.UnsupportedRevisionException. Client/version drift becomes a runtime error path we must design for, not an edge case.toArray() variants; the replacement path is not stated in the notes, so ad-hoc serializers are a real divergence risk.Key questions
Client/Common/Server namespaces?toArray() for outbound payload construction?Stack fit
Schema per supported revision, memoized behind a small McpSchemaManager exposing forVersion().fromArray() / fromJson().Migration path
toArray() call must change. Budget it as a feature-sized task, not a dependency bump.Record/Contract/Value.Compatibility
ElicitResult.content, JSONValue on 2026-07-28, NumberSchema bounds on 2025-11-25). Confirm downstream consumers tolerate floats where they previously saw only ints.Sequencing
composer.json and enable dependabot-style review, not auto-merge, for this package.Maintenance
skill/ reference scripts and @since protocol-history annotations moves discovery burden onto us: internal documentation for revision semantics and namespace layout becomes our responsibility.Support
\InvalidArgumentException produces 500s for what are client-caused malformed payloads. Fixing this early avoids a long tail of indistinguishable support tickets.UnsupportedRevisionException as a distinct, tagged metric — it is the primary signal of client/version drift and should not be buried in generic error rates.Scaling
memory_limit deliberately and alert on headroom rather than relying on defaults.Schema instance and profile allocation churn.Failure modes
toArray() variants invites hand-rolled serializers that drift from the schema; standardize one outbound path.Ramp-up
fromArray() / fromJson() within a day; the real curve is revision semantics and union-resolution rules, not the API surface.How can I help you explore Laravel packages today?