|
1 | 1 | # ModelContextProtocol |
2 | 2 |
|
3 | | - |
| 3 | +This gem enables the Model Context Protocol for Thor command-line applications. |
4 | 4 |
|
5 | 5 | ## Installation |
6 | 6 |
|
7 | | -TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. |
8 | | - |
9 | 7 | Install the gem and add to the application's Gemfile by executing: |
10 | 8 |
|
11 | 9 | ```bash |
12 | | -bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 10 | +bundle add modelcontextprotocol |
13 | 11 | ``` |
14 | 12 |
|
15 | 13 | If bundler is not being used to manage dependencies, install the gem by executing: |
16 | 14 |
|
17 | 15 | ```bash |
18 | | -gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 16 | +gem install modelcontextprotocol |
19 | 17 | ``` |
20 | 18 |
|
21 | 19 | ## Usage |
22 | 20 |
|
23 | | -TODO: Write usage instructions here |
| 21 | +**THIS DOES NOT WORK YET AND IS WHAT THIS PROJECT ASPIRES TO** |
| 22 | + |
| 23 | +Include the `ModelContextProtocol::Thor` in a Thor command-line application to enable model context protocol for the CLI: |
| 24 | + |
| 25 | +```ruby |
| 26 | +class MyCLI < Thor |
| 27 | + # Enables MCP for the CLI |
| 28 | + include ModelContextProtocol::Thor |
| 29 | + |
| 30 | + desc "hello GREETING", "Say hello" |
| 31 | + def hello(name) |
| 32 | + puts "Hello #{name}" |
| 33 | + end |
| 34 | +end |
| 35 | +``` |
| 36 | + |
| 37 | +Then boot the model context server via: |
| 38 | + |
| 39 | +```ruby |
| 40 | +MyCLI.mcp.start |
| 41 | +``` |
| 42 | + |
| 43 | +This boots a model context protocol server that connects to your tools that support MCP. |
| 44 | + |
| 45 | +### Terminalwire |
| 46 | + |
| 47 | +If you'd like to integrate your Rails SaaS to AI development tools, you maybe install Terminalwire Rails server and include it in the CLI. |
| 48 | + |
| 49 | +```ruby |
| 50 | +class MyCLI < Thor |
| 51 | + # Enable streaming from the server to the Terminalwire thin client. |
| 52 | + include Terminalwire::Thor |
| 53 | + |
| 54 | + # Enables MCP for the CLI |
| 55 | + include ModelContextProtocol::Thor |
| 56 | + |
| 57 | + desc "hello GREETING", "Say hello" |
| 58 | + def hello(name) |
| 59 | + puts "Hello #{name}" |
| 60 | + end |
| 61 | +end |
| 62 | +``` |
| 63 | + |
| 64 | +You'll then need to [create a Terminalwire distribution](https://terminalwire.com/docs/rails/distribution) and provide your users with the one-liner curl installer: |
| 65 | + |
| 66 | +```sh |
| 67 | +$ curl https://my-app.terminalwire.sh | bash |
| 68 | +``` |
| 69 | + |
| 70 | +Your users then boot the MCP server via `my-app mcp` to integrate with their MCP client. |
24 | 71 |
|
25 | 72 | ## Development |
26 | 73 |
|
|
0 commit comments