Skip to content

Commit 90a349f

Browse files
committed
Update docs
1 parent 204701c commit 90a349f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

docs/mcp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ agent = Agent(
169169

170170
## Caching
171171

172-
Every time an Agent runs, it calls `list_tools()` on the MCP server. This can be a latency hit, especially if the server is a remote server. To automatically cache the list of tools, you can pass `cache_tools_list=True` to [`MCPServerStdio`][agents.mcp.server.MCPServerStdio], [`MCPServerSse`][agents.mcp.server.MCPServerSse], and [`MCPServerStreamableHttp`][agents.mcp.server.MCPServerStreamableHttp]. You should only do this if you're certain the tool list will not change.
172+
Every time an Agent runs, it calls `list_tools()` and `list_prompts()` on the MCP server. This can be a latency hit, especially if the server is a remote server. To automatically cache the list of tools and prompts, you can pass `cache_tools_list=True` and `cache_prompts_list=True` to [`MCPServerStdio`][agents.mcp.server.MCPServerStdio], [`MCPServerSse`][agents.mcp.server.MCPServerSse], and [`MCPServerStreamableHttp`][agents.mcp.server.MCPServerStreamableHttp]. You should only do this if you're certain the tools and the prompts lists will not change.
173173

174-
If you want to invalidate the cache, you can call `invalidate_tools_cache()` on the servers.
174+
If you want to invalidate the cache, you can call `invalidate_tools_cache()` and `invalidate_prompts_cache()` on the servers.
175175

176176
## End-to-end examples
177177

examples/mcp/caching/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@
1212
async def run(mcp_server: MCPServerStreamableHttp):
1313
print(f"Cached tools before invoking tool_list")
1414
print(mcp_server._tools_list)
15-
await mcp_server.list_tools()
15+
1616
print(f"Cached tools names after invoking list_tools")
17+
await mcp_server.list_tools()
1718
cached_tools_list = mcp_server._tools_list
1819
for tool in cached_tools_list:
1920
print(f"name: {tool.name}")
2021

2122
print(f"Cached prompts before invoking list_prompts")
2223
print(mcp_server._prompts_list)
23-
await mcp_server.list_prompts()
24+
2425
print(f"\nCached prompts after invoking list_prompts")
26+
await mcp_server.list_prompts()
2527
cached_prompts_list = mcp_server._prompts_list
2628
for prompt in cached_prompts_list.prompts:
2729
print(f"name: {prompt.name}")

0 commit comments

Comments
 (0)