Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support for resource link #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2025
Merged

Add support for resource link #632

merged 4 commits into from
Jun 16, 2025

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
2 participants