Using the OAuthProxy mounted in a FastAPI Server #1862
Unanswered
joelacummings
asked this question in
Q&A
Replies: 1 comment
-
|
I also saw this PR and thought of another possiblity, could I mount another MCP app within my MCP but combine the lifespans to make that compatible? Something like this but sorting out the lifespan troubles? # create the API Key MCP Server
api_key_mcp = FastMCP(
name="Data Items MCP Server",
instructions=server_instructions,
middleware=[ApiKeyVerificationMiddleware()],
)
api_key_app = api_key_mcp.http_app(path='/mcp')
MCPToolSet(api_key_mcp, True)
# Create the OAuth MCP server
oauth_mcp = FastMCP(
name="Data Items MCP Server",
instructions=server_instructions,
auth=auth,
lifespan=api_key_app.lifespan
)
MCPToolSet(oauth_mcp)
oauth_app = oauth_mcp.http_app(path='/oauth/mcp')
oauth_app.mount('/api-key', api_key_app)Currently with this the I get this error: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
This might be a bit of an unusual case. I have a Fast API server that I'm essentially using to integrate two FastMCP servers due to different authentication requirements. So I have one server mounted using the OAuth proxy and one mounted as a plain FastMCP server but I have added some API key checking middleware.
I'm initiallizing both on different starting endpoints
/oauthfor my oauth implementation and/api-keyfor my api key implementation. The problem is that servers are looking for the well known resources at the root path:So is there a suggested workaround for getting these generated paths to the root level? (They exist at
/oauth/.well-knownCan I select just those paths from the application and mount them separately with FastAPI? I'm also imagining this will be an issue for the callback as well... Should I just create the routes in Fast API?Here is the FastMCP/FastAPI code if that is helpful.
Also if this just doesn't seem like a good way to handle having two methods of auth or servers I'm open to ideas on that as well.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions