Skip to content

feat: add ResourceLink content type (MCP spec 2025-06-18)#200

Draft
rupeshstha wants to merge 10 commits intolaravel:mainfrom
rupeshstha:feature/resource-link
Draft

feat: add ResourceLink content type (MCP spec 2025-06-18)#200
rupeshstha wants to merge 10 commits intolaravel:mainfrom
rupeshstha:feature/resource-link

Conversation

@rupeshstha
Copy link
Copy Markdown

@rupeshstha rupeshstha commented Apr 15, 2026

What

Adds the resource_link content type from the MCP specification (2025-06-18).

Closes #199

Why

resource_link is the only first-class content type in the spec not yet implemented. Unlike an embedded resource (which inlines content), a resource_link returns a URI pointer, the client fetches or subscribes independently. This matters for large payloads and live subscriptions.

Changes

  • New src/Server/Content/ResourceLink.php — implements the Content contract with HasMeta, constructor accepts $uri (required) plus optional $name, $mimeType, $description; null fields are omitted from output
  • Modified src/Response.php — adds Response::resourceLink() static factory, consistent with text(), image(), audio()
  • New tests/Unit/Content/ResourceLinkTest.php 12 tests, 40 assertions covering all fields, null omission, _meta, __toString(), and delegation to toTool()/toPrompt()/toResource()

Modified: src/Response.php

  • Imported use 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.php

  • 12 tests, 40 assertions
  • Covers: all optional fields, null field omission, support of the meta, delegation of toTool() / toPrompt() / toResource(), support of __toString().

Usage

use Laravel\Mcp\Response;

// In a Tool handler
public function handle(): array
{
    return [
        Response::resourceLink(
            uri: 'file:///data/report.json',
            name: 'Monthly Report',
            mimeType: 'application/json',
            description: 'Generated sales report',
        ),
    ];
}

Result (spec-compliant):

{
  "type": "resource_link",
  "uri": "file:///data/report.json",
  "name": "Monthly Report",
  "mimeType": "application/json",
  "description": "Generated sales report."
}

rupeshstha and others added 10 commits April 15, 2026 16:25
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.
@taylorotwell taylorotwell marked this pull request as draft April 16, 2026 13:59
@pushpak1300 pushpak1300 self-assigned this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Support for resource_link Content Type (MCP spec 2025-06-18)

2 participants