webmcp-rails 0.1.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 +7 -0
- data/.DS_Store +0 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +242 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +7 -0
- data/lib/.DS_Store +0 -0
- data/lib/webmcp/form_builder.rb +43 -0
- data/lib/webmcp/form_helper.rb +31 -0
- data/lib/webmcp/railtie.rb +11 -0
- data/lib/webmcp/version.rb +5 -0
- data/lib/webmcp-rails.rb +6 -0
- data/webmcp-rails.gemspec +30 -0
- data/webmcp-rails.jpeg +0 -0
- metadata +89 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 98bac34d321447599ce5130d1e613205cec6ef026168a0afaa7852749cbaa822
|
|
4
|
+
data.tar.gz: 832cd6def4b3b99ba9338a2d618c7ed08285bfdebc22f547313268e2e02a0965
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6c629a74b6f67c328a9b6b6110b6867a61bc1f1027f0d4bb3559d1aeb45d4141611b31e964ccd09f20acca1932ac8e0c39b0caed2308c02683fa7d40865bbe35
|
|
7
|
+
data.tar.gz: c88d10b0985425723f0995b0e92af0397f5a2b300183bb9957cd514aec5f6cd396dcd433dbc986cd4e65e9376914184689fc2859635eafb0220ee2c57f309e76
|
data/.DS_Store
ADDED
|
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
webmcp-rails (0.1.0)
|
|
5
|
+
rails (>= 7.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
action_text-trix (2.1.16)
|
|
11
|
+
railties
|
|
12
|
+
actioncable (8.1.2)
|
|
13
|
+
actionpack (= 8.1.2)
|
|
14
|
+
activesupport (= 8.1.2)
|
|
15
|
+
nio4r (~> 2.0)
|
|
16
|
+
websocket-driver (>= 0.6.1)
|
|
17
|
+
zeitwerk (~> 2.6)
|
|
18
|
+
actionmailbox (8.1.2)
|
|
19
|
+
actionpack (= 8.1.2)
|
|
20
|
+
activejob (= 8.1.2)
|
|
21
|
+
activerecord (= 8.1.2)
|
|
22
|
+
activestorage (= 8.1.2)
|
|
23
|
+
activesupport (= 8.1.2)
|
|
24
|
+
mail (>= 2.8.0)
|
|
25
|
+
actionmailer (8.1.2)
|
|
26
|
+
actionpack (= 8.1.2)
|
|
27
|
+
actionview (= 8.1.2)
|
|
28
|
+
activejob (= 8.1.2)
|
|
29
|
+
activesupport (= 8.1.2)
|
|
30
|
+
mail (>= 2.8.0)
|
|
31
|
+
rails-dom-testing (~> 2.2)
|
|
32
|
+
actionpack (8.1.2)
|
|
33
|
+
actionview (= 8.1.2)
|
|
34
|
+
activesupport (= 8.1.2)
|
|
35
|
+
nokogiri (>= 1.8.5)
|
|
36
|
+
rack (>= 2.2.4)
|
|
37
|
+
rack-session (>= 1.0.1)
|
|
38
|
+
rack-test (>= 0.6.3)
|
|
39
|
+
rails-dom-testing (~> 2.2)
|
|
40
|
+
rails-html-sanitizer (~> 1.6)
|
|
41
|
+
useragent (~> 0.16)
|
|
42
|
+
actiontext (8.1.2)
|
|
43
|
+
action_text-trix (~> 2.1.15)
|
|
44
|
+
actionpack (= 8.1.2)
|
|
45
|
+
activerecord (= 8.1.2)
|
|
46
|
+
activestorage (= 8.1.2)
|
|
47
|
+
activesupport (= 8.1.2)
|
|
48
|
+
globalid (>= 0.6.0)
|
|
49
|
+
nokogiri (>= 1.8.5)
|
|
50
|
+
actionview (8.1.2)
|
|
51
|
+
activesupport (= 8.1.2)
|
|
52
|
+
builder (~> 3.1)
|
|
53
|
+
erubi (~> 1.11)
|
|
54
|
+
rails-dom-testing (~> 2.2)
|
|
55
|
+
rails-html-sanitizer (~> 1.6)
|
|
56
|
+
activejob (8.1.2)
|
|
57
|
+
activesupport (= 8.1.2)
|
|
58
|
+
globalid (>= 0.3.6)
|
|
59
|
+
activemodel (8.1.2)
|
|
60
|
+
activesupport (= 8.1.2)
|
|
61
|
+
activerecord (8.1.2)
|
|
62
|
+
activemodel (= 8.1.2)
|
|
63
|
+
activesupport (= 8.1.2)
|
|
64
|
+
timeout (>= 0.4.0)
|
|
65
|
+
activestorage (8.1.2)
|
|
66
|
+
actionpack (= 8.1.2)
|
|
67
|
+
activejob (= 8.1.2)
|
|
68
|
+
activerecord (= 8.1.2)
|
|
69
|
+
activesupport (= 8.1.2)
|
|
70
|
+
marcel (~> 1.0)
|
|
71
|
+
activesupport (8.1.2)
|
|
72
|
+
base64
|
|
73
|
+
bigdecimal
|
|
74
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
75
|
+
connection_pool (>= 2.2.5)
|
|
76
|
+
drb
|
|
77
|
+
i18n (>= 1.6, < 2)
|
|
78
|
+
json
|
|
79
|
+
logger (>= 1.4.2)
|
|
80
|
+
minitest (>= 5.1)
|
|
81
|
+
securerandom (>= 0.3)
|
|
82
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
83
|
+
uri (>= 0.13.1)
|
|
84
|
+
base64 (0.3.0)
|
|
85
|
+
bigdecimal (4.0.1)
|
|
86
|
+
builder (3.3.0)
|
|
87
|
+
concurrent-ruby (1.3.6)
|
|
88
|
+
connection_pool (3.0.2)
|
|
89
|
+
crass (1.0.6)
|
|
90
|
+
date (3.5.1)
|
|
91
|
+
diff-lcs (1.6.2)
|
|
92
|
+
drb (2.2.3)
|
|
93
|
+
erb (6.0.1)
|
|
94
|
+
erubi (1.13.1)
|
|
95
|
+
globalid (1.3.0)
|
|
96
|
+
activesupport (>= 6.1)
|
|
97
|
+
i18n (1.14.8)
|
|
98
|
+
concurrent-ruby (~> 1.0)
|
|
99
|
+
io-console (0.8.2)
|
|
100
|
+
irb (1.17.0)
|
|
101
|
+
pp (>= 0.6.0)
|
|
102
|
+
prism (>= 1.3.0)
|
|
103
|
+
rdoc (>= 4.0.0)
|
|
104
|
+
reline (>= 0.4.2)
|
|
105
|
+
json (2.18.1)
|
|
106
|
+
logger (1.7.0)
|
|
107
|
+
loofah (2.25.0)
|
|
108
|
+
crass (~> 1.0.2)
|
|
109
|
+
nokogiri (>= 1.12.0)
|
|
110
|
+
mail (2.9.0)
|
|
111
|
+
logger
|
|
112
|
+
mini_mime (>= 0.1.1)
|
|
113
|
+
net-imap
|
|
114
|
+
net-pop
|
|
115
|
+
net-smtp
|
|
116
|
+
marcel (1.1.0)
|
|
117
|
+
mini_mime (1.1.5)
|
|
118
|
+
minitest (6.0.1)
|
|
119
|
+
prism (~> 1.5)
|
|
120
|
+
net-imap (0.6.3)
|
|
121
|
+
date
|
|
122
|
+
net-protocol
|
|
123
|
+
net-pop (0.1.2)
|
|
124
|
+
net-protocol
|
|
125
|
+
net-protocol (0.2.2)
|
|
126
|
+
timeout
|
|
127
|
+
net-smtp (0.5.1)
|
|
128
|
+
net-protocol
|
|
129
|
+
nio4r (2.7.5)
|
|
130
|
+
nokogiri (1.19.1-aarch64-linux-gnu)
|
|
131
|
+
racc (~> 1.4)
|
|
132
|
+
nokogiri (1.19.1-aarch64-linux-musl)
|
|
133
|
+
racc (~> 1.4)
|
|
134
|
+
nokogiri (1.19.1-arm-linux-gnu)
|
|
135
|
+
racc (~> 1.4)
|
|
136
|
+
nokogiri (1.19.1-arm-linux-musl)
|
|
137
|
+
racc (~> 1.4)
|
|
138
|
+
nokogiri (1.19.1-arm64-darwin)
|
|
139
|
+
racc (~> 1.4)
|
|
140
|
+
nokogiri (1.19.1-x86_64-darwin)
|
|
141
|
+
racc (~> 1.4)
|
|
142
|
+
nokogiri (1.19.1-x86_64-linux-gnu)
|
|
143
|
+
racc (~> 1.4)
|
|
144
|
+
nokogiri (1.19.1-x86_64-linux-musl)
|
|
145
|
+
racc (~> 1.4)
|
|
146
|
+
pp (0.6.3)
|
|
147
|
+
prettyprint
|
|
148
|
+
prettyprint (0.2.0)
|
|
149
|
+
prism (1.9.0)
|
|
150
|
+
psych (5.3.1)
|
|
151
|
+
date
|
|
152
|
+
stringio
|
|
153
|
+
racc (1.8.1)
|
|
154
|
+
rack (3.2.5)
|
|
155
|
+
rack-session (2.1.1)
|
|
156
|
+
base64 (>= 0.1.0)
|
|
157
|
+
rack (>= 3.0.0)
|
|
158
|
+
rack-test (2.2.0)
|
|
159
|
+
rack (>= 1.3)
|
|
160
|
+
rackup (2.3.1)
|
|
161
|
+
rack (>= 3)
|
|
162
|
+
rails (8.1.2)
|
|
163
|
+
actioncable (= 8.1.2)
|
|
164
|
+
actionmailbox (= 8.1.2)
|
|
165
|
+
actionmailer (= 8.1.2)
|
|
166
|
+
actionpack (= 8.1.2)
|
|
167
|
+
actiontext (= 8.1.2)
|
|
168
|
+
actionview (= 8.1.2)
|
|
169
|
+
activejob (= 8.1.2)
|
|
170
|
+
activemodel (= 8.1.2)
|
|
171
|
+
activerecord (= 8.1.2)
|
|
172
|
+
activestorage (= 8.1.2)
|
|
173
|
+
activesupport (= 8.1.2)
|
|
174
|
+
bundler (>= 1.15.0)
|
|
175
|
+
railties (= 8.1.2)
|
|
176
|
+
rails-dom-testing (2.3.0)
|
|
177
|
+
activesupport (>= 5.0.0)
|
|
178
|
+
minitest
|
|
179
|
+
nokogiri (>= 1.6)
|
|
180
|
+
rails-html-sanitizer (1.6.2)
|
|
181
|
+
loofah (~> 2.21)
|
|
182
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
183
|
+
railties (8.1.2)
|
|
184
|
+
actionpack (= 8.1.2)
|
|
185
|
+
activesupport (= 8.1.2)
|
|
186
|
+
irb (~> 1.13)
|
|
187
|
+
rackup (>= 1.0.0)
|
|
188
|
+
rake (>= 12.2)
|
|
189
|
+
thor (~> 1.0, >= 1.2.2)
|
|
190
|
+
tsort (>= 0.2)
|
|
191
|
+
zeitwerk (~> 2.6)
|
|
192
|
+
rake (13.3.1)
|
|
193
|
+
rdoc (7.2.0)
|
|
194
|
+
erb
|
|
195
|
+
psych (>= 4.0.0)
|
|
196
|
+
tsort
|
|
197
|
+
reline (0.6.3)
|
|
198
|
+
io-console (~> 0.5)
|
|
199
|
+
rspec (3.13.2)
|
|
200
|
+
rspec-core (~> 3.13.0)
|
|
201
|
+
rspec-expectations (~> 3.13.0)
|
|
202
|
+
rspec-mocks (~> 3.13.0)
|
|
203
|
+
rspec-core (3.13.6)
|
|
204
|
+
rspec-support (~> 3.13.0)
|
|
205
|
+
rspec-expectations (3.13.5)
|
|
206
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
207
|
+
rspec-support (~> 3.13.0)
|
|
208
|
+
rspec-mocks (3.13.7)
|
|
209
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
210
|
+
rspec-support (~> 3.13.0)
|
|
211
|
+
rspec-support (3.13.7)
|
|
212
|
+
securerandom (0.4.1)
|
|
213
|
+
stringio (3.2.0)
|
|
214
|
+
thor (1.5.0)
|
|
215
|
+
timeout (0.6.0)
|
|
216
|
+
tsort (0.2.0)
|
|
217
|
+
tzinfo (2.0.6)
|
|
218
|
+
concurrent-ruby (~> 1.0)
|
|
219
|
+
uri (1.1.1)
|
|
220
|
+
useragent (0.16.11)
|
|
221
|
+
websocket-driver (0.8.0)
|
|
222
|
+
base64
|
|
223
|
+
websocket-extensions (>= 0.1.0)
|
|
224
|
+
websocket-extensions (0.1.5)
|
|
225
|
+
zeitwerk (2.7.4)
|
|
226
|
+
|
|
227
|
+
PLATFORMS
|
|
228
|
+
aarch64-linux-gnu
|
|
229
|
+
aarch64-linux-musl
|
|
230
|
+
arm-linux-gnu
|
|
231
|
+
arm-linux-musl
|
|
232
|
+
arm64-darwin
|
|
233
|
+
x86_64-darwin
|
|
234
|
+
x86_64-linux-gnu
|
|
235
|
+
x86_64-linux-musl
|
|
236
|
+
|
|
237
|
+
DEPENDENCIES
|
|
238
|
+
rspec (~> 3.0)
|
|
239
|
+
webmcp-rails!
|
|
240
|
+
|
|
241
|
+
BUNDLED WITH
|
|
242
|
+
2.7.2
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jesse Waites
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jesse Waites
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# webmcp-rails
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Rails helpers for [WebMCP](https://webmachinelearning.github.io/webmcp/), a W3C standard that lets websites expose HTML forms as structured tools for AI agents.
|
|
6
|
+
|
|
7
|
+
Adds a `webmcp:` option to `form_with`, `form_for`, and all form input helpers.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem "webmcp-rails"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
form_with model: @todo, webmcp: { tool: "addTodo", description: "Add a new todo item", autosubmit: true } do |f|
|
|
19
|
+
f.text_field :title, webmcp: { param_description: "Title of the todo" }
|
|
20
|
+
f.date_field :due_date, webmcp: { param_description: "Due date", param_title: "Due Date" }
|
|
21
|
+
f.submit "Add"
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Renders:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<form toolname="addTodo" tooldescription="Add a new todo item" toolautosubmit action="/todos" method="post">
|
|
29
|
+
<input type="text" name="todo[title]" toolparamdescription="Title of the todo" />
|
|
30
|
+
<input type="date" name="todo[due_date]" toolparamdescription="Due date" toolparamtitle="Due Date" />
|
|
31
|
+
<input type="submit" value="Add" />
|
|
32
|
+
</form>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Form options
|
|
36
|
+
|
|
37
|
+
| Ruby key | HTML attribute | Description |
|
|
38
|
+
|----------|---------------|-------------|
|
|
39
|
+
| `tool:` | `toolname` | Tool name exposed to AI agents |
|
|
40
|
+
| `description:` | `tooldescription` | Human-readable tool description |
|
|
41
|
+
| `autosubmit:` | `toolautosubmit` | Allow agents to submit without confirmation |
|
|
42
|
+
|
|
43
|
+
### Field options
|
|
44
|
+
|
|
45
|
+
| Ruby key | HTML attribute | Description |
|
|
46
|
+
|----------|---------------|-------------|
|
|
47
|
+
| `param_description:` | `toolparamdescription` | Parameter description |
|
|
48
|
+
| `param_title:` | `toolparamtitle` | Display title for the parameter |
|
|
49
|
+
|
|
50
|
+
### Supported field helpers
|
|
51
|
+
|
|
52
|
+
`text_field`, `email_field`, `password_field`, `number_field`, `date_field`, `datetime_field`, `time_field`, `url_field`, `telephone_field`, `search_field`, `text_area`, `color_field`, `range_field`, `hidden_field`, `select`
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
- Ruby >= 3.1
|
|
57
|
+
- Rails >= 7.0
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
data/Rakefile
ADDED
data/lib/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Webmcp
|
|
4
|
+
class FormBuilder < ActionView::Helpers::FormBuilder
|
|
5
|
+
WEBMCP_FIELD_METHODS = %i[
|
|
6
|
+
text_field email_field password_field number_field
|
|
7
|
+
date_field datetime_field time_field url_field
|
|
8
|
+
telephone_field search_field text_area color_field range_field
|
|
9
|
+
].freeze
|
|
10
|
+
|
|
11
|
+
WEBMCP_FIELD_METHODS.each do |method_name|
|
|
12
|
+
define_method(method_name) do |attribute, options = {}|
|
|
13
|
+
options = inject_webmcp_param_attrs(options)
|
|
14
|
+
super(attribute, options)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def hidden_field(method, options = {})
|
|
19
|
+
options = inject_webmcp_param_attrs(options)
|
|
20
|
+
super(method, options)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def select(method, choices = nil, options = {}, html_options = {}, &block)
|
|
24
|
+
webmcp = html_options.delete(:webmcp) || options.delete(:webmcp)
|
|
25
|
+
if webmcp
|
|
26
|
+
html_options[:toolparamdescription] = webmcp[:param_description] if webmcp[:param_description]
|
|
27
|
+
html_options[:toolparamtitle] = webmcp[:param_title] if webmcp[:param_title]
|
|
28
|
+
end
|
|
29
|
+
super(method, choices, options, html_options, &block)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def inject_webmcp_param_attrs(options)
|
|
35
|
+
webmcp = options.delete(:webmcp)
|
|
36
|
+
return options unless webmcp
|
|
37
|
+
|
|
38
|
+
options[:toolparamdescription] = webmcp[:param_description] if webmcp[:param_description]
|
|
39
|
+
options[:toolparamtitle] = webmcp[:param_title] if webmcp[:param_title]
|
|
40
|
+
options
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Webmcp
|
|
4
|
+
module FormHelper
|
|
5
|
+
def form_with(**options, &block)
|
|
6
|
+
options = inject_webmcp_form_attrs(options)
|
|
7
|
+
super(**options, &block)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def form_for(record, options = {}, &block)
|
|
11
|
+
options = inject_webmcp_form_attrs(options)
|
|
12
|
+
super(record, options, &block)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def inject_webmcp_form_attrs(options)
|
|
18
|
+
webmcp = options.delete(:webmcp)
|
|
19
|
+
return options unless webmcp
|
|
20
|
+
|
|
21
|
+
html_attrs = {}
|
|
22
|
+
html_attrs[:toolname] = webmcp[:tool] if webmcp[:tool]
|
|
23
|
+
html_attrs[:tooldescription] = webmcp[:description] if webmcp[:description]
|
|
24
|
+
html_attrs[:toolautosubmit] = "toolautosubmit" if webmcp[:autosubmit]
|
|
25
|
+
|
|
26
|
+
options[:html] = (options[:html] || {}).merge(html_attrs)
|
|
27
|
+
options[:builder] = Webmcp::FormBuilder unless options.key?(:builder)
|
|
28
|
+
options
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/webmcp-rails.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/webmcp/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "webmcp-rails"
|
|
7
|
+
spec.version = Webmcp::VERSION
|
|
8
|
+
spec.authors = ["Jesse Waites"]
|
|
9
|
+
spec.email = ["jesse@example.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "WebMCP attributes for Rails forms"
|
|
12
|
+
spec.description = "Adds WebMCP (W3C) tool attributes to Rails form_with/form_for via a clean webmcp: option"
|
|
13
|
+
spec.homepage = "https://github.com/jessewaites/webmcp-rails"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 3.1.0"
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
19
|
+
|
|
20
|
+
spec.files = Dir.chdir(__dir__) do
|
|
21
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
22
|
+
(File.expand_path(f) == __FILE__) ||
|
|
23
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github])
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
spec.require_paths = ["lib"]
|
|
27
|
+
|
|
28
|
+
spec.add_dependency "rails", ">= 7.0"
|
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
30
|
+
end
|
data/webmcp-rails.jpeg
ADDED
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: webmcp-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jesse Waites
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-02-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '7.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '7.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.0'
|
|
41
|
+
description: 'Adds WebMCP (W3C) tool attributes to Rails form_with/form_for via a
|
|
42
|
+
clean webmcp: option'
|
|
43
|
+
email:
|
|
44
|
+
- jesse@example.com
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- ".DS_Store"
|
|
50
|
+
- Gemfile
|
|
51
|
+
- Gemfile.lock
|
|
52
|
+
- LICENSE
|
|
53
|
+
- LICENSE.txt
|
|
54
|
+
- README.md
|
|
55
|
+
- Rakefile
|
|
56
|
+
- lib/.DS_Store
|
|
57
|
+
- lib/webmcp-rails.rb
|
|
58
|
+
- lib/webmcp/form_builder.rb
|
|
59
|
+
- lib/webmcp/form_helper.rb
|
|
60
|
+
- lib/webmcp/railtie.rb
|
|
61
|
+
- lib/webmcp/version.rb
|
|
62
|
+
- webmcp-rails.gemspec
|
|
63
|
+
- webmcp-rails.jpeg
|
|
64
|
+
homepage: https://github.com/jessewaites/webmcp-rails
|
|
65
|
+
licenses:
|
|
66
|
+
- MIT
|
|
67
|
+
metadata:
|
|
68
|
+
homepage_uri: https://github.com/jessewaites/webmcp-rails
|
|
69
|
+
source_code_uri: https://github.com/jessewaites/webmcp-rails
|
|
70
|
+
post_install_message:
|
|
71
|
+
rdoc_options: []
|
|
72
|
+
require_paths:
|
|
73
|
+
- lib
|
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: 3.1.0
|
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
84
|
+
requirements: []
|
|
85
|
+
rubygems_version: 3.5.16
|
|
86
|
+
signing_key:
|
|
87
|
+
specification_version: 4
|
|
88
|
+
summary: WebMCP attributes for Rails forms
|
|
89
|
+
test_files: []
|