Skip to content

Feat/prompts caching #1087

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 10 commits into
base: main
Choose a base branch
from
Open

Conversation

amri369
Copy link
Contributor

@amri369 amri369 commented Jul 12, 2025

Summary

Integrate prompts list caching in MCP Servers. This allows agents to fetch prompts from local memory when cache_prompts_list is set to True. Otherwise, every time an agent runs, it calls list_prompts() on the MCP Server.

Key changes:

  • Updated the implementation of list_prompts in _MCPServerWithClientSession to integrate caching using the same design pattern as caching integration in list_tools.
  • Created example that uses caching with working demonstration.
  • Updated documentation with caching setting.
  • Renamed test test_server_caching_works to test_server_caching_prompts_works in tests/mcp/test_caching.py.

Note: This PR does not implement caching in get_prompt which can be useful in certain situations.

Test plan

Unit tests: Added 1 unit test in tests/mcp/test_caching.py to cover prompts list caching.

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

Checks

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

@amri369 amri369 marked this pull request as draft July 12, 2025 09:01
@amri369 amri369 marked this pull request as ready for review July 12, 2025 09:46
@seratch seratch added enhancement New feature or request feature:mcp labels Jul 14, 2025
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.

2 participants