feat: add ResourceLink content type (MCP spec 2025-06-18)#200
Draft
rupeshstha wants to merge 10 commits intolaravel:mainfrom
Draft
feat: add ResourceLink content type (MCP spec 2025-06-18)#200rupeshstha wants to merge 10 commits intolaravel:mainfrom
rupeshstha wants to merge 10 commits intolaravel:mainfrom
Conversation
feat: add ResourceLink content type (MCP spec 2025-06-18)
…sponse Added a new method to create a resource link content item.
Add unit tests for ResourceLink class functionality including conversion to tool, prompt, and resource, as well as optional fields handling.
- Fix ordered_imports in ResourceLink (alphabetical by full class name) - Add explicit closure param/return types per rector rules - Fix fully_qualified_strict_types in Mcp facade docblock
…cp facade string<T> is not valid PHPDoc syntax — PHPStan cannot resolve it. The correct type for a class name string is class-string<T>, which matches the existing docblocks in Registrar.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the
resource_linkcontent type from the MCP specification (2025-06-18).Closes #199
Why
resource_linkis the only first-class content type in the spec not yet implemented. Unlike an embedded resource (which inlines content), aresource_linkreturns a URI pointer, the client fetches or subscribes independently. This matters for large payloads and live subscriptions.Changes
src/Server/Content/ResourceLink.php— implements theContentcontract withHasMeta, constructor accepts$uri(required) plus optional$name,$mimeType,$description; null fields are omitted from outputsrc/Response.php— addsResponse::resourceLink()static factory, consistent withtext(),image(),audio()tests/Unit/Content/ResourceLinkTest.php12 tests, 40 assertions covering all fields, null omission,_meta,__toString(), and delegation totoTool()/toPrompt()/toResource()Modified:
src/Response.phpuse Laravel\Mcp\Server\Content\ResourceLink;import.Add ResourceLink Likewise Added
Response::resourceLink()static factory method - same as existing text, image, audio methods.New:
tests/Unit/Content/ResourceLinkTest.phptoTool()/toPrompt()/toResource(), support of__toString().Usage
Result (spec-compliant):
{ "type": "resource_link", "uri": "file:///data/report.json", "name": "Monthly Report", "mimeType": "application/json", "description": "Generated sales report." }