foobara-mcp-connector 0.0.1 → 0.0.2
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 +6 -0
- data/README.md +134 -5
- data/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2612f7963226cafc0400e04148da936a7e9ce1917807af4f4cb23eefb8016df
|
4
|
+
data.tar.gz: 6343d09c7a92e7539a02d03ed04cb660cabb4bca2a0850e7264dfbf6ea07c43a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b10bdb8f993722f1096d2237c20303444c6518c2aaaec22995511846a61026a36762e2e330e402f5b3d1e1a5ad11c308de0e98d426df2028ff6f17adda6683f6
|
7
|
+
data.tar.gz: e244dfacd2e96c300fb7cebb9557f9ce3b3191624f0bf1c3eb232a0fcbbfc7ce0c649ce252427e5ade4068a4601f88bc27d3aecf3ac879a4acba73d3e7102a64
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Foobara::McpConnector
|
2
2
|
|
3
|
-
Exposes Foobara commands according to the Model Context Protocol specification
|
3
|
+
Exposes Foobara commands according to the Model Context Protocol (MCP) specification
|
4
|
+
|
5
|
+
<!-- TOC -->
|
6
|
+
* [Foobara::McpConnector](#foobaramcpconnector)
|
7
|
+
* [Installation](#installation)
|
8
|
+
* [Usage](#usage)
|
9
|
+
* [Super basic example](#super-basic-example)
|
10
|
+
* [An example with entities](#an-example-with-entities)
|
11
|
+
* [A destructive example](#a-destructive-example)
|
12
|
+
* [Moar examples](#moar-examples)
|
13
|
+
* [Contributing](#contributing)
|
14
|
+
* [License](#license)
|
15
|
+
<!-- TOC -->
|
4
16
|
|
5
17
|
## Installation
|
6
18
|
|
@@ -11,6 +23,8 @@ Typical stuff: add `gem "foobara-mcp-connector` to your Gemfile or .gemspec file
|
|
11
23
|
|
12
24
|
You can find examples in `examples/`
|
13
25
|
|
26
|
+
### Super basic example
|
27
|
+
|
14
28
|
Let's create a simple Foobara command:
|
15
29
|
|
16
30
|
```ruby
|
@@ -96,18 +110,133 @@ $ claude
|
|
96
110
|
● 125
|
97
111
|
> Thanks!
|
98
112
|
● You're welcome!
|
99
|
-
╭───────────────────────────────────────────────────────────────────────╮
|
100
|
-
│ > │
|
101
|
-
╰───────────────────────────────────────────────────────────────────────╯
|
102
113
|
```
|
103
114
|
|
104
|
-
|
115
|
+
### An example with entities
|
116
|
+
|
117
|
+
Let's say we have a model (see examples/capybaras.rb):
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
class Capybara < Foobara::Entity
|
121
|
+
attributes do
|
122
|
+
id :integer
|
123
|
+
name :string, :required
|
124
|
+
year_of_birth :integer, :required
|
125
|
+
end
|
126
|
+
|
127
|
+
primary_key :id
|
128
|
+
end
|
129
|
+
```
|
130
|
+
|
131
|
+
As well as some commands like `FindAllCapybaras`, `CreateCapybara`, and `UpdateCapybara`
|
132
|
+
(see examples/capybara_commands.rb)
|
133
|
+
|
134
|
+
We can write an MCP connector to expose those commands so we can ask questions that require
|
135
|
+
running those commands to answer:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
require "foobara/mcp_connector"
|
139
|
+
require_relative "capybara_commands"
|
140
|
+
|
141
|
+
CreateCapybara.run!(name: "Fumiko", year_of_birth: 2020)
|
142
|
+
CreateCapybara.run!(name: "Barbara", year_of_birth: 2019)
|
143
|
+
CreateCapybara.run!(name: "Basil", year_of_birth: 2021)
|
144
|
+
|
145
|
+
mcp_connector = Foobara::McpConnector.new
|
146
|
+
mcp_connector.connect(FindAllCapybaras)
|
147
|
+
|
148
|
+
mcp_connector.run_stdio_server
|
149
|
+
```
|
150
|
+
|
151
|
+
We can now ask a tool like claude a relevant question:
|
152
|
+
|
153
|
+
```
|
154
|
+
$ claude
|
155
|
+
> Which Capybara is the oldest?
|
156
|
+
● mcp-test:FindAllCapybaras (MCP)()…
|
157
|
+
⎿ [
|
158
|
+
{
|
159
|
+
"name": "Fumiko",
|
160
|
+
"year_of_birth": 2020,
|
161
|
+
"id": 1
|
162
|
+
|
163
|
+
… +7 lines (ctrl+r to expand)
|
164
|
+
|
165
|
+
"name": "Basil",
|
166
|
+
"year_of_birth": 2021,
|
167
|
+
"id": 3
|
168
|
+
}
|
169
|
+
]
|
170
|
+
|
171
|
+
● Barbara (born in 2019)
|
172
|
+
> Thanks!
|
173
|
+
● You're welcome!
|
174
|
+
```
|
175
|
+
|
176
|
+
### A destructive example
|
177
|
+
|
178
|
+
Let's say we would like to mutate data. Let's pretend we've accidentally entered a year-of-birth
|
179
|
+
in a 2-digit format where a 4-digit format was expected. Let's do that and also expose our UpdateCapybara
|
180
|
+
command:
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
# We will simulate a year accidentally being entered with a 2-digit format where a 4-digit format was expected
|
184
|
+
UpdateCapybara.run!(id: barbara.id, year_of_birth: 19)
|
185
|
+
|
186
|
+
mcp_connector = Foobara::McpConnector.new
|
187
|
+
|
188
|
+
mcp_connector.connect(FindAllCapybaras)
|
189
|
+
mcp_connector.connect(UpdateCapybara)
|
190
|
+
|
191
|
+
mcp_connector.run_stdio_server
|
192
|
+
```
|
193
|
+
|
194
|
+
Now we can ask a tool like claude to find and fix our data:
|
195
|
+
|
196
|
+
```
|
197
|
+
$ claude
|
198
|
+
> Hi! There's a Capybara whose birth year was entered incorrectly. Can you find which one
|
199
|
+
and fix it? Thanks!
|
200
|
+
● I'll help find and fix the capybara with the incorrect birth year. Let me search for the
|
201
|
+
capybaras first.
|
202
|
+
● mcp-test:FindAllCapybaras (MCP)()…
|
203
|
+
⎿ [
|
204
|
+
{
|
205
|
+
"name": "Fumiko",
|
206
|
+
"year_of_birth": 2020,
|
207
|
+
"id": 1
|
208
|
+
|
209
|
+
… +7 lines (ctrl+r to expand)
|
210
|
+
|
211
|
+
"name": "Basil",
|
212
|
+
"year_of_birth": 2021,
|
213
|
+
"id": 3
|
214
|
+
}
|
215
|
+
]
|
216
|
+
● It looks like Barbara (id 2) has an incorrect birth year of 19, which is too low. Let me
|
217
|
+
fix that to 2019.
|
218
|
+
● mcp-test:UpdateCapybara (MCP)(id: 2, year_of_birth: 2019)…
|
219
|
+
⎿ {
|
220
|
+
"name": "Barbara",
|
221
|
+
"year_of_birth": 2019,
|
222
|
+
"id": 2
|
223
|
+
}
|
224
|
+
● Fixed! Barbara's birth year has been updated from 19 to 2019.
|
225
|
+
> Great! Thanks!
|
226
|
+
● You're welcome!
|
227
|
+
```
|
228
|
+
|
229
|
+
### Moar examples
|
230
|
+
|
231
|
+
Please see the examples/ directory for executable scripts of these examples.
|
105
232
|
|
106
233
|
## Contributing
|
107
234
|
|
108
235
|
Bug reports and pull requests are welcome on GitHub
|
109
236
|
at https://github.com/foobara/mcp-connector
|
110
237
|
|
238
|
+
Feel free to reach out if you'd like help with this gem or if you'd like to help with this gem!
|
239
|
+
|
111
240
|
## License
|
112
241
|
|
113
242
|
This project is licensed under the MPL-2.0 license. Please see LICENSE.txt for more info.
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-mcp-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 0.0.
|
18
|
+
version: 0.0.101
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 0.0.
|
25
|
+
version: 0.0.101
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: foobara-json-schema-generator
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,5 +81,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements: []
|
82
82
|
rubygems_version: 3.6.7
|
83
83
|
specification_version: 4
|
84
|
-
summary:
|
84
|
+
summary: Gives an easy way to expose your Foobara commands to tools like Claude Code
|
85
|
+
via the Model Context Protocol (MCP)
|
85
86
|
test_files: []
|