JWT authentication through header for MCP server - PATCH gem
{
"mcpServers": {
"your-rails-app": {
"url": "https://your-rails-app.com/mcp/sse",
"name": "Your Rails MCP Server",
"type": "sse",
"headers": {
"Authorization": "Bearer ${JWT_TOKEN}"
}
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
JWT authentication through header for MCP server - PATCH gem
Is it safe?
No package registry to scan.
No authentication — any process on your machine can connect.
MIT. View license →
Is it maintained?
Last commit 226 days ago. 3 stars.
Will it work with my client?
Transport: sse, http. Compatibility not confirmed.
No automated test available for this server. Check the GitHub README for setup instructions.
No known vulnerabilities.
This server is missing a description. Tools and install config are also missing.If you've used it, help the community.
Add informationHave you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Search, evaluate, and compare 17,000+ MCP servers — each scored on security, maintenance, and efficiency.
AI agents get on-chain identity, credentials, reputation, escrow, and persistent memory on XRPL.
MCP server for scanning and remediating hardcoded secrets using GitGuardian’s API. Detect over 500 secret types and prevent credential leaks before code goes public.
Trust infrastructure for AI agents — DIDs, reputation, verifiable credentials, USDC.
MCP Security Weekly
Get CVE alerts and security updates for Fast_mcp_jwt_auth and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
JWT Authorization header authentication extension for FastMcp RackTransport.
This gem extends the FastMcp gem to enable JWT-based user authentication via Authorization headers in Rails applications. It provides configurable callbacks for token decoding, user lookup, and validation.
FastMcp::Transports::RackTransport doesn't have built-in JWT authentication support. For integrating with external MCP clients that use JWT tokens for authentication, you need a way to:
Current.user for the request durationThis gem provides a monkey patch for FastMcp::Transports::RackTransport that:
Authorization: Bearer headersCurrent.user for request durationCurrent after request processingPrerequisites: This gem requires the fast-mcp gem to be installed first.
Add both gems to your application's Gemfile:
gem 'fast-mcp' # Required base gem
gem 'fast_mcp_jwt_auth', github: 'jchsoft/fast_mcp_jwt_auth' # This extension
And then execute:
bundle install
Note: The fast-mcp gem provides the core MCP (Model Context Protocol) server functionality, while this gem extends it with JWT authentication support.
No configuration needed for basic usage! Just add the gem to your Gemfile and configure the callbacks.
The gem will:
⚠️ IMPORTANT: This gem enables JWT authentication for your Rails application when used with the fast_mcp gem. For MCP clients to authenticate with your Rails app, they need to send JWT tokens in the Authorization: Bearer header.
When your Rails app is running as an MCP server (using fast_mcp gem and fast_mcp_jwt_auth gem), MCP clients need to be configured with proper authentication headers to connect to it.
For example create or update your .mcp.json configuration file:
cp .mcp.json.example .mcp.json
Critical: The headers section with Authorization: Bearer is essential for JWT authentication:
{
"mcpServers": {
"your-rails-app": {
"type": "sse",
"name": "Your Rails MCP Server",
"url": "https://your-rails-app.com/mcp/sse",
"headers": {
"Authorization": "Bearer ${JWT_TOKEN}"
}
}
}
}
{
"mcpServers": {
"workvector-production": {
"type": "sse",
"name": "WorkVector Production",
"url": "https://workvector.com/mcp/sse",
"headers": {
"Authorization": "Bearer ${WORKVECTOR_TOKEN}"
}
}
}
}
❌ This WON'T work - missing authentication:
{
"mcpServers": {
"your-app": {
"type": "sse",
"url": "https://your-app.com/mcp/sse"
}
}
}
✅ This WILL work - includes JWT authentication header:
{
"mcpServers": {
"your-app": {
"type": "sse",
"url": "https://your-app.com/mcp/sse",
"headers": {
"Authorization": "Bearer ${JWT_TOKEN}"
}
}
}
}
Use environment variables for sensitive tokens in your .mcp.json: