-
Notifications
You must be signed in to change notification settings - Fork 178
Description
Describe the bug
invalidateToolsCache()
is advertised in the docs and present in the Node/Browser shim classes, but it is not exposed by the public wrapper classes MCPServerStdio
and MCPServerStreamableHttp
. Calling the method on an instance created from @openai/agents
therefore throws:
TypeError: mcpServer.invalidateToolsCache is not a function
The only workaround is to use the global invalidateServerToolsCache(name)
helper and recreate the server object, or disable caching entirely.
Debug information
- Agents SDK version:
@openai/[email protected]
,@openai/[email protected]
,@openai/[email protected]
,@openai/[email protected]
- Runtime environment: Node.js 22.13.1 on Linux
Repro steps
Run the following minimal script:
import { MCPServerStreamableHttp } from "@openai/agents";
const mcpServer = new MCPServerStreamableHttp({
url: "http://localhost:3000/mcp",
name: "Local MCP",
cacheToolsList: true,
});
await mcpServer.connect();
await mcpServer.invalidateToolsCache(); // ← throws TypeError
Expected output: no error, cache cleared.
Actual output: TypeError: mcpServer.invalidateToolsCache is not a function
.
Expected behavior
invalidateToolsCache()
should be callable on any MCPServerStdio
/MCPServerStreamableHttp
instance and clear the per‑instance tools cache so the next run performs a fresh tools/list
request—mirroring the behaviour of the global invalidateServerToolsCache(name)
helper.
Additional context
Layer | File | Method present? |
---|---|---|
Node shim | packages/agents-core/src/shims/mcp-server/node.ts |
yes |
Browser shim | packages/agents-core/src/shims/mcp-server/browser.ts |
yes |
Public wrapper | packages/agents-core/src/mcp.ts |
missing |
Docs/examples assume the instance method exists; Python SDK still exposes invalidate_tools_cache()
at the instance level, so parity is expected.
Proposed fix
Add a passthrough method in the public wrappers:
invalidateToolsCache(): void {
this.underlying.invalidateToolsCache();
this._cachedTools = undefined; // optional: clear local copy
}
Happy to submit a PR if helpful, thanks for maintaining the SDK!