Skip to content

Support Authentication According to Current MCP Spec #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pazevedo-hyland opened this issue Mar 19, 2025 · 12 comments · May be fixed by elijahdev0/fastapi_mcp#1
Closed

Support Authentication According to Current MCP Spec #10

pazevedo-hyland opened this issue Mar 19, 2025 · 12 comments · May be fixed by elijahdev0/fastapi_mcp#1

Comments

@pazevedo-hyland
Copy link

Hey, great work on this,

I'm wondering how this will work with endpoints that require an authentication, through a token for example.

How would I connect with this server?

@dexhunter
Copy link
Contributor

you can pass env variables in the config

something like

{
  "mcpServers": {
    "server-name": {
      "url": "http://localhost:8000/mcp",
      "env": {
        "API_KEY": "value"
      }
    }
  }
}

@YikaiHu
Copy link

YikaiHu commented Mar 20, 2025

Hi @dexhunter , how to use this config?
I put it in my ~/Library/Application\ Support/Claude/claude_desktop_config.json

But when I launched the Claude Desktop App, it prompt a issue:

Could not load app settings
There was an error reading or parsing claude_desktop_config.json: [
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"mcpServers",
"server-name",
"command"
],
"message": "Required"
}
]

It seems like must have command field. So what should I use in this filed?

@dexhunter
Copy link
Contributor

@YikaiHu currently sse transport is not supported at Claude Desktop, you can use it at the cursor or other platforms which support mcp sse transport

@miki-tadata
Copy link

@YikaiHu - as @dexhunter said, sse transport is not supported in Claude Desktop yet. We added in the README instruction on how to use a gateway and tested it on Windows and Mac

@scottberres-tr
Copy link

How do I get access to the token when the mcp endpoint is invoked so I can validate it on the server before processing the request. FastApi allows dependencies=[Depends(authorize)]

The call is intercepted and routed to that method where the token can be authorized for access.

@elijahdev0
Copy link

Just checking if I can see the comments on this issue - this is a test.

@theeldermillenial
Copy link

theeldermillenial commented Mar 26, 2025

You can and probably should use the builtin auth tools in FastAPI. You could also potentially using FastAPIs middleware to inject the token into all requests.

This does not appear to be a fastapi_mcp issue, rather it's a fastapi configuration issue.

https://fastapi.tiangolo.com/tutorial/security/first-steps/

https://fastapi.tiangolo.com/tutorial/middleware/

@lordk911
Copy link

When will this be supported?

@shahar4499
Copy link
Contributor

When will this be supported?

We are working on adding authentication support in the coming ~ week. So very soon.

@Razikus
Copy link

Razikus commented Apr 14, 2025

right in time, waiting for it!

@adeprezh
Copy link

Hello, do you still plan to implement Bearer auth? A new MCP spec recommends OAuth 2.X

@shahar4499
Copy link
Contributor

@adeprezh No, we plan on implementing according to the spec, not Bearer auth specifically.

@shahar4499 shahar4499 changed the title How to pass Bearer Tokens / Authentication Support Authentication According to Current MCP Spec Apr 15, 2025
@shahar4499 shahar4499 pinned this issue Apr 15, 2025
@shahar4499 shahar4499 unpinned this issue Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.