Skip to content

Commit 11cb72f

Browse files
committed
Working MCP
1 parent 4ee1afa commit 11cb72f

37 files changed

+1383
-48
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
/spec/reports/
88
/tmp/
99

10+
/vendor/
11+
1012
# rspec failure tracking
1113
.rspec_status

Gemfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# frozen_string_literal: true
22

3-
source "https://rubygems.org"
3+
source 'https://rubygems.org'
44

55
# Specify your gem's dependencies in chatwerk.gemspec
66
gemspec
77

8-
gem "irb"
9-
gem "rake", "~> 13.0"
8+
gem 'mcp-rb', path: '/Users/martin.emde/workspace/mcp_investigation/mcp-base'
9+
gem 'query_packwerk', path: '/Users/martin.emde/workspace/github.com/rubyatscale/query_packwerk'
1010

11-
gem "rspec", "~> 3.0"
11+
gem 'irb'
12+
gem 'rake', '~> 13.0'
1213

13-
gem "rubocop", "~> 1.21"
14+
gem 'rspec', '~> 3.0'
15+
16+
gem 'rubocop', '~> 1.21'
17+
gem 'rubocop-performance'
18+
gem 'rubocop-sorbet'
19+
gem 'sorbet', '~> 0.5'

Gemfile.lock

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
PATH
2+
remote: .
3+
specs:
4+
chatwerk (0.1.0)
5+
mcp-rb (~> 0.4)
6+
query_packwerk (~> 0.1)
7+
sorbet-runtime
8+
thor (~> 1.2)
9+
10+
PATH
11+
remote: /Users/martin.emde/workspace/github.com/rubyatscale/query_packwerk
12+
specs:
13+
query_packwerk (0.1.0)
14+
coderay
15+
packwerk
16+
parse_packwerk
17+
rubocop
18+
sorbet-runtime
19+
thor
20+
21+
PATH
22+
remote: /Users/martin.emde/workspace/mcp_investigation/mcp-base
23+
specs:
24+
mcp-rb (0.4.0)
25+
addressable (~> 2.8.0)
26+
27+
GEM
28+
remote: https://rubygems.org/
29+
specs:
30+
actionview (8.0.2)
31+
activesupport (= 8.0.2)
32+
builder (~> 3.1)
33+
erubi (~> 1.11)
34+
rails-dom-testing (~> 2.2)
35+
rails-html-sanitizer (~> 1.6)
36+
activesupport (8.0.2)
37+
base64
38+
benchmark (>= 0.3)
39+
bigdecimal
40+
concurrent-ruby (~> 1.0, >= 1.3.1)
41+
connection_pool (>= 2.2.5)
42+
drb
43+
i18n (>= 1.6, < 2)
44+
logger (>= 1.4.2)
45+
minitest (>= 5.1)
46+
securerandom (>= 0.3)
47+
tzinfo (~> 2.0, >= 2.0.5)
48+
uri (>= 0.13.1)
49+
addressable (2.8.7)
50+
public_suffix (>= 2.0.2, < 7.0)
51+
ast (2.4.3)
52+
base64 (0.2.0)
53+
benchmark (0.4.0)
54+
better_html (2.1.1)
55+
actionview (>= 6.0)
56+
activesupport (>= 6.0)
57+
ast (~> 2.0)
58+
erubi (~> 1.4)
59+
parser (>= 2.4)
60+
smart_properties
61+
bigdecimal (3.1.9)
62+
builder (3.3.0)
63+
coderay (1.1.3)
64+
concurrent-ruby (1.3.5)
65+
connection_pool (2.5.0)
66+
constant_resolver (0.2.0)
67+
crass (1.0.6)
68+
date (3.4.1)
69+
diff-lcs (1.6.0)
70+
drb (2.2.1)
71+
erubi (1.13.1)
72+
i18n (1.14.7)
73+
concurrent-ruby (~> 1.0)
74+
io-console (0.8.0)
75+
irb (1.15.1)
76+
pp (>= 0.6.0)
77+
rdoc (>= 4.0.0)
78+
reline (>= 0.4.2)
79+
json (2.10.2)
80+
language_server-protocol (3.17.0.4)
81+
lint_roller (1.1.0)
82+
logger (1.6.6)
83+
loofah (2.24.0)
84+
crass (~> 1.0.2)
85+
nokogiri (>= 1.12.0)
86+
minitest (5.25.5)
87+
nokogiri (1.18.5-arm64-darwin)
88+
racc (~> 1.4)
89+
packwerk (3.2.2)
90+
activesupport (>= 6.0)
91+
ast
92+
better_html
93+
bundler
94+
constant_resolver (>= 0.2.0)
95+
parallel
96+
parser
97+
prism (>= 0.25.0)
98+
sorbet-runtime (>= 0.5.9914)
99+
zeitwerk (>= 2.6.1)
100+
parallel (1.26.3)
101+
parse_packwerk (0.26.0)
102+
bigdecimal
103+
sorbet-runtime
104+
parser (3.3.7.2)
105+
ast (~> 2.4.1)
106+
racc
107+
pp (0.6.2)
108+
prettyprint
109+
prettyprint (0.2.0)
110+
prism (1.4.0)
111+
psych (5.2.3)
112+
date
113+
stringio
114+
public_suffix (6.0.1)
115+
racc (1.8.1)
116+
rails-dom-testing (2.2.0)
117+
activesupport (>= 5.0.0)
118+
minitest
119+
nokogiri (>= 1.6)
120+
rails-html-sanitizer (1.6.2)
121+
loofah (~> 2.21)
122+
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)
123+
rainbow (3.1.1)
124+
rake (13.2.1)
125+
rdoc (6.12.0)
126+
psych (>= 4.0.0)
127+
regexp_parser (2.10.0)
128+
reline (0.6.0)
129+
io-console (~> 0.5)
130+
rspec (3.13.0)
131+
rspec-core (~> 3.13.0)
132+
rspec-expectations (~> 3.13.0)
133+
rspec-mocks (~> 3.13.0)
134+
rspec-core (3.13.3)
135+
rspec-support (~> 3.13.0)
136+
rspec-expectations (3.13.3)
137+
diff-lcs (>= 1.2.0, < 2.0)
138+
rspec-support (~> 3.13.0)
139+
rspec-mocks (3.13.2)
140+
diff-lcs (>= 1.2.0, < 2.0)
141+
rspec-support (~> 3.13.0)
142+
rspec-support (3.13.2)
143+
rubocop (1.74.0)
144+
json (~> 2.3)
145+
language_server-protocol (~> 3.17.0.2)
146+
lint_roller (~> 1.1.0)
147+
parallel (~> 1.10)
148+
parser (>= 3.3.0.2)
149+
rainbow (>= 2.2.2, < 4.0)
150+
regexp_parser (>= 2.9.3, < 3.0)
151+
rubocop-ast (>= 1.38.0, < 2.0)
152+
ruby-progressbar (~> 1.7)
153+
unicode-display_width (>= 2.4.0, < 4.0)
154+
rubocop-ast (1.41.0)
155+
parser (>= 3.3.7.2)
156+
rubocop-performance (1.24.0)
157+
lint_roller (~> 1.1)
158+
rubocop (>= 1.72.1, < 2.0)
159+
rubocop-ast (>= 1.38.0, < 2.0)
160+
rubocop-sorbet (0.9.0)
161+
lint_roller (~> 1.1)
162+
rubocop (>= 1)
163+
ruby-progressbar (1.13.0)
164+
securerandom (0.4.1)
165+
smart_properties (1.17.0)
166+
sorbet (0.5.11953)
167+
sorbet-static (= 0.5.11953)
168+
sorbet-runtime (0.5.11953)
169+
sorbet-static (0.5.11953-universal-darwin)
170+
stringio (3.1.5)
171+
thor (1.3.2)
172+
tzinfo (2.0.6)
173+
concurrent-ruby (~> 1.0)
174+
unicode-display_width (3.1.4)
175+
unicode-emoji (~> 4.0, >= 4.0.4)
176+
unicode-emoji (4.0.4)
177+
uri (1.0.3)
178+
zeitwerk (2.7.2)
179+
180+
PLATFORMS
181+
arm64-darwin
182+
universal-darwin
183+
184+
DEPENDENCIES
185+
chatwerk!
186+
irb
187+
mcp-rb!
188+
query_packwerk!
189+
rake (~> 13.0)
190+
rspec (~> 3.0)
191+
rubocop (~> 1.21)
192+
rubocop-performance
193+
rubocop-sorbet
194+
sorbet (~> 0.5)
195+
196+
BUNDLED WITH
197+
2.6.6

MCP.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# QueryPackwerk MCP Server
2+
3+
The QueryPackwerk MCP (Model Context Protocol) server enables integration with Cursor IDE and other AI tools that support the MCP protocol. This allows you to get information about Packwerk packages and violations directly in your IDE.
4+
5+
## Installation
6+
7+
The MCP server requires additional dependencies. Make sure to install the gem with the development dependencies:
8+
9+
```bash
10+
gem install query_packwerk --development
11+
```
12+
13+
Or in your Gemfile:
14+
15+
```ruby
16+
gem 'query_packwerk', group: :development
17+
```
18+
19+
## Starting the MCP Server
20+
21+
You can start the MCP server using the provided command:
22+
23+
```bash
24+
query_packwerk_mcp
25+
```
26+
27+
By default, the server runs on port 7531. You can specify a different port:
28+
29+
```bash
30+
query_packwerk_mcp --port=9000
31+
```
32+
33+
## Connecting with Cursor
34+
35+
To use QueryPackwerk with Cursor:
36+
37+
1. Start the MCP server in your project directory:
38+
```bash
39+
cd /your/rails/project
40+
query_packwerk_mcp
41+
```
42+
43+
2. In Cursor, open Settings > Extensions > Model Context Providers.
44+
45+
3. Add a new MCP connection with the URL: `http://localhost:7531/mcp/context`
46+
47+
4. Now you can ask Cursor about your packages and violations!
48+
49+
## Example Queries for Cursor
50+
51+
Once connected, you can ask Cursor questions about your Packwerk structure:
52+
53+
- "What are all the packages in this codebase?"
54+
- "Tell me about the dependencies of package X"
55+
- "What packages depend on package Y?"
56+
- "Show me all the violations for package Z"
57+
- "How difficult would it be to separate package X from its dependencies?"
58+
- "What code patterns are used to access package Y?"
59+
60+
## Available API Endpoints
61+
62+
The MCP server also provides a REST API that you can use directly:
63+
64+
- `GET /api/packages` - List all packages
65+
- `GET /api/packages/search?q=query` - Search packages by name/owner
66+
- `GET /api/packages/:name/info` - Get detailed info about a package
67+
- `GET /api/packages/:name/dependencies` - Get dependencies of a package
68+
- `GET /api/packages/:name/consumers` - Get consumers of a package
69+
- `GET /api/packages/:name/usage-patterns` - Get usage patterns of a package
70+
- `GET /api/packages/:name/access-patterns` - Get access patterns with examples
71+
- `GET /api/packages/:name/usage-locations` - Find where a package is used
72+
- `GET /api/packages/:name/separation-difficulty` - Assess difficulty of separating a package
73+
74+
## MCP Protocol Integration
75+
76+
The MCP server supports the following capabilities:
77+
78+
- `packwerk-packages` - Access information about packages
79+
- `packwerk-violations` - Access information about violations
80+
81+
These capabilities are available through the standard MCP context endpoint at `/mcp/context`.

0 commit comments

Comments
 (0)