mcp-on-rails 0.1.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9de4dca8095e1020e24bf8f70df4a28f148b2cc85ecf2768a556722da1292132
4
- data.tar.gz: c553494738ae79d5ac4409021a2f1ddd69caf1506e47d38c42e93add47c9f106
3
+ metadata.gz: 93a524f211df8a2ea314d0e463000112efc05524261a5b89aadcf00b5edb63fd
4
+ data.tar.gz: 89a7464c66e7d687ee6769aad56acbfd3681577867bec8a558b7e727b9d472b1
5
5
  SHA512:
6
- metadata.gz: cca8f6b8ebcdfe8ff07e50af3008d0aa50208225b127d5edddc3cb7b86b03329dcd36ae897ff079d387e2b4c7ef104932a6e5dca22b1e7da8380d029fc768ed7
7
- data.tar.gz: 7c120a4dff702bdb99be86fea3d02e02f0832bdae3e9b008a9397510a4ff7b4cff1f33319e0f038401caa007681a9f7e322c84c27e77f4b6dce4d5a1ce27a4d7
6
+ metadata.gz: c82beedcc2128dabd888fea3d3715e7070ee5a1a75f0c36296b32ead29ced9ffca57bda8026e5b487089b820aacad83462565b6daf0a04f7717e0b5fc04cdfd5
7
+ data.tar.gz: ac41da827cadf39124388a25842afea4aa64d7c90dd1d5ab5855f67accb6b6d2d7474a6978982b5a934e9a152ee7ba306584da14cf74819ca6d0d6248c92bf12
data/README.md CHANGED
@@ -80,20 +80,35 @@ your-rails-project/
80
80
  └── mcp-setup # Project setup script
81
81
  ```
82
82
 
83
- ## MCP Client Configuration
83
+ ## Using with AI Assistants
84
84
 
85
- ### VS Code with GitHub Copilot
85
+ ### GitHub Copilot (VS Code)
86
86
 
87
- 1. Install the MCP extension for VS Code
88
- 2. Configure your workspace settings:
87
+ GitHub Copilot doesn't directly read MCP configuration files, but you can leverage the specialized prompts by:
89
88
 
90
- ```json
91
- {
92
- "mcp.configPath": ".mcp-on-rails/mcp-config.yml"
93
- }
94
- ```
89
+ 1. **Reference prompts in your requests**:
90
+ ```
91
+ "Please check .mcp-on-rails/prompts/models.md for Rails model best practices and help me with this ActiveRecord model"
92
+ ```
93
+
94
+ 2. **Use context-aware requests**:
95
+ ```
96
+ "Looking at .mcp-on-rails/prompts/controllers.md, help me implement this API endpoint"
97
+ ```
98
+
99
+ 3. **Add to VS Code workspace settings** (optional):
100
+ ```json
101
+ {
102
+ "files.associations": {
103
+ ".mcp-on-rails/**/*.md": "markdown"
104
+ },
105
+ "explorer.fileNesting.patterns": {
106
+ ".mcp-on-rails": "mcp-config.yml,context.md"
107
+ }
108
+ }
109
+ ```
95
110
 
96
- ### Claude Desktop
111
+ ### Claude Desktop (Native MCP Support)
97
112
 
98
113
  Add to your Claude Desktop configuration:
99
114
 
@@ -110,9 +125,13 @@ Add to your Claude Desktop configuration:
110
125
  }
111
126
  ```
112
127
 
113
- ### Other MCP Clients
128
+ ### Other AI Assistants
114
129
 
115
- The generated `mcp-config.yml` is compatible with most MCP clients. Refer to your client's documentation for specific configuration steps.
130
+ For any AI assistant, you can reference the specialized prompts manually:
131
+ - **Models**: "Use .mcp-on-rails/prompts/models.md as context"
132
+ - **Controllers**: "Reference .mcp-on-rails/prompts/controllers.md"
133
+ - **Views**: "Check .mcp-on-rails/prompts/views.md for guidance"
134
+ - **Tests**: "Follow .mcp-on-rails/prompts/tests.md best practices"
116
135
 
117
136
  ## Context Areas
118
137
 
@@ -6,6 +6,8 @@ require "fileutils"
6
6
  module Mcp
7
7
  module On
8
8
  module Rails
9
+ # Generator class for creating MCP configuration files and directories
10
+ # Handles project setup with templates and customization
9
11
  class Generator
10
12
  attr_reader :project_name, :project_path
11
13
 
@@ -19,9 +21,11 @@ module Mcp
19
21
  copy_prompts
