@rigstate/mcp 0.4.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.
Files changed (40) hide show
  1. package/.env.example +8 -0
  2. package/README.md +352 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +3445 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +43 -0
  7. package/roadmap.json +531 -0
  8. package/src/agents/the-scribe.ts +122 -0
  9. package/src/index.ts +1792 -0
  10. package/src/lib/supabase.ts +120 -0
  11. package/src/lib/tool-registry.ts +134 -0
  12. package/src/lib/types.ts +415 -0
  13. package/src/lib/utils.ts +10 -0
  14. package/src/resources/project-morals.ts +92 -0
  15. package/src/tools/arch-tools.ts +166 -0
  16. package/src/tools/archaeological-scan.ts +335 -0
  17. package/src/tools/check-agent-bridge.ts +169 -0
  18. package/src/tools/check-rules-sync.ts +85 -0
  19. package/src/tools/complete-roadmap-task.ts +96 -0
  20. package/src/tools/generate-professional-pdf.ts +232 -0
  21. package/src/tools/get-latest-decisions.ts +130 -0
  22. package/src/tools/get-next-roadmap-step.ts +76 -0
  23. package/src/tools/get-project-context.ts +163 -0
  24. package/src/tools/index.ts +17 -0
  25. package/src/tools/list-features.ts +67 -0
  26. package/src/tools/list-roadmap-tasks.ts +61 -0
  27. package/src/tools/pending-tasks.ts +228 -0
  28. package/src/tools/planning-tools.ts +123 -0
  29. package/src/tools/query-brain.ts +125 -0
  30. package/src/tools/research-tools.ts +149 -0
  31. package/src/tools/run-architecture-audit.ts +203 -0
  32. package/src/tools/save-decision.ts +77 -0
  33. package/src/tools/security-tools.ts +82 -0
  34. package/src/tools/submit-idea.ts +66 -0
  35. package/src/tools/sync-ide-rules.ts +76 -0
  36. package/src/tools/teacher-mode.ts +171 -0
  37. package/src/tools/ui-tools.ts +191 -0
  38. package/src/tools/update-roadmap.ts +105 -0
  39. package/tsconfig.json +29 -0
  40. package/tsup.config.ts +16 -0
package/.env.example ADDED
@@ -0,0 +1,8 @@
1
+ # Required: Your Rigstate API key
2
+ # Get it from: https://rigstate.dev/settings/api-keys
3
+ RIGSTATE_API_KEY=sk_rigstate_your_api_key_here
4
+
5
+ # Optional: Override Supabase configuration
6
+ # Only needed for local development or self-hosted instances
7
+ # RIGSTATE_SUPABASE_URL=https://your-project.supabase.co
8
+ # RIGSTATE_SUPABASE_ANON_KEY=your-anon-key
package/README.md ADDED
@@ -0,0 +1,352 @@
1
+ # Rigstate MCP Server
2
+
3
+ A [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server that exposes Rigstate's Project Brain and Council Decisions to AI editors like **Cursor** and **Claude Desktop**.
4
+
5
+ > ⚠️ **v0.4.0 Update**: MCP is now in **Read-Only Mode**. Write operations are deprecated.
6
+ > Use `rigstate check` and `rigstate daemon` CLI commands for rule enforcement and task processing.
7
+
8
+ ## 🚀 Features
9
+
10
+ ### Read Operations (Recommended)
11
+ - **`get_project_context`**: Returns the project type, tech stack, and high-level description
12
+ - **`query_brain`**: Semantic search against project memories, architecture rules, and constraints
13
+ - **`get_latest_decisions`**: Fetches recent ADRs and decisions from The Architect's Council
14
+ - **`list_roadmap_tasks`**: Lists all actionable tasks for a project
15
+ - **`get_next_roadmap_step`**: Fetches the next logical step from the roadmap
16
+ - **`get_learned_instructions`**: Fetch all learned behaviors and corrections
17
+
18
+ ### Write Operations (⚠️ DEPRECATED)
19
+ > These tools will be removed in a future version. Use the Rigstate Dashboard or CLI instead.
20
+ - **`save_decision`**: Saves architectural decisions to the Project Brain
21
+ - **`submit_idea`**: Submits ideas to the Idea Lab
22
+ - **`update_roadmap`**: Updates roadmap step status
23
+
24
+ ### CLI Commands (Recommended for Rule Enforcement)
25
+ Use the `@rigstate/cli` package for local rule enforcement:
26
+ - `rigstate check` - Validate code against Guardian rules
27
+ - `rigstate daemon` - Continuous file monitoring with rule validation
28
+ - `rigstate hooks install` - Install pre-commit hooks
29
+
30
+ ## 📦 Installation
31
+
32
+ ```bash
33
+ npm install @rigstate/mcp
34
+ ```
35
+
36
+ Or use directly with npx:
37
+
38
+ ```bash
39
+ RIGSTATE_API_KEY=sk_rigstate_xxx npx @rigstate/mcp
40
+ ```
41
+
42
+ ## 🔑 Authentication
43
+
44
+ The MCP server requires a Rigstate API key. Get yours from:
45
+
46
+ 👉 https://rigstate.dev/settings/api-keys
47
+
48
+ Set it as an environment variable:
49
+
50
+ ```bash
51
+ export RIGSTATE_API_KEY=sk_rigstate_xxxxxxxxxxxxxxxx
52
+ ```
53
+
54
+ ## ⚙️ Configuration
55
+
56
+ ### Cursor
57
+
58
+ Add to your `.cursor/mcp.json`:
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "rigstate": {
64
+ "command": "npx",
65
+ "args": ["@rigstate/mcp"],
66
+ "env": {
67
+ "RIGSTATE_API_KEY": "sk_rigstate_xxx"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Claude Desktop
75
+
76
+ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "rigstate": {
82
+ "command": "npx",
83
+ "args": ["@rigstate/mcp"],
84
+ "env": {
85
+ "RIGSTATE_API_KEY": "sk_rigstate_xxx"
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ ## 🔧 Environment Variables
93
+
94
+ | Variable | Required | Description |
95
+ |----------|----------|-------------|
96
+ | `RIGSTATE_API_KEY` | ✅ | Your Rigstate API key (sk_rigstate_...) |
97
+ | `RIGSTATE_SUPABASE_URL` | ❌ | Override Supabase URL (defaults to production) |
98
+ | `RIGSTATE_SUPABASE_ANON_KEY` | ❌ | Override Supabase anon key (defaults to production) |
99
+
100
+ ## 🛠️ Available Tools
101
+
102
+ ### `get_project_context`
103
+
104
+ Returns project metadata and tech stack information.
105
+
106
+ **Input:**
107
+ ```json
108
+ {
109
+ "projectId": "uuid-of-your-project"
110
+ }
111
+ ```
112
+
113
+ **Output:**
114
+ ```
115
+ Project Type: WEB
116
+ Framework: Next.js 14.1.0
117
+ ORM: Prisma 5.0.0
118
+ Key Libraries: Tailwind, Supabase, Zod
119
+ Top Folders: src, public, prisma
120
+
121
+ Description: A SaaS dashboard for...
122
+ ```
123
+
124
+ ### `query_brain`
125
+
126
+ Searches the Project Brain for relevant memories.
127
+
128
+ **Input:**
129
+ ```json
130
+ {
131
+ "projectId": "uuid-of-your-project",
132
+ "query": "authentication flow",
133
+ "limit": 5
134
+ }
135
+ ```
136
+
137
+ **Output:**
138
+ ```
139
+ === PROJECT BRAIN: RELEVANT MEMORIES ===
140
+ Query: "authentication flow"
141
+ Found 3 relevant memories:
142
+
143
+ - [ARCHITECTURE] [auth, security]: Use Supabase Auth with RLS for all protected routes
144
+ - [DECISION]: Implement magic link login instead of password-based auth
145
+ - [CONSTRAINT]: All API routes must verify JWT before processing
146
+
147
+ ==========================================
148
+ ```
149
+
150
+ ### `get_latest_decisions`
151
+
152
+ Fetches recent council sessions and decisions.
153
+
154
+ **Input:**
155
+ ```json
156
+ {
157
+ "projectId": "uuid-of-your-project",
158
+ "limit": 3
159
+ }
160
+ ```
161
+
162
+ **Output:**
163
+ ```
164
+ === CURRENT FOCUS ===
165
+ Step 3: Implement Dashboard Views
166
+ Focus: Frontend Development
167
+
168
+ === RECENT COUNCIL SESSIONS (2) ===
169
+
170
+ 📅 Session on 1/3/2026
171
+ Agents: product-owner, cto, security-auditor
172
+ Key Feedback:
173
+ 🕵️ The Product Owner: ✅
174
+ - Feature scope is well-defined
175
+ 🔧 CTO: ✅
176
+ - Dependencies are properly ordered
177
+
178
+ === KEY DECISIONS FROM BRAIN ===
179
+ - [ARCHITECTURE] Use server components by default
180
+ - [DECISION] Implement optimistic updates for better UX
181
+ ```
182
+
183
+ ---
184
+
185
+ ## ✏️ Write Operations (v0.2.0+)
186
+
187
+ ### `save_decision`
188
+
189
+ Saves a new architectural decision (ADR) to the Project Brain.
190
+
191
+ **Input:**
192
+ ```json
193
+ {
194
+ "projectId": "uuid-of-your-project",
195
+ "title": "Use Prisma for ORM",
196
+ "decision": "We will use Prisma as our ORM for type-safe database access.",
197
+ "rationale": "Prisma provides excellent TypeScript integration and migration tooling.",
198
+ "category": "architecture",
199
+ "tags": ["database", "prisma"]
200
+ }
201
+ ```
202
+
203
+ **Output:**
204
+ ```
205
+ ✅ Decision "Use Prisma for ORM" saved to project "My App" with importance 9/10
206
+ ```
207
+
208
+ ### `submit_idea`
209
+
210
+ Submits a new idea to the Idea Lab for review.
211
+
212
+ **Input:**
213
+ ```json
214
+ {
215
+ "projectId": "uuid-of-your-project",
216
+ "title": "Add dark mode toggle",
217
+ "description": "Allow users to switch between light and dark themes.",
218
+ "category": "feature",
219
+ "tags": ["ui", "accessibility"]
220
+ }
221
+ ```
222
+
223
+ **Output:**
224
+ ```
225
+ 💡 Idea "Add dark mode toggle" submitted to Idea Lab for project "My App". Status: Draft (awaiting review)
226
+ ```
227
+
228
+ ### `update_roadmap`
229
+
230
+ Updates the status of a roadmap step.
231
+
232
+ **Input (by ID):**
233
+ ```json
234
+ {
235
+ "projectId": "uuid-of-your-project",
236
+ "chunkId": "uuid-of-roadmap-chunk",
237
+ "status": "COMPLETED"
238
+ }
239
+ ```
240
+
241
+ **Input (by title):**
242
+ ```json
243
+ {
244
+ "projectId": "uuid-of-your-project",
245
+ "title": "Implement auth",
246
+ "status": "ACTIVE"
247
+ }
248
+ ```
249
+
250
+ **Output:**
251
+ ```
252
+ ✅ Roadmap step "Implement Authentication" updated: LOCKED → ACTIVE
253
+ ```
254
+
255
+ ### `run_architecture_audit`
256
+
257
+ Audits code against project rules and security patterns.
258
+
259
+ **Input:**
260
+ ```json
261
+ {
262
+ "projectId": "uuid-of-your-project",
263
+ "filePath": "src/app/api/users/route.ts",
264
+ "content": "export async function GET(req) { ... }"
265
+ }
266
+ ```
267
+
268
+ **Output (Pass):**
269
+ ```
270
+ ✅ PASSED - No violations found in src/app/api/users/route.ts
271
+ Score: 100/100
272
+ ```
273
+
274
+ **Output (Fail):**
275
+ ```
276
+ ⚠️ AUDIT FAILED - 2 violation(s) found in src/app/api/users/route.ts
277
+ Score: 65/100
278
+ • HIGH: 1
279
+ • MEDIUM: 1
280
+ • LOW: 0
281
+
282
+ Violations:
283
+ 1. [HIGH] Potential XSS Vulnerability (line 15)
284
+ Using dangerouslySetInnerHTML can expose your app to XSS attacks.
285
+ → Sanitize HTML content using a library like DOMPurify before rendering.
286
+
287
+ 2. [MEDIUM] Potentially Missing Authentication
288
+ API route handler may not be checking authentication.
289
+ → Add authentication check at the start of your API handler.
290
+
291
+ ### `sync_ide_rules`
292
+
293
+ Generates the appropriate rules file content (e.g. `.cursorrules`, `.windsurfrules`) based on project context and user settings.
294
+
295
+ **Input:**
296
+ ```json
297
+ {
298
+ "projectId": "uuid-of-your-project"
299
+ }
300
+ ```
301
+
302
+ **Output:**
303
+ ```markdown
304
+ FileName: .cursorrules
305
+
306
+ Content:
307
+ RIGSTATE_START
308
+ ## 🤖 THE ACTIVE TEAM
309
+ ...
310
+ RIGSTATE_END
311
+ ```
312
+
313
+ ### `check_rules_sync`
314
+
315
+ Verifies if the IDE rules are present and belong to the correct project.
316
+
317
+ **Input:**
318
+ ```json
319
+ {
320
+ "projectId": "uuid-of-your-project",
321
+ "currentRulesContent": "full content of your .cursorrules file"
322
+ }
323
+ ```
324
+
325
+ ## 🤖 Strict Tool Ownership (v0.3.0+)
326
+ Rigstate MCP enforces **Strict Tool Ownership**. In your generated rules, every tool is explicitly bound to an Agent ID. When an AI invokes a tool, it is instructed to adopt the persona and authority level of the owner.
327
+
328
+ ## 🔒 Security
329
+
330
+ - The server only accesses data belonging to projects owned by the API key holder
331
+ - All database queries include ownership verification (`owner_id = userId`)
332
+ - API key usage is tracked via `last_used_at` timestamp
333
+
334
+ ## 📝 Development
335
+
336
+ ```bash
337
+ # Install dependencies
338
+ npm install
339
+
340
+ # Build
341
+ npm run build
342
+
343
+ # Development mode (with watch)
344
+ npm run dev
345
+
346
+ # Test locally
347
+ RIGSTATE_API_KEY=sk_rigstate_xxx node dist/index.js
348
+ ```
349
+
350
+ ## 📄 License
351
+
352
+ MIT
@@ -0,0 +1,2 @@
1
+
2
+ export { }