What's the recommendation to hook into a graph MCPs that may require different authorization per customer?

Hi, so - we have one instance of the graph using supervisor pattern:

   # Create the supervisor graph
    supervisor_graph = create_supervisor(
        agents=agents,
        model=model,
        tools=tools,
        prompt=prompt,
        state_schema=state_schema,
        output_mode=output_mode,
        add_handoff_back_messages=add_handoff_back_messages,
        supervisor_name=supervisor_name,
    )

This is created once, and is shared across all customers (they use the same instance of the graph)

  • to separate customers - we use return main_graph.compile(checkpointer=short_term_memory) checkpointer and attach specific config to differentiate between sessions.

Let’s say - i want to add github MCP - GitHub - github/github-mcp-server: GitHub's official MCP Server
this requires PAT to be sent with the request - but the PAT is different per user (i can retrieve user specific PATs from a secret store we have)

so - what’s the correct way to do it? should i levarage this?

At the moment the easiest way to achieve this is by rebuilding the graph for each request and providing auth headers in the connection object if you’re using langgraph_mcp_adapters.

We’ll try to add a more streamlined solution to remove some of the overhead of re-creating the graph for every request.

This has information on how to rebuild the graph per request with LangGraph Server

You can set up something similar if you’re doing your own FastAPI app.

This doc has information about run time headers: GitHub - langchain-ai/langchain-mcp-adapters: LangChain 🔌 MCP