Hey y'all,
Context
I'm building an ai agent that needs read-only but long-lived access to user's Stripe, database, logs platforms. The specific type of the database or the log platform is not known in advance. I want the Agent to be able to determine & connect to any database / platform via a pre-determined connection methods - MCP, API token, etc.
After one-time connection / configuraion, agent then needs to be able to execute dispute management workflows some time in the future over the period of time the user is using the service. This means agent can wake up to do work 1 day, 7 days or even a month after initial configuration.
Problem
- MCPs are great but tokens are short-lived -> I am building this on top of Cloudflare Agent SDK, which have great support for MCPs overall BUT the access tokens are short-lived. They expire much too soon. I do not want a workflow to fail because agent no longer has access to a resource.
What I am thinking [NEED FEEDBACK]
- Either I have to implement a token refresh mechanism on my side that periodically refreshes MCP access tokens before they expire OR
- Allow agents to connect to a resource via a long-lived token -> for example ask for a db connection string with read-only access when connecting to a db, instead of an MCP server OR
- Ask users to provide a long-lived API token and then
- Agent uses this API token with MCPs -> but not all MCP servers support API tokens as auth method. Some / most use oauth these days OR
- Agent uses this API token to hit the service API endpoint
Is there anything I am missing? How are you guys solving for a long-lived agent access to a resource?