fast_mcp_jwt_auth 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/fast_mcp_jwt_auth/version.rb +1 -1
- metadata +3 -9
- data/.DS_Store +0 -0
- data/.mcp.json +0 -30
- data/.mcp.json.example +0 -30
- data/.rubocop.yml +0 -34
- data/.ruby-version +0 -1
- data/CLAUDE.md +0 -148
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 70cd49312d3da735c0f936a67489255a0730fc343274690a616c4c3384be718e
|
|
4
|
+
data.tar.gz: 2df8782779b4f78566c81012ffe7f5e60a2c0df39c632ab568075195c85ee806
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bf3afe9ede194bac8b594d2170c2185b73d1473b581d38f8f11644a886d955c504f98f7ebffa3c73d108b7c1f050b9993e35ede5aa882e7b8996cc2285e1f3c7
|
|
7
|
+
data.tar.gz: 96b43b0ecd17a55647de3fa48beed7d6b762315f1aad9bd658e0d0d51d14dd33a1a27a2f81dc2cb866ec8dec61d26758cf0d9fb11b00882492b91ba2ec748888
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-08-20
|
|
11
|
+
|
|
12
|
+
Everything below reached consumers through the git source months ago but was
|
|
13
|
+
never published: 0.1.0 on RubyGems is the `v0.1.0` tag, seven commits behind what
|
|
14
|
+
projects actually run. This release closes that gap so the gem can be consumed
|
|
15
|
+
from RubyGems instead of from GitHub.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Comprehensive JWT authentication logging.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- Railtie class methods are public, as Rails initializer context requires.
|
|
22
|
+
- Token validator lambda parameter mismatch.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- Refactored towards Ruby Way idiom, with broader test coverage.
|
|
26
|
+
- README documents MCP server configuration.
|
|
27
|
+
|
|
10
28
|
## [0.1.0] - 2025-08-19
|
|
11
29
|
|
|
12
30
|
### Added
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fast_mcp_jwt_auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- josefchmel
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -102,13 +102,7 @@ executables: []
|
|
|
102
102
|
extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
|
104
104
|
files:
|
|
105
|
-
- ".DS_Store"
|
|
106
|
-
- ".mcp.json"
|
|
107
|
-
- ".mcp.json.example"
|
|
108
|
-
- ".rubocop.yml"
|
|
109
|
-
- ".ruby-version"
|
|
110
105
|
- CHANGELOG.md
|
|
111
|
-
- CLAUDE.md
|
|
112
106
|
- LICENSE.txt
|
|
113
107
|
- README.md
|
|
114
108
|
- Rakefile
|
|
@@ -141,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
141
135
|
- !ruby/object:Gem::Version
|
|
142
136
|
version: '0'
|
|
143
137
|
requirements: []
|
|
144
|
-
rubygems_version:
|
|
138
|
+
rubygems_version: 4.0.6
|
|
145
139
|
specification_version: 4
|
|
146
140
|
summary: JWT Authorization header authentication for FastMcp RackTransport
|
|
147
141
|
test_files: []
|
data/.DS_Store
DELETED
|
Binary file
|
data/.mcp.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mcpServers": {
|
|
3
|
-
"workvector-production": {
|
|
4
|
-
"type": "sse",
|
|
5
|
-
"name": "WorkVector Production",
|
|
6
|
-
"url": "https://workvector.com/mcp/sse",
|
|
7
|
-
"headers": {
|
|
8
|
-
"Authorization": "Bearer ${WORKVECTOR_TOKEN}"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"filesystem-project": {
|
|
12
|
-
"type": "stdio",
|
|
13
|
-
"name": "Filesystem",
|
|
14
|
-
"command": "npx",
|
|
15
|
-
"args": [
|
|
16
|
-
"-y",
|
|
17
|
-
"@modelcontextprotocol/server-filesystem",
|
|
18
|
-
"${PWD}"
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
"llmmn-production": {
|
|
22
|
-
"type": "sse",
|
|
23
|
-
"name": "LLM Memory Notes Production",
|
|
24
|
-
"url": "https://llm-memory.com/mcp/sse",
|
|
25
|
-
"headers": {
|
|
26
|
-
"Authorization": "Bearer ${LLMMN_TOKEN}"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
data/.mcp.json.example
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mcpServers": {
|
|
3
|
-
"example-server": {
|
|
4
|
-
"type": "sse",
|
|
5
|
-
"name": "Example MCP Server",
|
|
6
|
-
"url": "https://example.com/mcp/sse",
|
|
7
|
-
"headers": {
|
|
8
|
-
"Authorization": "Bearer ${MCP_JWT_TOKEN}"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"workvector-production": {
|
|
12
|
-
"type": "sse",
|
|
13
|
-
"name": "WorkVector Production",
|
|
14
|
-
"url": "https://workvector.com/mcp/sse",
|
|
15
|
-
"headers": {
|
|
16
|
-
"Authorization": "Bearer ${WORKVECTOR_TOKEN}"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"filesystem-project": {
|
|
20
|
-
"type": "stdio",
|
|
21
|
-
"name": "Filesystem",
|
|
22
|
-
"command": "npx",
|
|
23
|
-
"args": [
|
|
24
|
-
"-y",
|
|
25
|
-
"@modelcontextprotocol/server-filesystem",
|
|
26
|
-
"${PWD}"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
data/.rubocop.yml
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
TargetRubyVersion: 3.1
|
|
3
|
-
NewCops: enable
|
|
4
|
-
SuggestExtensions: false
|
|
5
|
-
|
|
6
|
-
plugins:
|
|
7
|
-
- rubocop-minitest
|
|
8
|
-
|
|
9
|
-
Layout/LineLength:
|
|
10
|
-
Max: 200
|
|
11
|
-
|
|
12
|
-
Style/StringLiterals:
|
|
13
|
-
EnforcedStyle: double_quotes
|
|
14
|
-
|
|
15
|
-
Style/StringLiteralsInInterpolation:
|
|
16
|
-
EnforcedStyle: double_quotes
|
|
17
|
-
|
|
18
|
-
# Relax some metrics for reasonable code
|
|
19
|
-
Metrics/ClassLength:
|
|
20
|
-
Max: 150
|
|
21
|
-
|
|
22
|
-
Metrics/MethodLength:
|
|
23
|
-
Max: 30
|
|
24
|
-
|
|
25
|
-
Metrics/AbcSize:
|
|
26
|
-
Max: 35
|
|
27
|
-
|
|
28
|
-
# Allow longer module for JWT authentication patch - it's a cohesive logical unit
|
|
29
|
-
Metrics/ModuleLength:
|
|
30
|
-
Max: 130
|
|
31
|
-
|
|
32
|
-
# Allow development dependencies in gemspec for gems
|
|
33
|
-
Gemspec/DevelopmentDependencies:
|
|
34
|
-
Enabled: false
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ruby-3.4.2
|
data/CLAUDE.md
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code when working with the `fast_mcp_jwt_auth` gem.
|
|
4
|
-
|
|
5
|
-
## Gem Overview
|
|
6
|
-
|
|
7
|
-
FastMCp Jwt Auth provides JWT authentication for FastMcp RackTransport, enabling secure user authentication in MCP requests.
|
|
8
|
-
It integrates seamlessly with Rails, allowing you to authenticate users using JWT tokens in a Rails application.
|
|
9
|
-
|
|
10
|
-
## Code Conventions
|
|
11
|
-
|
|
12
|
-
### Code Quality
|
|
13
|
-
- Max 200 chars/line (soft limit - prefer readability over strict compliance)
|
|
14
|
-
- breaking Ruby chain calls destroys the natural sentence flow and readability
|
|
15
|
-
- 14 lines/method, 110 lines/class
|
|
16
|
-
- Comments and tests in English
|
|
17
|
-
- KEEP CODE DRY (Don't Repeat Yourself)
|
|
18
|
-
|
|
19
|
-
### Ruby/Rails Philosophy
|
|
20
|
-
- **DO IT RUBY WAY OR RAILS WAY** - it's not Python, Java or PHP!
|
|
21
|
-
- Strong use of Ruby metaprogramming techniques
|
|
22
|
-
- code line should look like human sentence (e.g. `3.times do` not `for i in 0..2 do` - Ruby syntax reads like English)
|
|
23
|
-
- keep code raising exceptions when it's programmer's fault - DO NOT validate method parameters, expect them to be correct! Only validate user input
|
|
24
|
-
- do not repeat name of parameter in method name (e.g. `def create_new_user_from_user(user)` should be `def create_new_user_from(user)`)
|
|
25
|
-
- do not use extra variable if used only once - saves memory and reduces GC pressure under high traffic (e.g. `user = User.find(params[:id]); user.update(...)` should be `User.find(params[:id]).update(...)`) - use `.tap do` for chaining when you need to use the object later
|
|
26
|
-
- use metaprogramming instead of case statements (e.g. `self.send(method_name, params)` instead of `case method_name; when "find_slot"...` - let Ruby handle method dispatch and NoMethodError)
|
|
27
|
-
- PREFER FUNCTIONAL STYLE: use flat_map, map, select over loops and temp variables (e.g. `items.flat_map(&:children).uniq` not `results = []; items.each { |i| results.concat(i.children) }; results.uniq`)
|
|
28
|
-
- USE PATTERN MATCHING: Ruby 3.0+ `case/in` for complex conditionals instead of if/elsif chains - more expressive and catches unhandled cases
|
|
29
|
-
- ONE CLEAR RESPONSIBILITY: each method should do one thing well - if method has "and" in description, split it (e.g. `normalize_and_search` → `normalize` + `search`)
|
|
30
|
-
- FOLLOW KISS PRINCIPLE: Keep It Simple, Stupid - avoid unnecessary complexity, use simple solutions first
|
|
31
|
-
- ALWAYS TEST YOUR CODE
|
|
32
|
-
|
|
33
|
-
### Error Handling
|
|
34
|
-
- Use meaningful exception classes (not generic StandardError)
|
|
35
|
-
- Log errors with context using the configured logger
|
|
36
|
-
- Proper error propagation with fallback mechanisms
|
|
37
|
-
- Use `rescue_from` for common exceptions in Rails integration
|
|
38
|
-
|
|
39
|
-
### Performance Considerations
|
|
40
|
-
- Use database connection pooling efficiently
|
|
41
|
-
- Avoid blocking operations in main threads
|
|
42
|
-
- Cache expensive operations
|
|
43
|
-
- Monitor thread lifecycle and cleanup
|
|
44
|
-
|
|
45
|
-
### Thread Safety
|
|
46
|
-
- All operations must be thread-safe for cluster mode
|
|
47
|
-
- Use proper synchronization when accessing shared resources
|
|
48
|
-
- Handle thread lifecycle correctly (creation, monitoring, cleanup)
|
|
49
|
-
- Use connection checkout/checkin pattern for database operations
|
|
50
|
-
|
|
51
|
-
### Gem Specific Guidelines
|
|
52
|
-
|
|
53
|
-
#### Configuration
|
|
54
|
-
- Use configuration object pattern for all settings
|
|
55
|
-
- Provide sensible defaults that work out of the box
|
|
56
|
-
- Make all components configurable but not required
|
|
57
|
-
- Support both programmatic and initializer-based configuration
|
|
58
|
-
|
|
59
|
-
#### Rails Integration
|
|
60
|
-
- Use Railtie for automatic Rails integration
|
|
61
|
-
- Hook into appropriate Rails lifecycle events
|
|
62
|
-
- Respect Rails conventions for logging and error handling
|
|
63
|
-
- Provide manual configuration options for non-Rails usage
|
|
64
|
-
|
|
65
|
-
#### Error Recovery
|
|
66
|
-
- Implement automatic retry with backoff for transient errors
|
|
67
|
-
- Provide fallback mechanisms when PubSub fails
|
|
68
|
-
- Log errors appropriately without flooding logs
|
|
69
|
-
- Handle connection failures gracefully
|
|
70
|
-
|
|
71
|
-
#### Testing
|
|
72
|
-
- Test all public interfaces
|
|
73
|
-
- Mock external dependencies (PostgreSQL, FastMcp)
|
|
74
|
-
- Test error conditions and edge cases
|
|
75
|
-
- Provide test helpers for gem users
|
|
76
|
-
- Test both Rails and non-Rails usage
|
|
77
|
-
|
|
78
|
-
## Architecture
|
|
79
|
-
|
|
80
|
-
### Components
|
|
81
|
-
|
|
82
|
-
1. **FastMcpJwtAuth::Service** - Core JWT authentication service
|
|
83
|
-
- Handles JWT token generation and validation
|
|
84
|
-
- Integrates with FastMcp RackTransport for secure requests
|
|
85
|
-
2. **FastMcpJwtAuth::Configuration** - Configuration management
|
|
86
|
-
- Manages settings like JWT secret, expiration, and algorithm
|
|
87
|
-
3. **FastMcpJwtAuth::RackTransportPatch** - Monkey patch for FastMcp transport
|
|
88
|
-
- Overrides `send_message` to include JWT authentication
|
|
89
|
-
4. **FastMcpJwtAuth::Railtie** - Rails integration and lifecycle management
|
|
90
|
-
- Automatically patches FastMcp::Transports::RackTransport during Rails initialization
|
|
91
|
-
|
|
92
|
-
### Message Flow
|
|
93
|
-
|
|
94
|
-
1. **MCP Request Received** - FastMcp RackTransport receives HTTP request with Authorization header
|
|
95
|
-
2. **JWT Extraction** - Extract Bearer token from Authorization header (`HTTP_AUTHORIZATION`)
|
|
96
|
-
3. **Token Decoding** - Use configured `jwt_decoder` callback to decode JWT token
|
|
97
|
-
4. **Token Validation** - Validate token expiration and other claims using `token_validator` callback
|
|
98
|
-
5. **User Lookup** - Find user from decoded token using `user_finder` callback
|
|
99
|
-
6. **User Assignment** - Set current user in context using `current_user_setter` callback
|
|
100
|
-
7. **Request Processing** - Continue with normal MCP request handling
|
|
101
|
-
8. **Cleanup** - Clear current user context using `current_resetter` callback
|
|
102
|
-
|
|
103
|
-
### Thread Management
|
|
104
|
-
|
|
105
|
-
The gem is designed to be thread-safe for use in Rails applications:
|
|
106
|
-
|
|
107
|
-
- **Request Isolation** - Each MCP request runs in its own thread context
|
|
108
|
-
- **Current User Context** - Uses thread-local storage via Rails `Current` class for user context
|
|
109
|
-
- **Monkey Patching Safety** - Patch is applied only once using thread-safe flag checking
|
|
110
|
-
- **No Shared State** - All operations are stateless except for configuration (immutable after initialization)
|
|
111
|
-
- **Callback Thread Safety** - User-provided callbacks (`jwt_decoder`, `user_finder`, etc.) must be thread-safe
|
|
112
|
-
- **Automatic Cleanup** - Current user context is always cleared after request processing (even on exceptions)
|
|
113
|
-
|
|
114
|
-
## Dependencies
|
|
115
|
-
|
|
116
|
-
### Runtime Dependencies
|
|
117
|
-
- **rails** (>= 7.0) - Required for Rails integration, Current class, and logger support
|
|
118
|
-
|
|
119
|
-
### Development Dependencies
|
|
120
|
-
- **jwt** (~> 2.0) - Used in tests for JWT token generation and decoding examples
|
|
121
|
-
- **minitest** (~> 5.16) - Test framework
|
|
122
|
-
- **rubocop** (~> 1.21) - Ruby code style enforcement
|
|
123
|
-
- **rubocop-minitest** (~> 0.25) - Minitest-specific RuboCop rules
|
|
124
|
-
- **rubocop-rails** (~> 2.0) - Rails-specific RuboCop rules
|
|
125
|
-
|
|
126
|
-
### External Dependencies
|
|
127
|
-
- **FastMcp** - The gem monkey patches `FastMcp::Transports::RackTransport` (not declared as dependency to avoid circular dependencies)
|
|
128
|
-
- **JWT Library** - Users must provide their own JWT decoder implementation (commonly `jwt` gem)
|
|
129
|
-
|
|
130
|
-
## Development
|
|
131
|
-
|
|
132
|
-
### Running Tests
|
|
133
|
-
```bash
|
|
134
|
-
bundle exec rake test
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Linting
|
|
138
|
-
```bash
|
|
139
|
-
bundle exec rubocop
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Console
|
|
143
|
-
```bash
|
|
144
|
-
bundle exec rake console
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Project-Specific Info
|
|
148
|
-
- **LLM Memory identifier**: `fast_mcp_jwt_auth`
|