Skip to content

Feat/support mcp resources #1042

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

Open
wants to merge 54 commits into
base: main
Choose a base branch
from

Conversation

amri369
Copy link
Contributor

@amri369 amri369 commented Jul 8, 2025

Summary

Integrate MCP Resources. This allows MCP servers to expose data and content that can be read by clients and used as context for LLM interactions.

Key changes:

  • Added three abstract methods to the to the base class MCPServer: list_resources, list_resource_templates and read_resource
  • Implemented the abstract methods in the base class _MCPServerWithClientSession which is parent of classes MCPServerStdio, MCPServerSse , and MCPServerStreamableHttp.
  • Created example MCP resources server with working demonstration.
  • Updated documentation with MCP resources usage examples.

Note: This PR does not implement subscribe_resource and unsubscribe_resource methods.

Test plan

Unit tests: Added 4 comprehensive tests in tests/mcp/test_resources_server.py covering:

  • Resources listing and retrieval
  • Error handling for missing resource
  • Integration tests: Updated existing MCP test suite to handle new abstract methods

Additionally, unit test test_handoff_prompt_is_correct has been added to increase coverage.

Example verification: Created working example with MCP resources server and client
All tests pass: 527/527 tests passing after adding optional dependencies

Issue number

Partially addresses #544 (resources only)

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@amri369 amri369 marked this pull request as draft July 8, 2025 19:43
@amri369 amri369 marked this pull request as ready for review July 8, 2025 22:51
@seratch seratch added enhancement New feature or request feature:mcp labels Jul 10, 2025
@seratch seratch self-assigned this Jul 10, 2025
@seratch
Copy link
Member

seratch commented Jul 10, 2025

Thanks for sending this PR! Will check it later this week.

@artificial-aidan
Copy link

Does this actually do anything to integrate MCP resources into the agent flow? Or is it up to the implementer to retrieve resources. Seems not very useful?

Tool calls can return links to resources, it seems like it would be more useful to parse tool outputs and use the resource link to return a resource to the LLM.

https://modelcontextprotocol.io/specification/2025-06-18/server/tools#resource-links

@amri369 amri369 marked this pull request as draft July 12, 2025 06:27
@amri369 amri369 marked this pull request as ready for review July 12, 2025 06:47
@amri369
Copy link
Contributor Author

amri369 commented Jul 12, 2025

Does this actually do anything to integrate MCP resources into the agent flow? Or is it up to the implementer to retrieve resources. Seems not very useful?

Tool calls can return links to resources, it seems like it would be more useful to parse tool outputs and use the resource link to return a resource to the LLM.

https://modelcontextprotocol.io/specification/2025-06-18/server/tools#resource-links

Hey, thanks for the question!
All of the MCP-Resource helper methods live in _MCPServerWithClientSession, so any subclass that inherits from it—MCPServerStdio, MCPServerSse, or MCPServerStreamableHttp—already gets full access in run time to:

  • list_resources
  • list_resource_templates
  • read_resource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature:mcp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants