How do I review OpenAI Agents SDK local MCP connection lifetime?
A locally controlled SDK connection must stay valid while its discovered tools are used. Trace that lifetime before debugging apparent remote failures, so premature cleanup is not confused with expired Montage authorization and retained tool objects do not outlive the client that owns them. The important execution point is where the application actually invokes the discovered tool, not merely where initialization succeeds. Use the installed local lifecycle and preserve separate observations for remote permission failure and premature cleanup.
Help me review OpenAI Agents SDK local MCP connection lifetime. Find where MCPServerStreamableHttp is created, opened and released in the existing application. Record the real workspace response and whether documented cleanup completed. No writes.Map construction and cleanup
Find where MCPServerStreamableHttp is created, opened and released in the existing application. Identify any tool references retained after the documented connection lifetime ends. The resource map should show where direct tool execution settles relative to connection cleanup rather than relying on a successful early metadata fetch.
Follow version-matched lifecycle
Consult the installed SDK’s local connection documentation instead of copying HostedMCPTool setup. Hosted execution does not repair a prematurely closed local connection and changes the execution boundary. MCPServerStreamableHttp lifecycle evidence applies to application-owned execution; replacing it with hosted setup changes the test instead of explaining the local resource bug.
Keep authorization user-scoped
Retain approved Montage access only for the intended caller while the connection is active. Do not solve lifecycle bugs by turning a user-owned session into an unbounded shared client. A reusable global connection should not silently inherit one user’s grant for all requests merely to avoid a closed-session exception in later code.
Exercise the actual execution point
Call signals_status directly within the intended open lifetime, not only during early discovery. Preserve transport closure and server permission errors as separate observations for diagnosis. Inspect actual closure errors and permission responses independently so the remedy addresses resource timing rather than indiscriminately resetting an account grant.
Verify cleanup and scope
Record the real workspace response and whether documented cleanup completed. A direct lifecycle check does not require paid inference and cannot establish the correctness of later hosted execution. The diagnostic outcome should distinguish completed read, failed cleanup and untested hosted execution as separate facts rather than one blanket integration status.
Keep the boundaries clear.
- A reusable global connection should not silently inherit one user’s grant for all requests merely to avoid a closed-session exception in later code.
- The diagnostic outcome should distinguish completed read, failed cleanup and untested hosted execution as separate facts rather than one blanket integration status.
Start with a read-only check: ask your agent to report actual source coverage before collecting records or exporting an audience.
Primary references
Documentation reviewed 2026-11-15. Product capabilities, client availability and plans can change. Third-party marks identify their products, not an affiliation.