hitch-rails 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.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +103 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +460 -0
  5. data/SECURITY.md +118 -0
  6. data/app/controllers/concerns/hitch/cors_support.rb +97 -0
  7. data/app/controllers/concerns/hitch/host_validation.rb +51 -0
  8. data/app/controllers/concerns/hitch/issuer_url.rb +26 -0
  9. data/app/controllers/concerns/hitch/mcp/endpoint.rb +355 -0
  10. data/app/controllers/concerns/hitch/oauth_form_admission.rb +83 -0
  11. data/app/controllers/concerns/hitch/oauth_parameter_validation.rb +26 -0
  12. data/app/controllers/concerns/hitch/registration_admission.rb +115 -0
  13. data/app/controllers/concerns/hitch/request_admission.rb +46 -0
  14. data/app/controllers/concerns/hitch/uri_validation.rb +116 -0
  15. data/app/controllers/hitch/application_controller.rb +59 -0
  16. data/app/controllers/hitch/authorizations_controller.rb +152 -0
  17. data/app/controllers/hitch/metadata_controller.rb +114 -0
  18. data/app/controllers/hitch/preflights_controller.rb +14 -0
  19. data/app/controllers/hitch/public_endpoint_controller.rb +36 -0
  20. data/app/controllers/hitch/registrations_controller.rb +135 -0
  21. data/app/controllers/hitch/revocations_controller.rb +31 -0
  22. data/app/controllers/hitch/tokens_controller.rb +89 -0
  23. data/app/models/hitch/access_token.rb +267 -0
  24. data/app/models/hitch/application_record.rb +7 -0
  25. data/app/models/hitch/authorization_request.rb +252 -0
  26. data/app/models/hitch/client/credentials.rb +30 -0
  27. data/app/models/hitch/client.rb +237 -0
  28. data/app/models/hitch/client_authentication.rb +80 -0
  29. data/app/models/hitch/client_id_metadata/cache.rb +69 -0
  30. data/app/models/hitch/client_id_metadata/fetcher.rb +277 -0
  31. data/app/models/hitch/client_id_metadata/throttle.rb +119 -0
  32. data/app/models/hitch/client_id_metadata.rb +316 -0
  33. data/app/models/hitch/client_redirect_uri.rb +14 -0
  34. data/app/models/hitch/mcp/context.rb +91 -0
  35. data/app/models/hitch/mcp/forbidden.rb +10 -0
  36. data/app/models/hitch/mcp/internal/bearer_challenge.rb +51 -0
  37. data/app/models/hitch/mcp/internal/cors_policy.rb +53 -0
  38. data/app/models/hitch/mcp/internal/endpoint_error_reporter.rb +40 -0
  39. data/app/models/hitch/mcp/internal/error_normalizer.rb +74 -0
  40. data/app/models/hitch/mcp/internal/header_field.rb +31 -0
  41. data/app/models/hitch/mcp/internal/hmac_identity.rb +37 -0
  42. data/app/models/hitch/mcp/internal/host_authority.rb +51 -0
  43. data/app/models/hitch/mcp/internal/json_values.rb +182 -0
  44. data/app/models/hitch/mcp/internal/local_diagnosis.rb +31 -0
  45. data/app/models/hitch/mcp/internal/media_type.rb +61 -0
  46. data/app/models/hitch/mcp/internal/observation.rb +333 -0
  47. data/app/models/hitch/mcp/internal/registry_runtime.rb +312 -0
  48. data/app/models/hitch/mcp/internal/result_normalizer.rb +167 -0
  49. data/app/models/hitch/mcp/internal/sanitized_report.rb +36 -0
  50. data/app/models/hitch/mcp/internal/schema_contract.rb +173 -0
  51. data/app/models/hitch/mcp/internal/sdk_adapter/response_normalizer.rb +173 -0
  52. data/app/models/hitch/mcp/internal/sdk_adapter.rb +222 -0
  53. data/app/models/hitch/mcp/internal/server_info.rb +49 -0
  54. data/app/models/hitch/mcp/internal/verified_request.rb +229 -0
  55. data/app/models/hitch/mcp/internal.rb +11 -0
  56. data/app/models/hitch/mcp/rate_limit_key.rb +29 -0
  57. data/app/models/hitch/mcp/registry.rb +70 -0
  58. data/app/models/hitch/mcp/result.rb +63 -0
  59. data/app/models/hitch/mcp/tool.rb +148 -0
  60. data/app/models/hitch/oauth_request_parameters.rb +74 -0
  61. data/app/views/hitch/authorizations/new.html.erb +57 -0
  62. data/config/routes.rb +37 -0
  63. data/db/migrate/20260817000000_create_hitch_tables.rb +77 -0
  64. data/docs/operator/doctor.md +82 -0
  65. data/docs/operator/rate_limiting.md +98 -0
  66. data/docs/public_api/0.2.0.md +322 -0
  67. data/docs/removing.md +43 -0
  68. data/lib/generators/hitch/generator_guards.rb +36 -0
  69. data/lib/generators/hitch/install/install_generator.rb +168 -0
  70. data/lib/generators/hitch/install/templates/controller.rb.tt +11 -0
  71. data/lib/generators/hitch/install/templates/initializer.rb +40 -0
  72. data/lib/generators/hitch/install/templates/registry.rb +6 -0
  73. data/lib/generators/hitch/tool/templates/tool.rb.tt +54 -0
  74. data/lib/generators/hitch/tool/templates/tool_test.rb.tt +58 -0
  75. data/lib/generators/hitch/tool_generator.rb +153 -0
  76. data/lib/hitch/configuration.rb +386 -0
  77. data/lib/hitch/doctor.rb +647 -0
  78. data/lib/hitch/dynamic_registration_rate_limit.rb +75 -0
  79. data/lib/hitch/engine.rb +154 -0
  80. data/lib/hitch/mcp/configuration.rb +190 -0
  81. data/lib/hitch/mcp/protocol.rb +36 -0
  82. data/lib/hitch/mcp/test_helper.rb +203 -0
  83. data/lib/hitch/pkce.rb +18 -0
  84. data/lib/hitch/rack_form_guard.rb +109 -0
  85. data/lib/hitch/rate_limit_store.rb +47 -0
  86. data/lib/hitch/resource_uri.rb +71 -0
  87. data/lib/hitch/version.rb +5 -0
  88. data/lib/hitch-rails.rb +6 -0
  89. data/lib/hitch.rb +51 -0
  90. data/lib/tasks/hitch.rake +197 -0
  91. metadata +230 -0
metadata ADDED
@@ -0,0 +1,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hitch-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Tyler Klose
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: json
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '2.13'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '2.13'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3'
32
+ - !ruby/object:Gem::Dependency
33
+ name: json_schemer
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '2.4'
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '3'
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '2.4'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '3'
52
+ - !ruby/object:Gem::Dependency
53
+ name: mcp
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '1.2'
59
+ - - "<"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '1.2'
69
+ - - "<"
70
+ - !ruby/object:Gem::Version
71
+ version: '2'
72
+ - !ruby/object:Gem::Dependency
73
+ name: rails
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '8.0'
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '9'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '8.0'
89
+ - - "<"
90
+ - !ruby/object:Gem::Version
91
+ version: '9'
92
+ description: |
93
+ Hitch lets MCP clients -- Claude, ChatGPT, Cursor -- call your Rails
94
+ app's tools as a specific signed-in user, with access you can revoke.
95
+
96
+ You do not stand up a separate auth server, add Redis, or adopt a new
97
+ sign-in system. Hitch uses the authentication your app already has
98
+ (current_user or Current.user) and your configured cache store.
99
+
100
+ Underneath it is a full OAuth 2.1 authorization server implementing the
101
+ MCP 2026-07-28 authorization profile: PKCE (S256), audience-bound tokens
102
+ (RFC 8707), discovery metadata (RFC 8414 + RFC 9728), revocation
103
+ (RFC 7009), Client ID Metadata Documents, and optional Dynamic Client
104
+ Registration (RFC 7591). It adds an authenticated /mcp endpoint backed by
105
+ the official Ruby MCP SDK and a deny-default tool registry with schema
106
+ validation and size caps. SQLite and PostgreSQL supported.
107
+ executables: []
108
+ extensions: []
109
+ extra_rdoc_files: []
110
+ files:
111
+ - CHANGELOG.md
112
+ - MIT-LICENSE
113
+ - README.md
114
+ - SECURITY.md
115
+ - app/controllers/concerns/hitch/cors_support.rb
116
+ - app/controllers/concerns/hitch/host_validation.rb
117
+ - app/controllers/concerns/hitch/issuer_url.rb
118
+ - app/controllers/concerns/hitch/mcp/endpoint.rb
119
+ - app/controllers/concerns/hitch/oauth_form_admission.rb
120
+ - app/controllers/concerns/hitch/oauth_parameter_validation.rb
121
+ - app/controllers/concerns/hitch/registration_admission.rb
122
+ - app/controllers/concerns/hitch/request_admission.rb
123
+ - app/controllers/concerns/hitch/uri_validation.rb
124
+ - app/controllers/hitch/application_controller.rb
125
+ - app/controllers/hitch/authorizations_controller.rb
126
+ - app/controllers/hitch/metadata_controller.rb
127
+ - app/controllers/hitch/preflights_controller.rb
128
+ - app/controllers/hitch/public_endpoint_controller.rb
129
+ - app/controllers/hitch/registrations_controller.rb
130
+ - app/controllers/hitch/revocations_controller.rb
131
+ - app/controllers/hitch/tokens_controller.rb
132
+ - app/models/hitch/access_token.rb
133
+ - app/models/hitch/application_record.rb
134
+ - app/models/hitch/authorization_request.rb
135
+ - app/models/hitch/client.rb
136
+ - app/models/hitch/client/credentials.rb
137
+ - app/models/hitch/client_authentication.rb
138
+ - app/models/hitch/client_id_metadata.rb
139
+ - app/models/hitch/client_id_metadata/cache.rb
140
+ - app/models/hitch/client_id_metadata/fetcher.rb
141
+ - app/models/hitch/client_id_metadata/throttle.rb
142
+ - app/models/hitch/client_redirect_uri.rb
143
+ - app/models/hitch/mcp/context.rb
144
+ - app/models/hitch/mcp/forbidden.rb
145
+ - app/models/hitch/mcp/internal.rb
146
+ - app/models/hitch/mcp/internal/bearer_challenge.rb
147
+ - app/models/hitch/mcp/internal/cors_policy.rb
148
+ - app/models/hitch/mcp/internal/endpoint_error_reporter.rb
149
+ - app/models/hitch/mcp/internal/error_normalizer.rb
150
+ - app/models/hitch/mcp/internal/header_field.rb
151
+ - app/models/hitch/mcp/internal/hmac_identity.rb
152
+ - app/models/hitch/mcp/internal/host_authority.rb
153
+ - app/models/hitch/mcp/internal/json_values.rb
154
+ - app/models/hitch/mcp/internal/local_diagnosis.rb
155
+ - app/models/hitch/mcp/internal/media_type.rb
156
+ - app/models/hitch/mcp/internal/observation.rb
157
+ - app/models/hitch/mcp/internal/registry_runtime.rb
158
+ - app/models/hitch/mcp/internal/result_normalizer.rb
159
+ - app/models/hitch/mcp/internal/sanitized_report.rb
160
+ - app/models/hitch/mcp/internal/schema_contract.rb
161
+ - app/models/hitch/mcp/internal/sdk_adapter.rb
162
+ - app/models/hitch/mcp/internal/sdk_adapter/response_normalizer.rb
163
+ - app/models/hitch/mcp/internal/server_info.rb
164
+ - app/models/hitch/mcp/internal/verified_request.rb
165
+ - app/models/hitch/mcp/rate_limit_key.rb
166
+ - app/models/hitch/mcp/registry.rb
167
+ - app/models/hitch/mcp/result.rb
168
+ - app/models/hitch/mcp/tool.rb
169
+ - app/models/hitch/oauth_request_parameters.rb
170
+ - app/views/hitch/authorizations/new.html.erb
171
+ - config/routes.rb
172
+ - db/migrate/20260817000000_create_hitch_tables.rb
173
+ - docs/operator/doctor.md
174
+ - docs/operator/rate_limiting.md
175
+ - docs/public_api/0.2.0.md
176
+ - docs/removing.md
177
+ - lib/generators/hitch/generator_guards.rb
178
+ - lib/generators/hitch/install/install_generator.rb
179
+ - lib/generators/hitch/install/templates/controller.rb.tt
180
+ - lib/generators/hitch/install/templates/initializer.rb
181
+ - lib/generators/hitch/install/templates/registry.rb
182
+ - lib/generators/hitch/tool/templates/tool.rb.tt
183
+ - lib/generators/hitch/tool/templates/tool_test.rb.tt
184
+ - lib/generators/hitch/tool_generator.rb
185
+ - lib/hitch-rails.rb
186
+ - lib/hitch.rb
187
+ - lib/hitch/configuration.rb
188
+ - lib/hitch/doctor.rb
189
+ - lib/hitch/dynamic_registration_rate_limit.rb
190
+ - lib/hitch/engine.rb
191
+ - lib/hitch/mcp/configuration.rb
192
+ - lib/hitch/mcp/protocol.rb
193
+ - lib/hitch/mcp/test_helper.rb
194
+ - lib/hitch/pkce.rb
195
+ - lib/hitch/rack_form_guard.rb
196
+ - lib/hitch/rate_limit_store.rb
197
+ - lib/hitch/resource_uri.rb
198
+ - lib/hitch/version.rb
199
+ - lib/tasks/hitch.rake
200
+ homepage: https://github.com/tylerklose/hitch-rails
201
+ licenses:
202
+ - MIT
203
+ metadata:
204
+ changelog_uri: https://github.com/tylerklose/hitch-rails/blob/main/CHANGELOG.md
205
+ bug_tracker_uri: https://github.com/tylerklose/hitch-rails/issues
206
+ allowed_push_host: https://rubygems.org
207
+ documentation_uri: https://github.com/tylerklose/hitch-rails/blob/v0.2.0/docs/public_api/0.2.0.md
208
+ rubygems_mfa_required: 'true'
209
+ rdoc_options: []
210
+ require_paths:
211
+ - lib
212
+ required_ruby_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '3.3'
217
+ - - "<"
218
+ - !ruby/object:Gem::Version
219
+ version: '4.1'
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ requirements: []
226
+ rubygems_version: 3.6.9
227
+ specification_version: 4
228
+ summary: 'Let AI agents call your Rails app''s tools: an OAuth 2.1 authorization server
229
+ plus an authenticated MCP endpoint, built on the sign-in you already have'
230
+ test_files: []