Skip to content

Conversation

@siyukok
Copy link
Contributor

@siyukok siyukok commented Nov 28, 2025

Summary

This PR adds resource management capabilities and enhanced tool result parsing to the MCP adapters package, enabling better integration with MCP servers that expose resources and return structured content.

Changes

Resource Management

  • Added listResources() method to list available resources from MCP servers
  • Added listResourceTemplates() method to list resource templates with parameterized URIs
  • Added readResource() method to read resource content by URI
  • Added type definitions: MCPResource, MCPResourceTemplate, MCPResourceContent
  • All methods support filtering by server names and custom connection options

Structured Content and Metadata Support

  • Enhanced tool result parsing to extract and preserve structuredContent from MCP tool results
  • Enhanced tool result parsing to extract and preserve _meta from MCP tool results
  • Structured content and metadata are now available in tool results as special artifacts and can be attached to text content blocks

Type Safety

  • Introduced ExtendedContent and ExtendedArtifact types to properly handle structured content and metadata
  • Removed any type assertions in favor of explicit type definitions
  • Improved type safety throughout the tool result conversion process

Testing

  • Added comprehensive integration tests for resource management methods
  • Added tests for structured content and metadata parsing
  • All tests follow existing test patterns and style guidelines
  • Tests cover both HTTP and SSE transport methods

Breaking Changes

None. This is a purely additive change that maintains backward compatibility.

Example Usage

pescript
// List resources from all servers
const resources = await client.listResources();

// List resources from specific servers
const resources = await client.listResources("server1", "server2");

// Read a specific resource
const content = await client.readResource("server1", "mem://test.txt");

// Tool results now include structuredContent and _meta when available
const result = await tool.invoke({ input: "test" });
// result may contain structuredContent and meta information

… resources, and handling structured content and meta information

- Implemented `listResources` and `listResourceTemplates` methods to retrieve resources and templates from specified servers.
- Added `readResource` method for fetching resource content from a server.
- Enhanced handling of structured content and meta information in tool results.
- Updated tests to cover new resource management functionalities.
@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2025

🦋 Changeset detected

Latest commit: af5cb97

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@langchain/mcp-adapters Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Introduce resource management methods and support for structured content in mcp-adapters.
…content

Add resource management and structured content support
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

This is amazing 😍 Thank you!

@christian-bromann christian-bromann merged commit 40faca2 into langchain-ai:main Dec 12, 2025
22 checks passed
christian-bromann added a commit that referenced this pull request Dec 12, 2025
…ntent support (#9515)

Co-authored-by: Christian Bromann <git@bromann.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants