Skip to content

Commit b2df2cd

Browse files
committed
[Feature] MCP tool get_install_command_for_project
1 parent b097675 commit b2df2cd

5 files changed

Lines changed: 44 additions & 2 deletions

File tree

docs/app/views/docs/mcp.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ def tools_list
146146
["view_items_in_registries", "Returns full source files and dependencies."],
147147
["get_item_examples_from_registries", "Returns code examples per component."],
148148
["get_add_command_for_items", "Returns a validated rails g ruby_ui:component … command."],
149-
["get_audit_checklist", "Returns a post-install verification checklist."]
149+
["get_audit_checklist", "Returns a post-install verification checklist."],
150+
["get_install_command_for_project", "Returns commands to bootstrap ruby_ui in a fresh Rails project."]
150151
]
151152
end
152153
end

mcp/lib/ruby_ui/mcp/server.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
require "ruby_ui/mcp/tools/get_item_examples_from_registries"
1111
require "ruby_ui/mcp/tools/get_add_command_for_items"
1212
require "ruby_ui/mcp/tools/get_audit_checklist"
13+
require "ruby_ui/mcp/tools/get_install_command_for_project"
1314

1415
module RubyUI
1516
module MCP
@@ -71,6 +72,12 @@ class Server
7172
klass: Tools::GetAuditChecklist,
7273
description: "Return a post-install verification checklist.",
7374
input_schema: {properties: {}}
75+
},
76+
{
77+
name: "get_install_command_for_project",
78+
klass: Tools::GetInstallCommandForProject,
79+
description: "Return the commands to bootstrap ruby_ui in a fresh Rails project (gem install + ruby_ui:install generator).",
80+
input_schema: {properties: {}}
7481
}
7582
].freeze
7683

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
require "ruby_ui/mcp/tools/base"
4+
5+
module RubyUI
6+
module MCP
7+
module Tools
8+
class GetInstallCommandForProject < Base
9+
def call(**)
10+
{
11+
steps: [
12+
{title: "Add the gem", command: "bundle add ruby_ui"},
13+
{title: "Run the installer", command: "bin/rails g ruby_ui:install"},
14+
{title: "Add a component", command: "bin/rails g ruby_ui:component Button"}
15+
],
16+
note: "Use `get_add_command_for_items` once you know which components to install."
17+
}
18+
end
19+
end
20+
end
21+
end
22+
end

mcp/test/server_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ def setup
88
@registry = RubyUI::MCP::Registry.load(TestSupport::FIXTURE_PATH)
99
end
1010

11-
def test_builds_with_seven_tools
11+
def test_builds_with_eight_tools
1212
builder = RubyUI::MCP::Server.new(registry: @registry)
1313
names = builder.tool_classes.map(&:name_value).sort
1414
expected = %w[
1515
get_add_command_for_items
1616
get_audit_checklist
17+
get_install_command_for_project
1718
get_item_examples_from_registries
1819
get_project_registries
1920
list_items_in_registries
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require "test_helper"
2+
require "ruby_ui/mcp/tools/get_install_command_for_project"
3+
4+
class InstallCommandToolTest < Minitest::Test
5+
def test_returns_install_steps
6+
tool = RubyUI::MCP::Tools::GetInstallCommandForProject.new(registry: nil)
7+
result = tool.call
8+
assert_equal 3, result[:steps].length
9+
assert_match(/bundle add ruby_ui/, result[:steps].first[:command])
10+
end
11+
end

0 commit comments

Comments
 (0)