JWT authentication through header for MCP server - PATCH gem
Config is the same across clients — only the file and path differ.
{
"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 Authorization header authentication extension for FastMcp RackTransport.
No automated test available for this server. Check the GitHub README for setup instructions.
Five weighted categories — click any category to see the underlying evidence.
No known CVEs.
No package registry to scan.
Be the first to review
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Others in security
An evil MCP server used for redteam testing
AI-powered reverse engineering assistant that bridges IDA Pro with language models through MCP.
Proof primitive for AI agents on MultiversX. Anchor file hashes on-chain as verifiable proofs.
mcpki-server is the backend infrastructure for https://www.mcpki.org, enabling secure public key management and autonomous certificate handling for large language models (LLMs).
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: