Problem: Passing per-user auth token to MCP tools when using a shared Agent instance (FastAPI + streamable HTTP MCP)

Hi :waving_hand:

I’m using Agno in a FastAPI project with the following setup:

  • I have a single Agent instance shared across requests (multi-user usage).

  • The Agent is exposed via a FastAPI endpoint.

  • Each user calls the endpoint with their own auth token.

  • I store this token in a per-request / per-session state.

  • I also have an MCP server developed in a separate project using FastMCP, exposed via streamable HTTP.

  • This MCP server is added to the Agent via MCP tools.

  • All MCP tools require the user token (e.g. via HTTP headers) to function correctly.

The problem

I currently have no clean way to propagate the per-user token from the FastAPI request / Agent session state into the underlying MCP tool calls.

Since the Agent is shared across users, any global configuration on the MCP tools (headers, auth, etc.) is not user-specific.

Approaches I tried

1. Create a new Agent + MCP tools per request

For each incoming request:

  • Create a new Agent instance

  • Create new MCP tools

  • Inject the user token into the MCP tool HTTP headers

Concern:
This feels inefficient and potentially expensive, since the Agent and all tools are recreated for every request.

2. Wrap each MCP method with a custom Function Tool

For each MCP method that requires a token:

  • Create a custom Function Tool

  • Manually call the MCP endpoint using httpx

  • Inject the user token into headers manually

Concern:
This defeats the purpose of using an MCP server, since I have to re-implement custom tools for every MCP method.

Question

What is the recommended / idiomatic solution in Agno for this scenario?

Specifically:

  • How should per-user context (like auth tokens) be passed to MCP tools when:

    • The Agent is a single shared instance

    • The Agent is used in a multi-user FastAPI application

  • Is there a supported pattern for:

    • Per-request MCP headers?

    • Session-scoped tool configuration?

    • Context propagation from Agent → MCP?

Any guidance, patterns, or future roadmap insight would be greatly appreciated.

Thanks :folded_hands: