-
Notifications
You must be signed in to change notification settings - Fork 7
Example: Create an authenticated mcp-lite server with Hono + Clerk #58
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
Conversation
|
48f66a3 to
b783fbc
Compare
commit: |
955c89f to
c8488ba
Compare
What Works
I was able to authenticate with MCP Inspector!
Resources
What I'm reading / using:
The current code is based on:
Hono Clerk middleware, which calls authenticateRequest, and uses the result to get the auth object
acceptsTokenparameter should beTokenType.OAuthToken, which differs from the Hono Clerk middlewareClerk's MCP Server utilities (
@clerk/mcp-tools/server) for setting up proper.well-knownroutes in the APIMisc Notes
Configuration is necessary:
The Clerk
authInfoin their Express example is typecast like this:The function
fetchClerkAuthorizationServerMetadatarequired that nodejs compatibility flag was enabled in thewrangler.jsoncThe
@clerk/mcp-toolspackage brings in@modelcontextprotocol/sdktypes.Misc TODOs
Show (in example) use of
authInfoInvestigate intermittent 400 on POST /mcp after authenticating... does not seem to affect functionality in inspector but. Ya know.
Can we remove and implement our own version of
verifyClerkToken? Seems tied specifically to the mcp sdk + its AuthInfo type anyhow, and the logic is dead simpleUse typegen for the bindings types (AppType)
File issue with mcp-tools as their README is out of date: Remove refs to nonexistent auth server metadata helpers from README clerk/mcp-tools#7
Can we remove
error="${err.errorCode}", error_description="${err.message}",from the www-authenticate headerCheck if the oauth client id and oauth client secret are necessary to configure in the Hono api?
Clean up or document the manual construction of the resource url in
".well-known/oauth-protected-resource"handlerCheck if the Clerk middleware for Hono has been updated to support the machine auth beta (UPDATE: It has not)
File issue with Clerk Docs as the code samples are missing for "js backend sdk" when setting up MCP auth (see here - then select JS Backend from the sdk dropdown on the left)