Skip to content

FastMCP Auth Context in tools #638

Closed

Description

@anant-singh

I wanted to know how I can get the Auth context within the tools/resources. Couldn't find any documentation or examples for it. I was able to add Oauth to my server and it completes the login flow. But I need to pass the auth token to the tools being called. Is that possible right now or is it still to be implemented

Activity

  1. stanlee000 commented on May 6, 2025

    @stanlee000
  2. gilv commented on May 6, 2025

    @gilv

    @stanlee000 @anant-singh I was looking exactly the same and see thus issue. I use

    @mcp.tool 
    def my_func()
    

    and was struggle to get request object inside my_func so i can access Authorization header. Nothing works, even using my_func(**kwargs) not works... why this happens? @mcp.tool simply doesn't allow to pass request into tool?

  3. jlowin commented on May 6, 2025

    @jlowin
    Contributor

    Just FYI this functionality is available in FastMCP 2.0, which is otherwise compatible with the FastMCP class in mcp: https://gofastmcp.com/servers/context#accessing-http-requests

  4. orest-tokovenko-block commented on May 7, 2025

    @orest-tokovenko-block

    I'm having difficulty actually kicking off the oauth flow, anyone else seeing the same issue? I've implemented the protocol class and it initializes it in th elogs but nothing afterwards and no errors 🤔

  5. added
    auth
    enhancement
    ready for work
    P1
    on Oct 7, 2025
  6. maxisbey commented on Feb 19, 2026

    @maxisbey
    Contributor

    Now tracked in #2098.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1authenhancementready for work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions