Skip to content

Conversation

@brettimus
Copy link

@brettimus brettimus commented Sep 15, 2025

Overview

Adds a new folder hono/ with utilities and examples for building an authenticated (Hono-based) MCP server with Clerk.

At the moment, this PR focuses on Clerk utilities only, and does not export general-purpose helpers like the express/ module does.

Worth Noting

Web Standard api frameworks like Hono do not play nicely with the @modelcontextprotocol/sdk typescript package, since that package is rather Express-and-Node.js specific.

(This is why Hono has its own package for building MCP servers, which re-implements the StreamableHTTPTransport under the hood.)

Currently, the Hono mcp middleware does not have a way to pass auth down to tools (it's WIP), but this is something that the mcp-lite SDK does (disclosure: I am a maintainer), which is why I included it in an example.

Exports of @clerk/mcp-tools/hono

  • mcpAuthClerk - Hono authentication middleware
  • oauthCorsMiddleware - cors middleware for the oauth metadata handlers
  • protectedResourceHandlerClerk - handler that returns metadata for the resource server (Hono app)
  • authServerMetadataHandlerClerk - handler that returns Clerk auth server metadata

How I tested

I published this package under a different scope (@bretterplane/mcp-tools) and made sure the example from the Hono README worked in the repo here without import or type errors.

To configure Clerk, I created an application, then enabled OAuth + DCR.

To test the auth flow, I ran the @modelcontextprotocol/inspector and used the guided OAuth flow to check each step. (Discovery, client registration, etc.)

Finally, I used the inspector to execute the authenticated tool, and it worked (fetching auth'd user info from Clerk).

TODOs

  • Add general purpose mcp auth utils? (Utilities that do not assume usage of Clerk)
  • Update hono/README.md to fix get_clerk_user_data tool
  • Update hono/README.md to document oauthCorsMiddleware
  • Test the Hono utilities in the wild with a published package (I will do this)

mcpAuthClerk - authentication middleware
oauthCorsMiddleware - cors for the oauth metadata handlers
protectedResourceHandlerClerk - handler that returns metadata for the resource server (Hono app)
authServerMetadataHandlerClerk - handler that returns Clerk auth server metadata
@brettimus brettimus marked this pull request as ready for review September 16, 2025 09:40
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 this pull request may close these issues.

1 participant