How do MCPToolset lifecycle and user authorization fit together?
Pydantic AI's current MCPToolset wraps FastMCP and integrates with Agent toolsets. The application must manage the asynchronous lifecycle and supply an approved authorization path; attaching a toolset does not sign a user into Montage. Begin with the existing project's installed API generation, then validate the remote tool directly before giving a model any opportunity to choose a broader research operation.
https://app.montages.co/mcpWithin the authorized client's async lifetime, call signals_status directly and inspect its real workspace response. Do not run the Agent or any write tools for setup verification.Check the current toolset interface
Review the project's Pydantic AI and FastMCP versions against the official client documentation. Use MCPToolset for the documented current integration rather than mixing examples from a different API generation. Preserve existing dependencies and agent configuration. If the installed project predates this interface, record that limitation and use its matching documentation without silently changing the application stack.
Prepare a remote client for the toolset
Point the documented remote connection at https://app.montages.co/mcp over Streamable HTTP. For advanced approved OAuth, configure a FastMCP Client using its supported authentication facilities and pass it through the documented MCPToolset integration. A URL describes where to connect; it does not select a user account or complete consent on its own.
Keep credentials scoped to their user
Store approved authorization in the application's appropriate private configuration and isolate sessions for different users. Never share one user's credentials across agents serving other people or insert access material into system prompts. If no supported OAuth or approved authorization method exists in the deployed environment, fail closed and report the missing capability instead of exposing an unauthenticated toolset.
Respect the asynchronous lifetime
Enter the documented async context before discovery or tool execution and keep the client alive for the operations that need it. Attach the resulting toolset through the Agent's toolsets interface only after the preliminary check. Avoid retaining tool objects that depend on a closed connection, and distinguish lifecycle errors from server-side permission failures during diagnosis.
End with direct signals_status verification
Through the configured client, invoke Montage signals_status and inspect the actual workspace result without starting an Agent model run. If auth fails, repair the user-scoped FastMCP authorization; if the connection closes, review the async context and transport settings. Do not accept successful tool discovery as a substitute response. Close resources cleanly and keep research execution disabled until this read-only test succeeds.
Keep the boundaries clear.
- Current MCPToolset uses FastMCP; older project APIs require version-matched documentation.
- Advanced OAuth needs a configured client, not a shared user's credentials or a URL-only assumption.
- This guide documents setup and does not certify a deployment or run paid model inference.
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-13. Product capabilities, client availability and plans can change. Third-party marks identify their products, not an affiliation.