Skip to content

Conversation

@ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Jun 15, 2025

Implements support for ResourceLinks
Closes #618

What are ResourceLinks?

ResourceLinks allow tools to return references to resources without embedding their full content. This is essential for performance when dealing with large files or many resources - clients can then selectively read only the resources they need.

Implementation

  • Added ResourceLinkSchema type that extends ResourceSchema with type: "resource_link"
  • Created ContentBlockSchema union type that includes all content types (text, image, audio, resource_link, resource)
  • Updated PromptMessageSchema and CallToolResultSchema to use the new ContentBlockSchema
  • Added type exports for ResourceLink and ContentBlock

Example Usage

  // Tool returning ResourceLinks
  server.registerTool('list-files', {
    inputSchema: { pattern: z.string() }
  }, async ({ pattern }) => ({
    content: [
      { type: 'text', text: `Found files:` },
      {
        type: 'resource_link',
        uri: 'file:///project/README.md',
        name: 'README.md',
        mimeType: 'text/markdown'
      }
    ]
  }));

@ihrpr ihrpr requested a review from bhosmer-ant June 15, 2025 21:24
@ihrpr ihrpr linked an issue Jun 15, 2025 that may be closed by this pull request
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Base automatically changed from ihrpr/title to main June 16, 2025 10:55
@ihrpr ihrpr merged commit f822c12 into main Jun 16, 2025
5 checks passed
@ihrpr ihrpr deleted the ihrpr/resource-link branch June 16, 2025 11:12
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 ResourceLink to CallToolResult

3 participants