20
22
  generate_config_file
21
23
  copy_context_file
24
+ create_copilot_instructions
22
25
  create_executable
23
26
  puts "✅ MCP on Rails setup completed for '#{project_name}'"
24
- puts "📁 Files created in: #{File.join(project_path, '.mcp-on-rails')}"
27
+ puts "📁 Files created in: #{File.join(project_path, ".mcp-on-rails")}"
28
+ puts "📋 GitHub Copilot instructions: #{File.join(project_path, ".github/copilot-instructions.md")}"
25
29
  puts "🚀 Run: ./bin/mcp-setup to configure your project"
26
30
  end
27
31
 
@@ -41,10 +45,10 @@ module Mcp
41
45
  def generate_config_file
42
46
  template_file = File.join(templates_path, "mcp-config.yml.erb")
43
47
  target_file = File.join(project_path, ".mcp-on-rails", "mcp-config.yml")
44
-
48
+
45
49
  template = ERB.new(File.read(template_file))
46
50
  content = template.result(binding)
47
-
51
+
48
52
  File.write(target_file, content)
49
53
  end
50
54
 
@@ -54,14 +58,30 @@ module Mcp
54
58
  FileUtils.cp(source_file, target_file)
55
59
  end
56
60
 
61
+ def create_copilot_instructions
62
+ github_dir = File.join(project_path, ".github")
63
+ FileUtils.mkdir_p(github_dir)
64
+
65
+ source_file = File.join(templates_path, "copilot-instructions.md")
66
+ target_file = File.join(github_dir, "copilot-instructions.md")
67
+ FileUtils.cp(source_file, target_file)
68
+ end
69
+
57
70
  def create_executable
58
71
  bin_dir = File.join(project_path, "bin")
59
72
  FileUtils.mkdir_p(bin_dir)
60
-
61
- executable_content = <<~SCRIPT
73
+
74
+ executable_content = build_executable_content
75
+ executable_path = File.join(bin_dir, "mcp-setup")
76
+ File.write(executable_path, executable_content)
77
+ FileUtils.chmod(0o755, executable_path)
78
+ end
79
+
80
+ def build_executable_content
81
+ <<~SCRIPT
62
82
  #!/usr/bin/env ruby
63
83
  # frozen_string_literal: true
64
-
84
+
65
85
  puts "🔧 Setting up MCP on Rails for #{project_name}"
66
86
  puts "📋 Configuration files are ready in .mcp-on-rails/"
67
87
  puts ""
@@ -70,10 +90,6 @@ module Mcp
70
90
  puts "2. Use the prompts in .mcp-on-rails/prompts/ for context-aware AI assistance"
71
91
  puts "3. Customize the configuration as needed for your project"
72
92
  SCRIPT
73
-
74
- executable_path = File.join(bin_dir, "mcp-setup")
75
- File.write(executable_path, executable_content)
76
- FileUtils.chmod(0o755, executable_path)
77
93
  end
78
94
 
79
95
  def templates_path
@@ -0,0 +1,265 @@
1
+ # GitHub Copilot Instructions for MCP on Rails
2
+
3
+ You are working with a Rails project that has been configured with MCP on Rails, providing specialized AI assistance for Rails development. This project follows the principles of claude-on-rails but is adapted for GitHub Copilot usage.
4
+
5
+ ## Project Context
6
+
7
+ This Rails project uses **MCP on Rails** configuration located in `.mcp-on-rails/` directory. Always reference the specialized prompts and context when helping with development tasks.
8
+
9
+ ### Key Directories and Their Purpose:
10
+ - **`.mcp-on-rails/prompts/`** - Contains specialized prompts for different Rails components
11
+ - **`.mcp-on-rails/context.md`** - Project-specific context and information
12
+ - **`.mcp-on-rails/mcp-config.yml`** - MCP server configuration
13
+ - **`.mcp-on-rails/specs/`** - Feature specifications and task management
14
+
15
+ ## Pre-Development Workflow
16
+
17
+ ### 📋 **MANDATORY: Specification Creation**
18
+ **Before starting ANY development task**, you MUST create a comprehensive specification in `.mcp-on-rails/specs/` directory:
19
+
20
+ 1. **Create Project Subdirectory**:
21
+ ```
22
+ .mcp-on-rails/specs/[feature-name]/
23
+ ```
24
+
25
+ 2. **Required Documentation Files**:
26
+ - **`requirement.md`** - Detailed requirements and acceptance criteria
27
+ - **`design.md`** - Technical design, architecture decisions, and implementation approach
28
+ - **MANDATORY**: Must query `rails-mcp-server` for latest Rails documentation before writing
29
+ - **MANDATORY**: Include version-specific Rails patterns and best practices
30
+ - **MANDATORY**: Reference current Rails guides for security, performance, and conventions
31
+ - **`tasks.md`** - Step-by-step task breakdown with progress tracking
32
+
33
+ 3. **Task Management Process**:
34
+ - Assign appropriate specialist prompts to each task
35
+ - Update `tasks.md` after completing each step
36
+ - Mark completed tasks with ✅ and timestamp
37
+ - Document any design changes or decisions
38
+
39
+ ### 🔍 **Rails Documentation Integration**
40
+ **Always leverage `rails-mcp-server` for up-to-date Rails guidance**:
41
+
42
+ 1. **During design.md Creation** (MANDATORY):
43
+ - Query latest Rails documentation for current version patterns
44
+ - Verify API methods and their parameters
45
+ - Check for deprecated methods and modern alternatives
46
+ - Reference security best practices and performance guidelines
47
+ - Ensure design follows current Rails conventions
48
+
49
+ 2. **Before Implementation**: Query latest Rails documentation for:
50
+ - Version-specific syntax and best practices
51
+ - New features and deprecated methods
52
+ - Security considerations and performance optimizations
53
+
54
+ 3. **Stay Current**: Use MCP server to:
55
+ - Verify Rails conventions for current version
56
+ - Check for latest gem compatibility
57
+ - Reference official Rails guides and API documentation
58
+ - Ensure security best practices compliance
59
+
60
+ **Example Specification Structure**:
61
+ ```
62
+ .mcp-on-rails/specs/user-authentication/
63
+ ├── requirement.md # What needs to be built
64
+ ├── design.md # How it will be built
65
+ └── tasks.md # Step-by-step implementation plan
66
+ ```
67
+
68
+ ## Specialized Agent Roles
69
+
70
+ When working on different parts of the Rails application, adopt the appropriate specialist role and reference the corresponding prompt file:
71
+
72
+ ### 🏗️ **Architect Role** (Overall coordination)
73
+ **When to use**: Project-wide decisions, architecture planning, feature coordination
74
+ **Reference**: `.mcp-on-rails/prompts/architect.md`
75
+ **Focus**:
76
+ - Coordinate implementation across multiple components
77
+ - Make high-level architectural decisions
78
+ - Ensure consistency across the application
79
+ - Plan complex features that span multiple areas
80
+
81
+ ### 🗄️ **Models Specialist** (Data layer)
82
+ **When working in**: `app/models/`, `db/migrate/`, database-related tasks
83
+ **Reference**: `.mcp-on-rails/prompts/models.md`
84
+ **Focus**:
85
+ - ActiveRecord models, associations, validations
86
+ - Database migrations and schema design
87
+ - Query optimization and performance
88
+ - Data integrity and constraints
89
+
90
+ ### 🎮 **Controllers Specialist** (HTTP handling)
91
+ **When working in**: `app/controllers/`, routing, APIs
92
+ **Reference**: `.mcp-on-rails/prompts/controllers.md`
93
+ **Focus**:
94
+ - RESTful controllers and routing
95
+ - Authentication and authorization
96
+ - API design and implementation
97
+ - Request/response handling
98
+
99
+ ### 🎨 **Views Specialist** (Frontend/UI)
100
+ **When working in**: `app/views/`, `app/assets/`, frontend components
101
+ **Reference**: `.mcp-on-rails/prompts/views.md`
102
+ **Focus**:
103
+ - ERB templates and layouts
104
+ - HTML/CSS styling and responsive design
105
+ - Asset pipeline management
106
+ - UI components and partials
107
+ - **MANDATORY**: Playwright MCP testing for view validation and iterative refinement
108
+
109
+ ### ⚡ **Stimulus Specialist** (JavaScript/Interactivity)
110
+ **When working in**: `app/javascript/`, Stimulus controllers, Turbo features
111
+ **Reference**: `.mcp-on-rails/prompts/stimulus.md`
112
+ **Focus**:
113
+ - Stimulus.js controllers and targets
114
+ - Turbo Drive, Frames, and Streams
115
+ - JavaScript behavior and DOM manipulation
116
+ - Progressive enhancement
117
+
118
+ ### 🔧 **Jobs Specialist** (Background processing)
119
+ **When working in**: `app/jobs/`, background tasks, queues
120
+ **Reference**: `.mcp-on-rails/prompts/jobs.md`
121
+ **Focus**:
122
+ - ActiveJob background processing
123
+ - Queue management and scheduling
124
+ - Async task implementation
125
+ - Performance optimization for background work
126
+
127
+ ### 🧪 **Tests Specialist** (Quality assurance)
128
+ **When working in**: `test/`, `spec/`, testing-related tasks
129
+ **Reference**: `.mcp-on-rails/prompts/tests.md`
130
+ **Focus**:
131
+ - Comprehensive test coverage
132
+ - Test-driven development (TDD)
133
+ - Factory and fixture management
134
+ - Integration and system tests
135
+
136
+ ### 🚀 **DevOps Specialist** (Infrastructure/Deployment)
137
+ **When working in**: `config/`, deployment, infrastructure
138
+ **Reference**: `.mcp-on-rails/prompts/devops.md`
139
+ **Focus**:
140
+ - Application configuration and environments
141
+ - Docker, CI/CD, and deployment strategies
142
+ - Performance monitoring and optimization
143
+ - Security and infrastructure concerns
144
+
145
+ ## How to Work with This Project
146
+
147
+ ### 1. **Always Check Context First**
148
+ Before starting any task, review:
149
+ ```
150
+ - .mcp-on-rails/context.md for project-specific information
151
+ - .mcp-on-rails/prompts/[relevant-area].md for specialized guidance
152
+ ```
153
+
154
+ ### 2. **Multi-Agent Coordination**
155
+ For complex features that span multiple areas:
156
+ 1. Start with the **Architect** role to plan the implementation
157
+ 2. Break down tasks for appropriate specialists
158
+ 3. Ensure consistency across all components
159
+ 4. Always include comprehensive tests
160
+
161
+ ### 3. **Rails Best Practices**
162
+ Always follow:
163
+ - Rails conventions and naming patterns
164
+ - RESTful design principles
165
+ - Security best practices
166
+ - Performance optimization
167
+ - Comprehensive test coverage
168
+
169
+ ### 4. **Code Quality Standards**
170
+ - Write clean, readable, and maintainable code
171
+ - Follow Ruby and Rails style guides
172
+ - Include proper documentation and comments
173
+ - Implement error handling and edge cases
174
+ - Consider performance implications
175
+
176
+ ## Implementation Workflow
177
+
178
+ ### For New Features:
179
+ 1. **📋 Specification** (MANDATORY): Create comprehensive specs in `.mcp-on-rails/specs/[feature-name]/`
180
+ - Write `requirement.md` with detailed requirements and acceptance criteria
181
+ - Create `design.md` with technical approach and architecture decisions
182
+ - Draft `tasks.md` with step-by-step implementation plan
183
+ 2. **🔍 Research** (Rails MCP): Query latest Rails documentation for version-specific best practices
184
+ 3. **🏗️ Plan** (Architect): Understand requirements and design approach
185
+ 4. **🗄️ Model** (Models): Design data structure and relationships
186
+ 5. **🎮 Route & Control** (Controllers): Implement HTTP endpoints
187
+ 6. **🎨 Present** (Views): Create user interface
188
+ - **MANDATORY**: Use `playwright` MCP for view testing and validation
189
+ - Test UI rendering and interactions iteratively until properly displayed
190
+ - Verify responsive design and cross-browser compatibility
191
+ - Fix visual and functional issues identified through Playwright testing
192
+ 7. **⚡ Enhance** (Stimulus): Add interactive behavior
193
+ 8. **🔧 Process** (Jobs): Handle background tasks if needed
194
+ 9. **🧪 Test** (Tests): Ensure comprehensive coverage
195
+ 10. **🚀 Deploy** (DevOps): Configure for production
196
+ 11. **📝 Update**: Mark tasks complete in `tasks.md` with ✅ and timestamp
197
+
198
+ ### For Bug Fixes:
199
+ 1. **📋 Document** (MANDATORY): Create spec directory for the fix with problem analysis
200
+ 2. **🔍 Research**: Use Rails MCP server for latest debugging techniques and solutions
201
+ 3. **🧩 Diagnose**: Identify the problem area
202
+ 4. **📚 Reference**: Check relevant specialist prompt
203
+ 5. **🔧 Fix**: Implement solution following best practices
204
+ 6. **🧪 Test**: Verify fix with appropriate tests
205
+ 7. **📝 Document**: Update specs and relevant documentation
206
+
207
+ ### For Refactoring:
208
+ 1. **📋 Plan** (MANDATORY): Create refactoring spec with current state analysis
209
+ 2. **🔍 Research**: Query Rails MCP for modern patterns and best practices
210
+ 3. **🧐 Analyze**: Understand current implementation
211
+ 4. **🎯 Design**: Plan improved approach with clear goals
212
+ 5. **🔄 Refactor**: Implement changes systematically
213
+ 6. **🧪 Test**: Ensure no regression
214
+ 7. **⚡ Optimize**: Improve performance where applicable
215
+ 8. **📝 Complete**: Update specs with final implementation details
216
+
217
+ ## Special Considerations
218
+
219
+ ### Security First
220
+ - Always validate user input
221
+ - Implement proper authentication/authorization
222
+ - Follow Rails security guidelines
223
+ - Use strong parameters and CSRF protection
224
+
225
+ ### Performance Matters
226
+ - Optimize database queries (avoid N+1)
227
+ - Use appropriate caching strategies
228
+ - Monitor and profile performance
229
+ - Consider background processing for heavy tasks
230
+
231
+ ### Test Everything
232
+ - Write tests before implementing features (TDD)
233
+ - Ensure high test coverage
234
+ - Include integration and system tests
235
+ - Test edge cases and error conditions
236
+ - **MANDATORY for Views**: Use `playwright` MCP for comprehensive view testing
237
+ - Test UI components and interactions until properly rendered
238
+ - Verify responsive design across different viewports
239
+ - Validate accessibility and user experience
240
+ - Iterate testing and fixes until all visual elements work correctly
241
+
242
+ ## Quick Reference Commands
243
+
244
+ When asked to help with Rails development:
245
+
246
+ 1. **📋 CREATE SPECS FIRST** (MANDATORY): Always start with `.mcp-on-rails/specs/[feature-name]/` directory creation
247
+ 2. **🔍 Query Rails MCP**: Use `rails-mcp-server` to get latest Rails documentation and best practices
248
+ 3. **🎯 Identify the area** of work (models, controllers, views, etc.)
249
+ 4. **📚 Reference the appropriate prompt**: "Let me check .mcp-on-rails/prompts/[area].md for best practices"
250
+ 5. **🔧 Apply specialist knowledge** for that area with current Rails version considerations
251
+ 6. **🔗 Consider dependencies** and coordination with other areas
252
+ 7. **🧪 Ensure comprehensive testing** and documentation
253
+ 8. **📝 Update progress**: Mark completed tasks in `tasks.md` throughout development
254
+
255
+ ### Mandatory Pre-Development Checklist:
256
+ - [ ] Created `.mcp-on-rails/specs/[feature-name]/` directory
257
+ - [ ] Written comprehensive `requirement.md`
258
+ - [ ] **MANDATORY**: Queried `rails-mcp-server` for latest Rails documentation and patterns
259
+ - [ ] **MANDATORY**: Incorporated current Rails version best practices into `design.md`
260
+ - [ ] Designed technical approach in `design.md` with up-to-date Rails guidance
261
+ - [ ] Planned step-by-step tasks in `tasks.md`
262
+ - [ ] Assigned appropriate specialist prompts to each task
263
+ - [ ] **For View Components**: Prepared to use `playwright` MCP for iterative testing and refinement
264
+
265
+ Remember: You are part of a coordinated development team with a structured specification-driven approach. Always create comprehensive documentation before coding, leverage the Rails MCP server for up-to-date guidance, and use Playwright MCP for thorough view testing. Maintain consistency with Rails conventions and project standards.
@@ -3,7 +3,7 @@
3
3
  module Mcp
4
4
  module On
5
5
  module Rails
6
- VERSION = "0.1.0"
6
+ VERSION = "0.3.0"
7
7
  end
8
8
  end
9
9
  end
data/lib/mcp/on/rails.rb CHANGED
@@ -5,6 +5,8 @@ require_relative "rails/generator"
5
5
 
6
6
  module Mcp
7
7
  module On
8
+ # Main module for MCP on Rails gem
9
+ # Provides setup functionality for Rails projects with MCP configuration
8
10
  module Rails
9
11
  class Error < StandardError; end
10
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcp-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCoder
@@ -27,6 +27,7 @@ files:
27
27
  - lib/mcp/on/rails.rb
28
28
  - lib/mcp/on/rails/generator.rb
29
29
  - lib/mcp/on/rails/templates/context.md
30
+ - lib/mcp/on/rails/templates/copilot-instructions.md
30
31
  - lib/mcp/on/rails/templates/mcp-config.yml.erb
31
32
  - lib/mcp/on/rails/templates/prompts/api.md
32
33
  - lib/mcp/on/rails/templates/prompts/architect.md