feat(mcp-adapters): Add resource management methods and structured content support #9515
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.
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
listResources()method to list available resources from MCP serverslistResourceTemplates()method to list resource templates with parameterized URIsreadResource()method to read resource content by URIMCPResource,MCPResourceTemplate,MCPResourceContentStructured Content and Metadata Support
structuredContentfrom MCP tool results_metafrom MCP tool resultsType Safety
ExtendedContentandExtendedArtifacttypes to properly handle structured content and metadataanytype assertions in favor of explicit type definitionsTesting
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