@everystack/mcp 0.2.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.
- package/README.md +100 -0
- package/package.json +39 -0
- package/src/index.ts +58 -0
- package/src/prompts/add-feature.ts +163 -0
- package/src/prompts/debug.ts +136 -0
- package/src/prompts/deploy.ts +131 -0
- package/src/prompts/design-schema.ts +104 -0
- package/src/prompts/index.ts +16 -0
- package/src/prompts/new-app.ts +211 -0
- package/src/prompts/secure.ts +231 -0
- package/src/resources/adding-database.md +169 -0
- package/src/resources/admin.md +81 -0
- package/src/resources/auth.md +115 -0
- package/src/resources/aws-setup.md +173 -0
- package/src/resources/cli.md +108 -0
- package/src/resources/client-api.md +145 -0
- package/src/resources/core.md +196 -0
- package/src/resources/deployment.md +146 -0
- package/src/resources/events.md +87 -0
- package/src/resources/first-run.md +100 -0
- package/src/resources/getting-started.md +75 -0
- package/src/resources/handler-options.md +114 -0
- package/src/resources/images.md +73 -0
- package/src/resources/index.ts +224 -0
- package/src/resources/jobs.md +97 -0
- package/src/resources/logging.md +91 -0
- package/src/resources/plugins.md +68 -0
- package/src/resources/project-claude-md.md +127 -0
- package/src/resources/query-protocol.md +129 -0
- package/src/resources/schema-patterns.md +167 -0
- package/src/resources/security-device.md +99 -0
- package/src/resources/security.md +270 -0
- package/src/resources/ssr.md +82 -0
- package/src/resources/storage.md +63 -0
- package/src/resources/testing.md +118 -0
- package/src/tools/check-environment.ts +319 -0
- package/src/tools/index.ts +58 -0
- package/src/tools/project-status.ts +183 -0
- package/src/tools/project-validate.ts +369 -0
- package/src/tools/schema-analyze.ts +410 -0
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @everystack/mcp
|
|
2
|
+
|
|
3
|
+
MCP server that makes Claude an everystack expert. Provides architecture knowledge, project introspection tools, and guided workflow prompts so Claude can help build apps from V1 (static) to V3 (full platform).
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
Add to your project's `.mcp.json`:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"mcpServers": {
|
|
12
|
+
"everystack": {
|
|
13
|
+
"command": "npx",
|
|
14
|
+
"args": ["@everystack/mcp"]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or for a monorepo workspace:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"everystack": {
|
|
26
|
+
"command": "npx",
|
|
27
|
+
"args": ["tsx", "packages/mcp/src/index.ts"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## What It Provides
|
|
34
|
+
|
|
35
|
+
### Resources (Knowledge)
|
|
36
|
+
|
|
37
|
+
Claude reads these to understand everystack architecture and conventions.
|
|
38
|
+
|
|
39
|
+
**Core (loaded first):**
|
|
40
|
+
- `everystack://core` — Architecture, package map, tiers, conventions, handler reference
|
|
41
|
+
- `everystack://security` — Three-layer security model, AWS IAM profiles, RLS policies
|
|
42
|
+
|
|
43
|
+
**Detail (loaded on demand):**
|
|
44
|
+
- `everystack://handler-options` — Complete createHandler() options reference
|
|
45
|
+
- `everystack://query-protocol` — PostgREST filter syntax, embedding, aggregates
|
|
46
|
+
- `everystack://client-api` — Typed client, query builder, mutations
|
|
47
|
+
- `everystack://auth` — JWT auth flows, OAuth, token lifecycle
|
|
48
|
+
- `everystack://schema-patterns` — Drizzle schema design, migrations, RLS
|
|
49
|
+
- `everystack://deployment` — SST config, secrets, stages, resource linking
|
|
50
|
+
- `everystack://admin` — Declarative admin dashboard
|
|
51
|
+
- `everystack://jobs` — SQS background workers
|
|
52
|
+
- `everystack://storage` — S3 file uploads, presigned URLs
|
|
53
|
+
- `everystack://logging` — Structured logging, crash reports, analytics
|
|
54
|
+
- `everystack://security-device` — Device attestation, biometric auth
|
|
55
|
+
- `everystack://testing` — Jest setup, TDD workflow, mocking patterns
|
|
56
|
+
- `everystack://plugins` — Plugin system for composing handlers
|
|
57
|
+
- `everystack://ssr` — Server-side rendering, loaders, SEO
|
|
58
|
+
- `everystack://images` — Sharp image processing, CDN delivery
|
|
59
|
+
- `everystack://events` — Real-time events via LISTEN/NOTIFY + WebSocket
|
|
60
|
+
- `everystack://cli` — CLI command reference
|
|
61
|
+
|
|
62
|
+
### Tools (Project Introspection)
|
|
63
|
+
|
|
64
|
+
Read-only tools that analyze your project and return structured data.
|
|
65
|
+
|
|
66
|
+
| Tool | Purpose |
|
|
67
|
+
|------|---------|
|
|
68
|
+
| `project_status` | Detect tier (V1/V2/V3), installed packages, project structure, deployment state |
|
|
69
|
+
| `schema_analyze` | Parse Drizzle schema, cross-reference handler config, detect misconfigurations |
|
|
70
|
+
| `project_validate` | Check for security gaps, missing dependencies, convention violations |
|
|
71
|
+
|
|
72
|
+
### Prompts (Guided Workflows)
|
|
73
|
+
|
|
74
|
+
Structured prompts that guide Claude through multi-step tasks.
|
|
75
|
+
|
|
76
|
+
| Prompt | Purpose |
|
|
77
|
+
|--------|---------|
|
|
78
|
+
| `new-app` | Scaffold a new everystack app (V1/V2/V3) |
|
|
79
|
+
| `add-feature` | Add auth, jobs, storage, images, admin, logging, security, SSR, or events |
|
|
80
|
+
| `design-schema` | Plain English → Drizzle schema + RLS policies + handler config |
|
|
81
|
+
| `deploy` | Stage-specific deployment walkthrough |
|
|
82
|
+
| `debug` | Systematic debugging based on symptoms |
|
|
83
|
+
| `secure` | AWS IAM profiles + RLS + JWT auth setup |
|
|
84
|
+
|
|
85
|
+
## Design
|
|
86
|
+
|
|
87
|
+
**Standalone.** Zero everystack peer dependencies. Only depends on `@modelcontextprotocol/sdk` and `zod`. Works even when the project is broken or partially set up.
|
|
88
|
+
|
|
89
|
+
**Local-only.** Runs via stdio transport. No network access, no AWS calls. The everystack CLI handles remote infrastructure — the MCP teaches Claude how to use it.
|
|
90
|
+
|
|
91
|
+
**Read-only tools.** Tools read files and return structured data. Claude does the reasoning. No file writes, no imports from other packages.
|
|
92
|
+
|
|
93
|
+
**Curated resources.** The markdown files are optimized for Claude consumption — organized by task, not by package. Each follows a consistent structure: When to Use, Setup, API Reference, Common Patterns, Gotchas.
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm --filter @everystack/mcp test # Run tests (58 passing)
|
|
99
|
+
pnpm --filter @everystack/mcp lint # Type check
|
|
100
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@everystack/mcp",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server that makes Claude an everystack expert",
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./src/index.ts",
|
|
16
|
+
"default": "./src/index.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"everystack-mcp": "./src/index.ts"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "jest",
|
|
24
|
+
"build": "tsc --build",
|
|
25
|
+
"lint": "tsc --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
29
|
+
"zod": "3.25.67"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/jest": "29.5.14",
|
|
33
|
+
"@types/node": "22.19.18",
|
|
34
|
+
"jest": "29.7.0",
|
|
35
|
+
"ts-jest": "29.4.9",
|
|
36
|
+
"tsx": "4.21.0",
|
|
37
|
+
"typescript": "5.9.3"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { registerResources } from './resources/index.js';
|
|
6
|
+
import { registerTools } from './tools/index.js';
|
|
7
|
+
import { registerPrompts } from './prompts/index.js';
|
|
8
|
+
|
|
9
|
+
const server = new McpServer(
|
|
10
|
+
{ name: '@everystack/mcp', version: '0.2.0' },
|
|
11
|
+
{
|
|
12
|
+
instructions: [
|
|
13
|
+
'You are an everystack expert. everystack is a self-hosted application stack for Expo apps on AWS.',
|
|
14
|
+
'',
|
|
15
|
+
'## Beginner Detection',
|
|
16
|
+
'',
|
|
17
|
+
'Detect the user\'s experience level from context:',
|
|
18
|
+
'- If the user describes an app idea without technical terms, has no existing project, or asks basic questions ("how do I start?", "I want to build..."), treat them as a BEGINNER.',
|
|
19
|
+
'- If the user references specific packages, tiers (V1/V2/V3), tools (Drizzle, PostgREST, SST), or has an existing everystack project, treat them as a DEVELOPER.',
|
|
20
|
+
'',
|
|
21
|
+
'## Beginner Flow',
|
|
22
|
+
'',
|
|
23
|
+
'For beginners:',
|
|
24
|
+
'1. Read everystack://getting-started first. This is your guide for how to talk to beginners.',
|
|
25
|
+
'2. Ask what they want to build. Listen to their idea before anything technical. Do NOT categorize into tiers or ask them to choose V1/V2/V3.',
|
|
26
|
+
'3. Run check_environment with phase "local". Only V1 prerequisites matter now (Node.js, git, pnpm). PostgreSQL is NOT needed yet.',
|
|
27
|
+
' Do NOT require AWS tools (AWS CLI, credentials, SST) upfront. The user will build and run locally first.',
|
|
28
|
+
'4. Walk through installing missing prerequisites ONE AT A TIME. Do not list them all at once. Install the first missing tool, confirm it works, then move to the next.',
|
|
29
|
+
'5. Create a stock Expo app: `npx create-expo-app@latest`, install V1 packages (`@everystack/server`, `@everystack/cli`, `@everystack/ui`), and `pnpm add -D sst`.',
|
|
30
|
+
'6. Run `npx expo start`. Read everystack://first-run for the walkthrough. The first milestone is seeing the app running in a browser.',
|
|
31
|
+
'7. Build together. Discuss what the app should look like. Create screens, navigation, components. Everything is static and visual.',
|
|
32
|
+
'8. When a feature needs user accounts or saved data, read everystack://adding-database. This introduces PostgreSQL, the API handler, auth, and database setup step by step.',
|
|
33
|
+
'9. When a feature needs file uploads or background tasks, add the relevant packages incrementally (everystack://storage, everystack://jobs, everystack://images).',
|
|
34
|
+
'10. When the user is ready to deploy to the internet, run check_environment with phase "deploy" and walk through AWS setup.',
|
|
35
|
+
' For AWS credentials specifically, read everystack://aws-setup and walk them through account creation and IAM setup step by step.',
|
|
36
|
+
'11. Never use jargon without explaining it. "Lambda" is "the server that runs your code." "S3" is "file storage." "RDS" is "the database server." "CloudFront" is "the CDN that makes your app fast worldwide."',
|
|
37
|
+
'',
|
|
38
|
+
'## Developer Flow',
|
|
39
|
+
'',
|
|
40
|
+
'For experienced developers:',
|
|
41
|
+
'1. Read everystack://core for architecture and conventions.',
|
|
42
|
+
'2. Read everystack://security before any deployment or auth guidance.',
|
|
43
|
+
'3. Load detail resources on demand when the user asks about specific features.',
|
|
44
|
+
'4. Use the project_status tool to understand the user\'s current project state.',
|
|
45
|
+
'5. Use the schema_analyze tool when helping with database schema or RLS.',
|
|
46
|
+
'6. Use the project_validate tool to check for common mistakes before deployment.',
|
|
47
|
+
'7. When the user wants to start a new project, run check_environment (phase "local" for dev, "deploy" for deployment) to verify prerequisites.',
|
|
48
|
+
'8. When the user needs to interact with deployed infrastructure, guide them to use the everystack CLI.',
|
|
49
|
+
].join('\n'),
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
registerResources(server);
|
|
54
|
+
registerTools(server);
|
|
55
|
+
registerPrompts(server);
|
|
56
|
+
|
|
57
|
+
const transport = new StdioServerTransport();
|
|
58
|
+
server.connect(transport).catch(console.error);
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
const FEATURES: Record<string, { resource: string; packages: string[]; steps: string[] }> = {
|
|
5
|
+
auth: {
|
|
6
|
+
resource: 'everystack://auth',
|
|
7
|
+
packages: ['@everystack/auth'],
|
|
8
|
+
steps: [
|
|
9
|
+
'Install @everystack/auth',
|
|
10
|
+
'Create auth handlers with createAuthHandlers(db, schema, jwtSecret)',
|
|
11
|
+
'Add auth routes to Lambda handler (signup, signin, refresh, verify, signout)',
|
|
12
|
+
'Create lib/auth-context.tsx with AuthProvider and useAuth hook',
|
|
13
|
+
'Add pgSettings to handler config for RLS claim injection',
|
|
14
|
+
'Add signup and signin screens in app/',
|
|
15
|
+
'Set JwtSecret via SST secrets: `pnpm sst secret set JwtSecret "$(openssl rand -base64 32)" --stage dev`',
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
jobs: {
|
|
19
|
+
resource: 'everystack://jobs',
|
|
20
|
+
packages: ['@everystack/jobs'],
|
|
21
|
+
steps: [
|
|
22
|
+
'Install @everystack/jobs',
|
|
23
|
+
'Create server/worker.ts with createWorkerHandler',
|
|
24
|
+
'Define job types and handlers',
|
|
25
|
+
'Add SQS queue to sst.config.ts',
|
|
26
|
+
'Create job adapter: createJobAdapter({ type: "sqs", queueUrl: Resource.Jobs.url })',
|
|
27
|
+
'Publish jobs from API handlers: jobClient.publish(type, payload)',
|
|
28
|
+
'Add dead letter queue for failed jobs',
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
storage: {
|
|
32
|
+
resource: 'everystack://storage',
|
|
33
|
+
packages: ['@everystack/storage'],
|
|
34
|
+
steps: [
|
|
35
|
+
'Install @everystack/storage',
|
|
36
|
+
'Add S3 bucket for uploads to sst.config.ts',
|
|
37
|
+
'Add storagePlugin to handler plugins with MIME type validation',
|
|
38
|
+
'Add uploads table to schema (or use @everystack/storage/schema)',
|
|
39
|
+
'Client flow: request presigned URL → upload to S3 → confirm upload',
|
|
40
|
+
'Configure CDN delivery for public files',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
images: {
|
|
44
|
+
resource: 'everystack://images',
|
|
45
|
+
packages: ['@everystack/images'],
|
|
46
|
+
steps: [
|
|
47
|
+
'Install @everystack/images',
|
|
48
|
+
'Create server/image.ts with createImageHandler',
|
|
49
|
+
'Add image Lambda to sst.config.ts (needs sharp layer)',
|
|
50
|
+
'Add image_variants table to schema',
|
|
51
|
+
'Configure variant generation (thumb, medium, large)',
|
|
52
|
+
'Set up CDN delivery with format negotiation (WebP, AVIF)',
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
admin: {
|
|
56
|
+
resource: 'everystack://admin',
|
|
57
|
+
packages: ['@everystack/admin'],
|
|
58
|
+
steps: [
|
|
59
|
+
'Install @everystack/admin',
|
|
60
|
+
'Create admin page in app/ using AdminRoot and AdminLayout',
|
|
61
|
+
'Define resource configs for each table (fields, columns, actions)',
|
|
62
|
+
'Use EverystackAdapter for API integration',
|
|
63
|
+
'Add admin role check to protect admin routes',
|
|
64
|
+
'Add dashboard RPCs via createAllDashboardRpcs',
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
logging: {
|
|
68
|
+
resource: 'everystack://logging',
|
|
69
|
+
packages: ['@everystack/logging'],
|
|
70
|
+
steps: [
|
|
71
|
+
'Install @everystack/logging',
|
|
72
|
+
'Add loggingPlugin to handler plugins',
|
|
73
|
+
'Add logging schema tables to your schema exports',
|
|
74
|
+
'Configure S3 log storage in sst.config.ts',
|
|
75
|
+
'Add client SDK: createLoggingClient for crash reports and analytics',
|
|
76
|
+
'Add admin dashboard RPCs for log viewing',
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
security: {
|
|
80
|
+
resource: 'everystack://security-device',
|
|
81
|
+
packages: ['@everystack/security'],
|
|
82
|
+
steps: [
|
|
83
|
+
'Install @everystack/security',
|
|
84
|
+
'Set up Apple App Attest (requires iOS 14+, real device)',
|
|
85
|
+
'Set up Google Play Integrity (requires Google Play Services)',
|
|
86
|
+
'Generate RS256 device keys on client',
|
|
87
|
+
'Add device attestation verification to auth flow',
|
|
88
|
+
'Store device keys in secure enclave/keystore',
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
ssr: {
|
|
92
|
+
resource: 'everystack://ssr',
|
|
93
|
+
packages: [],
|
|
94
|
+
steps: [
|
|
95
|
+
'SSR is built into @everystack/server — no extra packages needed',
|
|
96
|
+
'Create SSR loader functions that query Drizzle directly',
|
|
97
|
+
'Add getWebHandler to Lambda for HTML rendering',
|
|
98
|
+
'Set up JSON-LD structured data for SEO',
|
|
99
|
+
'Add OG meta tags for social sharing',
|
|
100
|
+
'Configure cache headers per route',
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
events: {
|
|
104
|
+
resource: 'everystack://events',
|
|
105
|
+
packages: [],
|
|
106
|
+
steps: [
|
|
107
|
+
'Events use PostgreSQL LISTEN/NOTIFY — built into the database',
|
|
108
|
+
'Create database trigger functions for table change notifications',
|
|
109
|
+
'Set up a listener Lambda with persistent database connection',
|
|
110
|
+
'Add WebSocket fan-out for client delivery',
|
|
111
|
+
'Use the useSignal hook in React components for real-time updates',
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export function registerAddFeaturePrompt(server: McpServer): void {
|
|
117
|
+
server.prompt(
|
|
118
|
+
'add-feature',
|
|
119
|
+
'Add an everystack feature to an existing project. Provides step-by-step instructions for auth, jobs, storage, images, admin, logging, security, SSR, or events.',
|
|
120
|
+
{
|
|
121
|
+
feature: z.enum(['auth', 'jobs', 'storage', 'images', 'admin', 'logging', 'security', 'ssr', 'events'])
|
|
122
|
+
.describe('Feature to add'),
|
|
123
|
+
projectPath: z.string().optional().describe('Absolute path to project root'),
|
|
124
|
+
},
|
|
125
|
+
async ({ feature, projectPath }) => {
|
|
126
|
+
const f = FEATURES[feature];
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
messages: [
|
|
130
|
+
{
|
|
131
|
+
role: 'user' as const,
|
|
132
|
+
content: {
|
|
133
|
+
type: 'text' as const,
|
|
134
|
+
text: [
|
|
135
|
+
`Add ${feature} to ${projectPath ? 'the project at ' + projectPath : 'my everystack project'}.`,
|
|
136
|
+
'',
|
|
137
|
+
'## Instructions',
|
|
138
|
+
'',
|
|
139
|
+
`1. Read the ${f.resource} resource for full documentation.`,
|
|
140
|
+
'2. Read everystack://core for architecture context.',
|
|
141
|
+
feature === 'auth' || feature === 'security' ? '3. Read everystack://security for the security model.' : '',
|
|
142
|
+
projectPath ? `4. Run the project_status tool with projectPath="${projectPath}" to understand the current state.` : '',
|
|
143
|
+
projectPath ? `5. Run the project_validate tool with projectPath="${projectPath}" after making changes.` : '',
|
|
144
|
+
'',
|
|
145
|
+
'## Steps',
|
|
146
|
+
'',
|
|
147
|
+
...f.steps.map((s, i) => `${i + 1}. ${s}`),
|
|
148
|
+
'',
|
|
149
|
+
f.packages.length > 0 ? `## Install\n\n\`\`\`bash\npnpm add ${f.packages.join(' ')}\n\`\`\`` : '',
|
|
150
|
+
'',
|
|
151
|
+
'## After Setup',
|
|
152
|
+
'',
|
|
153
|
+
'- Run tests to verify the integration',
|
|
154
|
+
'- Run project_validate to check for configuration issues',
|
|
155
|
+
'- Read the relevant resource docs for advanced configuration',
|
|
156
|
+
].filter(Boolean).join('\n'),
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export function registerDebugPrompt(server: McpServer): void {
|
|
5
|
+
server.prompt(
|
|
6
|
+
'debug',
|
|
7
|
+
'Systematic debugging for common everystack issues. Provides diagnostic steps based on the symptom.',
|
|
8
|
+
{
|
|
9
|
+
symptom: z.string().describe('Description of the problem (e.g., "401 on all API requests", "RLS blocking reads", "Lambda timeout")'),
|
|
10
|
+
projectPath: z.string().optional().describe('Absolute path to project root'),
|
|
11
|
+
},
|
|
12
|
+
async ({ symptom, projectPath }) => {
|
|
13
|
+
return {
|
|
14
|
+
messages: [
|
|
15
|
+
{
|
|
16
|
+
role: 'user' as const,
|
|
17
|
+
content: {
|
|
18
|
+
type: 'text' as const,
|
|
19
|
+
text: [
|
|
20
|
+
`Debug this issue: ${symptom}`,
|
|
21
|
+
'',
|
|
22
|
+
'## Instructions',
|
|
23
|
+
'',
|
|
24
|
+
'1. Read everystack://core for architecture context.',
|
|
25
|
+
projectPath ? `2. Run project_status with projectPath="${projectPath}" to understand the project.` : '',
|
|
26
|
+
projectPath ? `3. Run project_validate with projectPath="${projectPath}" to find configuration issues.` : '',
|
|
27
|
+
projectPath ? `4. Run schema_analyze with projectPath="${projectPath}" to check schema/handler alignment.` : '',
|
|
28
|
+
'',
|
|
29
|
+
'## Diagnostic Framework',
|
|
30
|
+
'',
|
|
31
|
+
'Work through these categories systematically:',
|
|
32
|
+
'',
|
|
33
|
+
'### 1. Authentication Issues (401/403)',
|
|
34
|
+
'',
|
|
35
|
+
'If the symptom involves authentication or authorization:',
|
|
36
|
+
'',
|
|
37
|
+
'- **Check token flow:**',
|
|
38
|
+
' - Is the JWT being sent in the Authorization header?',
|
|
39
|
+
' - Is the token expired? Decode at jwt.io and check `exp`',
|
|
40
|
+
' - Does `auth.verifyToken` return a valid payload?',
|
|
41
|
+
'',
|
|
42
|
+
'- **Check publicRoutes:**',
|
|
43
|
+
' - Is the route supposed to be public? Check `auth.publicRoutes` in handler config',
|
|
44
|
+
' - Is the RPC in `auth.publicRpc`?',
|
|
45
|
+
'',
|
|
46
|
+
'- **Check pgSettings:**',
|
|
47
|
+
' - Is `pgSettings` configured in the handler?',
|
|
48
|
+
' - Does it set `role` and `request.jwt.claims`?',
|
|
49
|
+
' - Test with: `SELECT current_setting(\'request.jwt.claims\', true);`',
|
|
50
|
+
'',
|
|
51
|
+
'### 2. RLS Issues (empty results, permission denied)',
|
|
52
|
+
'',
|
|
53
|
+
'Read everystack://security for RLS debugging.',
|
|
54
|
+
'',
|
|
55
|
+
'- **Check RLS is enabled:**',
|
|
56
|
+
' ```sql',
|
|
57
|
+
' SELECT tablename, rowsecurity FROM pg_tables WHERE schemaname = \'public\';',
|
|
58
|
+
' ```',
|
|
59
|
+
'',
|
|
60
|
+
'- **Check policies exist:**',
|
|
61
|
+
' ```sql',
|
|
62
|
+
' SELECT * FROM pg_policies WHERE schemaname = \'public\';',
|
|
63
|
+
' ```',
|
|
64
|
+
'',
|
|
65
|
+
'- **Test as specific role:**',
|
|
66
|
+
' ```sql',
|
|
67
|
+
' SET LOCAL ROLE authenticated;',
|
|
68
|
+
' SELECT set_config(\'request.jwt.claims\', \'{"sub":"user-id","role":"authenticated"}\', true);',
|
|
69
|
+
' SELECT * FROM your_table;',
|
|
70
|
+
' ```',
|
|
71
|
+
'',
|
|
72
|
+
'- **Common RLS mistakes:**',
|
|
73
|
+
' - Policy references wrong claim path (sub vs user_id)',
|
|
74
|
+
' - USING clause doesn\'t match the data (e.g., UUID vs text comparison)',
|
|
75
|
+
' - Missing policy for the operation (SELECT exists but not INSERT)',
|
|
76
|
+
' - Forgot `WITH CHECK` on INSERT/UPDATE policies',
|
|
77
|
+
'',
|
|
78
|
+
'### 3. Query Issues (wrong data, missing relations)',
|
|
79
|
+
'',
|
|
80
|
+
'Read everystack://query-protocol for filter syntax.',
|
|
81
|
+
'',
|
|
82
|
+
'- **Check relations config:**',
|
|
83
|
+
' - Does the handler `relations` config match the Drizzle schema relations?',
|
|
84
|
+
' - Is the relation direction correct (from/to)?',
|
|
85
|
+
'',
|
|
86
|
+
'- **Check column names:**',
|
|
87
|
+
' - Handler uses camelCase by default. Database uses snake_case.',
|
|
88
|
+
' - Check `naming` option in handler config.',
|
|
89
|
+
'',
|
|
90
|
+
'### 4. Deployment Issues',
|
|
91
|
+
'',
|
|
92
|
+
'Read everystack://deployment and everystack://cli.',
|
|
93
|
+
'',
|
|
94
|
+
'- **Lambda errors:**',
|
|
95
|
+
' ```bash',
|
|
96
|
+
' everystack logs:errors --stage dev',
|
|
97
|
+
' everystack logs:tail --stage dev',
|
|
98
|
+
' ```',
|
|
99
|
+
'',
|
|
100
|
+
'- **Database connection:**',
|
|
101
|
+
' ```bash',
|
|
102
|
+
' everystack db:psql --stage dev',
|
|
103
|
+
' everystack diag --stage dev',
|
|
104
|
+
' ```',
|
|
105
|
+
'',
|
|
106
|
+
'- **Common deployment issues:**',
|
|
107
|
+
' - Missing secrets: `pnpm sst secret list --stage dev`',
|
|
108
|
+
' - VPC configuration: Lambda can\'t reach RDS without proper VPC setup',
|
|
109
|
+
' - Bundle size: Check if unnecessary packages are bundled',
|
|
110
|
+
'',
|
|
111
|
+
'### 5. Performance Issues',
|
|
112
|
+
'',
|
|
113
|
+
'- **Slow queries:**',
|
|
114
|
+
' - Check for missing indexes on filtered/joined columns',
|
|
115
|
+
' - Check `maxLimit` and `maxEmbedDepth` in handler config',
|
|
116
|
+
' - Use `EXPLAIN ANALYZE` on slow queries',
|
|
117
|
+
'',
|
|
118
|
+
'- **Cold starts:**',
|
|
119
|
+
' - Minimize Lambda bundle size',
|
|
120
|
+
' - Use provisioned concurrency for production',
|
|
121
|
+
'',
|
|
122
|
+
'## Resolution',
|
|
123
|
+
'',
|
|
124
|
+
'After diagnosing:',
|
|
125
|
+
'1. Identify the root cause',
|
|
126
|
+
'2. Propose a fix with the specific code change',
|
|
127
|
+
'3. Verify the fix resolves the issue',
|
|
128
|
+
'4. Run project_validate to ensure no new issues were introduced',
|
|
129
|
+
].filter(Boolean).join('\n'),
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export function registerDeployPrompt(server: McpServer): void {
|
|
5
|
+
server.prompt(
|
|
6
|
+
'deploy',
|
|
7
|
+
'Step-by-step deployment walkthrough for a specific stage. Covers AWS credentials, SST deploy, migrations, and verification.',
|
|
8
|
+
{
|
|
9
|
+
stage: z.enum(['dev', 'staging', 'production']).describe('Deployment stage'),
|
|
10
|
+
projectPath: z.string().optional().describe('Absolute path to project root'),
|
|
11
|
+
},
|
|
12
|
+
async ({ stage, projectPath }) => {
|
|
13
|
+
const isProduction = stage === 'production';
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
messages: [
|
|
17
|
+
{
|
|
18
|
+
role: 'user' as const,
|
|
19
|
+
content: {
|
|
20
|
+
type: 'text' as const,
|
|
21
|
+
text: [
|
|
22
|
+
`Deploy to ${stage}.`,
|
|
23
|
+
'',
|
|
24
|
+
'## Instructions',
|
|
25
|
+
'',
|
|
26
|
+
'1. Read everystack://deployment for infrastructure setup.',
|
|
27
|
+
'2. Read everystack://security for AWS credential setup and deployment checklist.',
|
|
28
|
+
projectPath ? `3. Run project_validate with projectPath="${projectPath}" to check for issues before deploying.` : '',
|
|
29
|
+
projectPath ? `4. Run project_status with projectPath="${projectPath}" to see current deployment state.` : '',
|
|
30
|
+
'',
|
|
31
|
+
'## Pre-Deploy Checklist',
|
|
32
|
+
'',
|
|
33
|
+
'### AWS Credentials',
|
|
34
|
+
'',
|
|
35
|
+
'1. Verify the correct AWS profile is configured:',
|
|
36
|
+
` - ${stage === 'dev' ? '`everystack-manage` — for development deploys and CLI operations' : ''}`,
|
|
37
|
+
` - ${isProduction ? '`everystack-deploy` — for CI/CD production deploys (limited permissions)' : ''}`,
|
|
38
|
+
'2. Run `aws sts get-caller-identity` to verify the active profile',
|
|
39
|
+
'3. Ensure `everystack-create` profile is DISABLED unless first deploy',
|
|
40
|
+
'',
|
|
41
|
+
'### Secrets',
|
|
42
|
+
'',
|
|
43
|
+
'Set required secrets for this stage:',
|
|
44
|
+
'```bash',
|
|
45
|
+
`pnpm sst secret set JwtSecret "$(openssl rand -base64 32)" --stage ${stage}`,
|
|
46
|
+
'```',
|
|
47
|
+
'',
|
|
48
|
+
isProduction ? [
|
|
49
|
+
'### Production Safety',
|
|
50
|
+
'',
|
|
51
|
+
'- [ ] All tests pass: `pnpm test`',
|
|
52
|
+
'- [ ] No security warnings: run project_validate',
|
|
53
|
+
'- [ ] RLS policies are in place for all tables',
|
|
54
|
+
'- [ ] pgSettings is configured in handler',
|
|
55
|
+
'- [ ] No hardcoded secrets in source',
|
|
56
|
+
'- [ ] .env files are not committed',
|
|
57
|
+
'',
|
|
58
|
+
].join('\n') : '',
|
|
59
|
+
'## Deploy Steps',
|
|
60
|
+
'',
|
|
61
|
+
'### 1. Build',
|
|
62
|
+
'```bash',
|
|
63
|
+
'pnpm export # Expo export (builds dist/)',
|
|
64
|
+
'```',
|
|
65
|
+
'',
|
|
66
|
+
'### 2. Deploy Infrastructure',
|
|
67
|
+
'```bash',
|
|
68
|
+
`pnpm sst deploy --stage ${stage}`,
|
|
69
|
+
'```',
|
|
70
|
+
'',
|
|
71
|
+
'This creates/updates:',
|
|
72
|
+
'- S3 bucket for static assets',
|
|
73
|
+
'- CloudFront distribution',
|
|
74
|
+
'- Lambda functions',
|
|
75
|
+
'- RDS Aurora Serverless (V2+)',
|
|
76
|
+
'- SQS queues (V3)',
|
|
77
|
+
'- IAM roles and policies',
|
|
78
|
+
'',
|
|
79
|
+
'### 3. Database Setup (V2+)',
|
|
80
|
+
'```bash',
|
|
81
|
+
`everystack db:migrate --stage ${stage}`,
|
|
82
|
+
stage === 'dev' ? `everystack db:seed --stage ${stage} # dev only` : '',
|
|
83
|
+
'```',
|
|
84
|
+
'',
|
|
85
|
+
'### 4. Verify',
|
|
86
|
+
'```bash',
|
|
87
|
+
'# Check Lambda logs',
|
|
88
|
+
`everystack logs:tail --stage ${stage}`,
|
|
89
|
+
'',
|
|
90
|
+
'# Test the API',
|
|
91
|
+
`curl https://your-domain/api/health`,
|
|
92
|
+
'',
|
|
93
|
+
`# Connect to database (${stage})`,
|
|
94
|
+
`everystack db:psql --stage ${stage}`,
|
|
95
|
+
'```',
|
|
96
|
+
'',
|
|
97
|
+
'## Post-Deploy',
|
|
98
|
+
'',
|
|
99
|
+
'### OTA Updates (no redeploy needed)',
|
|
100
|
+
'```bash',
|
|
101
|
+
`everystack update --channel ${stage === 'production' ? 'production' : stage} --message "Description"`,
|
|
102
|
+
'```',
|
|
103
|
+
'',
|
|
104
|
+
isProduction ? [
|
|
105
|
+
'### Production Monitoring',
|
|
106
|
+
'',
|
|
107
|
+
'- Check CloudWatch for Lambda errors',
|
|
108
|
+
'- Monitor RDS connection count',
|
|
109
|
+
'- Verify CDN cache hit rates',
|
|
110
|
+
'- Set up CloudWatch alarms for error rates',
|
|
111
|
+
].join('\n') : '',
|
|
112
|
+
'',
|
|
113
|
+
'## Rollback',
|
|
114
|
+
'',
|
|
115
|
+
'If something goes wrong:',
|
|
116
|
+
'```bash',
|
|
117
|
+
'# Revert to previous OTA update',
|
|
118
|
+
`everystack update --channel ${stage === 'production' ? 'production' : stage} --rollback`,
|
|
119
|
+
'',
|
|
120
|
+
'# For infrastructure changes, redeploy from a known good commit',
|
|
121
|
+
'git checkout <good-commit>',
|
|
122
|
+
`pnpm sst deploy --stage ${stage}`,
|
|
123
|
+
'```',
|
|
124
|
+
].filter(Boolean).join('\n'),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
}
|