Example: Create an authenticated mcp-lite server with Hono + Clerk#58
Merged
Example: Create an authenticated mcp-lite server with Hono + Clerk#58
Conversation
|
48f66a3 to
b783fbc
Compare
commit: |
955c89f to
c8488ba
Compare
laulauland
approved these changes
Sep 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)