@cronicorn/mcp-server 1.5.9 → 1.6.1

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.
@@ -0,0 +1,197 @@
1
+ ---
2
+ id: environment-configuration
3
+ title: Environment Configuration
4
+ description: Understanding Cronicorn's zero-config approach and environment variables
5
+ tags:
6
+ - developer
7
+ - configuration
8
+ - setup
9
+ sidebar_position: 2
10
+ ---
11
+
12
+ # Environment Configuration
13
+
14
+ ## Zero-Config Local Development
15
+
16
+ Cronicorn is designed for **zero-configuration local development**. All environment variables have sensible defaults, so you can run the entire stack without creating a `.env` file.
17
+
18
+ ```bash
19
+ # That's it - no .env file needed!
20
+ pnpm install
21
+ pnpm db
22
+ pnpm db:migrate
23
+ pnpm dev
24
+ ```
25
+
26
+ Login at http://localhost:5173 with:
27
+ - Email: `admin@example.com`
28
+ - Password: `devpassword`
29
+
30
+ ## How It Works
31
+
32
+ ### Centralized Defaults
33
+
34
+ All default values are maintained in a single package: `@cronicorn/config-defaults`
35
+
36
+ This ensures:
37
+ - **Consistency** - Same defaults across all apps (API, scheduler, ai-planner, web)
38
+ - **Maintainability** - One place to update defaults
39
+ - **Type safety** - TypeScript constants prevent typos
40
+ - **Security** - Production validation prevents using dev defaults
41
+
42
+ ### Development Defaults
43
+
44
+ | Category | Variable | Default Value |
45
+ |----------|----------|---------------|
46
+ | **Ports** | API_PORT | 3333 |
47
+ | | WEB_PORT | 5173 |
48
+ | | DB_PORT | 6666 |
49
+ | **Database** | DATABASE_URL | postgresql://user:password@localhost:6666/db |
50
+ | **Auth** | ADMIN_USER_EMAIL | admin@example.com |
51
+ | | ADMIN_USER_PASSWORD | devpassword |
52
+ | | BETTER_AUTH_SECRET | dev-secret-DO-NOT-USE-IN-PRODUCTION-min32chars |
53
+ | **URLs** | BETTER_AUTH_URL | http://localhost:3333 |
54
+ | | WEB_URL | http://localhost:5173 |
55
+ | | API_URL | http://localhost:3333 |
56
+ | **Stripe** | STRIPE_SECRET_KEY | sk_test_dummy_key_for_local_dev_only |
57
+ | | STRIPE_WEBHOOK_SECRET | whsec_test_dummy_secret_for_local_dev |
58
+
59
+ ⚠️ **Security Warning**: These are insecure defaults for local development only. Production deployments MUST override these values.
60
+
61
+ ## Customizing Configuration
62
+
63
+
64
+ ### Full Configuration (.env.example)
65
+
66
+ For production or advanced setup:
67
+
68
+ ```bash
69
+ # Copy the full example
70
+ cp .env.example .env
71
+
72
+ # Edit with your production values
73
+ vim .env
74
+ ```
75
+
76
+ See all available variables with descriptions in `.env.example`.
77
+
78
+ ## Production Deployment
79
+
80
+ ### Required Changes
81
+
82
+ Production deployments MUST set these variables:
83
+
84
+ ```bash
85
+ # 1. Secure auth secret (generate with: openssl rand -base64 32)
86
+ BETTER_AUTH_SECRET=your-secure-random-secret-min-32-chars
87
+
88
+ # 2. Choose authentication method:
89
+ # Option A: Admin User
90
+ ADMIN_USER_EMAIL=admin@yourcompany.com
91
+ ADMIN_USER_PASSWORD=strong-unique-password
92
+
93
+ # Option B: GitHub OAuth
94
+ GITHUB_CLIENT_ID=your_github_client_id
95
+ GITHUB_CLIENT_SECRET=your_github_client_secret
96
+
97
+ # 3. Real Stripe keys (if using payments)
98
+ STRIPE_SECRET_KEY=sk_live_your_production_key
99
+ STRIPE_WEBHOOK_SECRET=whsec_your_production_webhook_secret
100
+ STRIPE_PRICE_PRO=price_live_pro_monthly
101
+ STRIPE_PRICE_ENTERPRISE=price_live_enterprise_monthly
102
+
103
+ # 4. Production URLs
104
+ BASE_URL=https://your-production-domain.com
105
+ WEB_URL=https://your-production-domain.com
106
+ API_URL=https://api.your-production-domain.com
107
+ BETTER_AUTH_URL=https://api.your-production-domain.com
108
+ ```
109
+
110
+ ### Production Validation
111
+
112
+ The application automatically validates that dev defaults are not used in production:
113
+
114
+ ```typescript
115
+ // Automatically runs on startup in production
116
+ if (NODE_ENV === "production") {
117
+ // Checks BETTER_AUTH_SECRET, ADMIN_USER_PASSWORD, STRIPE_SECRET_KEY
118
+ // Exits with error if using dev defaults
119
+ }
120
+ ```
121
+
122
+ ## Configuration Architecture
123
+
124
+ ### Per-App Config Files
125
+
126
+ Each app has its own configuration file that imports shared defaults:
127
+
128
+ ```
129
+ apps/
130
+ api/src/lib/config.ts # API server config
131
+ scheduler/src/index.ts # Scheduler worker config
132
+ ai-planner/src/index.ts # AI planner config
133
+ web/src/config.ts # Web app config
134
+ ```
135
+
136
+ ### Shared Defaults Package
137
+
138
+ ```
139
+ packages/
140
+ config-defaults/
141
+ src/index.ts # Single source of truth
142
+ README.md # Usage documentation
143
+ ```
144
+
145
+ ## Best Practices
146
+
147
+ ### Local Development
148
+ - ✅ Use defaults (empty .env or .env.minimal)
149
+ - ✅ Override only what you need to test
150
+ - ✅ Keep .env out of git (already in .gitignore)
151
+
152
+ ### Production
153
+ - ✅ Set all required variables explicitly
154
+ - ✅ Use secure secrets (never dev defaults)
155
+ - ✅ Validate with `NODE_ENV=production` locally first
156
+ - ✅ Use environment-specific .env files (.env.production, .env.staging)
157
+
158
+ ### Team Development
159
+ - ✅ Document custom local overrides in team wiki (not in .env)
160
+ - ✅ Keep .env.example up to date
161
+ - ✅ Use the same default ports to avoid conflicts
162
+ - ✅ Update shared defaults in config-defaults package only
163
+
164
+ ## Troubleshooting
165
+
166
+ ### "Cannot find module @cronicorn/config-defaults"
167
+
168
+ Run `pnpm build:packages` to build the shared config package:
169
+
170
+ ```bash
171
+ pnpm build:packages
172
+ ```
173
+
174
+ ### "Environment variable validation failed"
175
+
176
+ Check the error message for which variable is invalid:
177
+
178
+ ```bash
179
+ # See current environment
180
+ pnpm exec dotenv -e .env -- env | grep -E "(DATABASE_URL|STRIPE|ADMIN|GITHUB)"
181
+ ```
182
+
183
+ ### "Auth not working in production"
184
+
185
+ Ensure you've overridden the dev defaults:
186
+
187
+ ```bash
188
+ # Never use these in production:
189
+ ADMIN_USER_PASSWORD=devpassword # ❌
190
+ BETTER_AUTH_SECRET=dev-secret-DO-NOT-USE-IN-PRODUCTION-min32chars # ❌
191
+ ```
192
+
193
+ ## Related
194
+
195
+ - **[Quick Start](./quick-start.md)** - Get started with development
196
+ - **[Quality Checks](./quality-checks.md)** - Testing and validation
197
+ - **[Workspace Structure](./workspace-structure.md)** - Project organization
@@ -0,0 +1,68 @@
1
+ ---
2
+ id: developer-quality-checks
3
+ title: Quality Checks
4
+ description: Required quality checks before committing and merging code
5
+ tags:
6
+ - developer
7
+ - quality
8
+ - testing
9
+ sidebar_position: 4
10
+ mcp:
11
+ uri: file:///docs/developers/quality-checks.md
12
+ mimeType: text/markdown
13
+ priority: 0.75
14
+ ---
15
+
16
+ # Quality Checks
17
+
18
+ ## Before Commit
19
+
20
+ ```bash
21
+ pnpm test # Unit & integration tests (excludes e2e)
22
+ pnpm lint # Check for errors
23
+ pnpm build:packages # Ensure types compile
24
+ ```
25
+
26
+ ## Before Merge
27
+
28
+ ```bash
29
+ pnpm test # Full test suite (excludes e2e)
30
+ pnpm lint:fix # Fix and verify (zero warnings)
31
+ pnpm build # Full build
32
+ pnpm test:e2e # E2E tests (separate command)
33
+ ```
34
+
35
+ ## What to Test
36
+
37
+ | Change | Test Type |
38
+ |--------|-----------|
39
+ | Domain logic | Unit tests (mocked ports) |
40
+ | Repositories | Integration tests (transaction-per-test) |
41
+ | API routes | API + integration tests |
42
+ | Bug fixes | Regression test |
43
+
44
+ **Coverage**: 80%+ for managers/services
45
+
46
+ ## Common Fixes
47
+
48
+ **Tests fail**: `pnpm db` (ensure database running)
49
+ **Module errors**: `pnpm build:packages`
50
+ **Lint errors**: `pnpm lint:fix` (auto-fix most issues)
51
+
52
+ ## Checklist
53
+
54
+ **Before Commit**
55
+ - [ ] Tests pass for changed packages
56
+ - [ ] No lint errors
57
+ - [ ] Packages build
58
+
59
+ **Before Merge**
60
+ - [ ] Full test suite passes
61
+ - [ ] Full build succeeds
62
+ - [ ] Zero lint warnings
63
+ - [ ] E2E tests pass (if applicable)
64
+ - [ ] ADR created (if architectural decision)
65
+
66
+ ## Related
67
+
68
+ - **[Quick Start](./quick-start.md)** - Dev environment setup
@@ -0,0 +1,84 @@
1
+ ---
2
+ id: developer-quick-start
3
+ title: Developer Quick Start
4
+ description: Set up your Cronicorn development environment in 4 steps
5
+ tags:
6
+ - developer
7
+ - essential
8
+ sidebar_position: 1
9
+ mcp:
10
+ uri: file:///docs/developers/quick-start.md
11
+ mimeType: text/markdown
12
+ priority: 0.9
13
+ ---
14
+
15
+ # Developer Quick Start
16
+
17
+ Get Cronicorn running locally in 4 steps.
18
+
19
+ ## Prerequisites
20
+
21
+ - Node.js 24+ and pnpm 10+
22
+ - Docker (for PostgreSQL)
23
+
24
+ ## Setup
25
+
26
+ ```bash
27
+ # 1. Clone and install
28
+ git clone https://github.com/weskerllc/cronicorn.git
29
+ cd cronicorn
30
+ pnpm install # Auto-builds packages
31
+
32
+ # 2. Configure authentication (optional - use defaults)
33
+ cp .env.example .env
34
+ # Edit .env and uncomment ADMIN_USER_EMAIL and ADMIN_USER_PASSWORD
35
+ # Or leave as-is to use GitHub OAuth (requires setup)
36
+
37
+ # 3. Start database
38
+ pnpm db
39
+
40
+ # 4. Run migrations
41
+ pnpm db:migrate
42
+
43
+ # 5. Start development
44
+ pnpm dev
45
+ ```
46
+
47
+ **Login**: Open http://localhost:5173
48
+
49
+ - **Admin User**: Use email/password from your `.env` file
50
+ - **GitHub OAuth**: Click "Sign in with GitHub" (if configured)
51
+
52
+ > 💡 **Tip**: For local dev, uncomment the admin user credentials in `.env` for instant login without OAuth setup.
53
+
54
+ > ⚠️ You'll see a warning about `OPENAI_API_KEY` - this is normal. AI features are optional.
55
+
56
+ ## Common Commands
57
+
58
+ | Command | Description |
59
+ |---------|-------------|
60
+ | `pnpm dev` | Start all services |
61
+ | `pnpm dev:api` | API server only |
62
+ | `pnpm dev:web` | Web app only |
63
+ | `pnpm db` | Start PostgreSQL |
64
+ | `pnpm db:migrate` | Run migrations |
65
+ | `pnpm db:reset` | Reset db |
66
+ | `pnpm db:generate` | Generate migrations when you make schema changes |
67
+ | `pnpm studio` | Database Browser |
68
+ | `pnpm build` | Production build |
69
+
70
+ ## Troubleshooting
71
+
72
+ **Can't login?**
73
+ → Check `.env` has either admin user credentials uncommented OR GitHub OAuth configured
74
+
75
+ **Module errors?**
76
+ → `pnpm build:packages`
77
+
78
+ **Database errors?**
79
+ → Ensure Docker is running, then `pnpm db`
80
+
81
+ ## Next Steps
82
+
83
+ - [Authentication](./authentication.md) - Configure authentication methods
84
+ - [Architecture](../technical/system-architecture.md) - System design
@@ -0,0 +1,179 @@
1
+ ---
2
+ id: developer-workspace-structure
3
+ title: Workspace Structure
4
+ description: Overview of monorepo workspaces (apps and packages)
5
+ tags:
6
+ - developer
7
+ - architecture
8
+ sidebar_position: 3
9
+ mcp:
10
+ uri: file:///docs/developers/workspace-structure.md
11
+ mimeType: text/markdown
12
+ priority: 0.7
13
+ ---
14
+
15
+ # Workspace Structure
16
+
17
+ Cronicorn is organized as a pnpm monorepo with 8 apps and 13 packages. This guide helps you quickly locate code for specific features.
18
+
19
+ ## Apps (8)
20
+
21
+ Deployable applications and services.
22
+
23
+ ### `@cronicorn/api`
24
+ HTTP API server using Hono framework with OpenAPI/Swagger support and Better Auth authentication.
25
+ - **Tech**: Hono, Zod, Better Auth, Drizzle ORM
26
+ - **Port**: Configurable via env
27
+ - **Location**: `apps/api/`
28
+
29
+ ### `@cronicorn/web`
30
+ Frontend web application built with React and TanStack Router.
31
+ - **Tech**: React 19, TanStack Router, Vite, Tailwind CSS 4
32
+ - **Dev**: Vite dev server with HMR
33
+ - **Location**: `apps/web/`
34
+
35
+ ### `@cronicorn/scheduler-app`
36
+ Background worker that claims and executes scheduled job endpoints.
37
+ - **Tech**: Pino logging, Drizzle ORM, HTTP dispatcher
38
+ - **Purpose**: Main scheduling loop execution
39
+ - **Location**: `apps/scheduler/`
40
+
41
+ ### `@cronicorn/ai-planner-app`
42
+ AI-powered worker that optimizes scheduling decisions using OpenAI.
43
+ - **Tech**: Vercel AI SDK, OpenAI provider
44
+ - **Purpose**: Adaptive scheduling intelligence
45
+ - **Location**: `apps/ai-planner/`
46
+
47
+ ### `@cronicorn/docs`
48
+ Docusaurus-based documentation website.
49
+ - **Tech**: Docusaurus 3.9.2
50
+ - **Purpose**: Public and developer documentation
51
+ - **Location**: `apps/docs/`
52
+
53
+ ### `@cronicorn/mcp-server`
54
+ Model Context Protocol server enabling AI agents to manage cron jobs.
55
+ - **Tech**: MCP SDK
56
+ - **Published**: Yes (public npm package)
57
+ - **Binary**: `cronicorn-mcp`
58
+ - **Location**: `apps/mcp-server/`
59
+
60
+ ### `@cronicorn/migrator`
61
+ Database migration runner using Drizzle Kit.
62
+ - **Purpose**: Run migrations on startup or manually
63
+ - **Location**: `apps/migrator/`
64
+
65
+ ### `@cronicorn/test-ai`
66
+ Test harness for AI integration experiments.
67
+ - **Purpose**: Development/testing only
68
+ - **Location**: `apps/test-ai/`
69
+
70
+ ---
71
+
72
+ ## Packages (13)
73
+
74
+ Shared libraries and adapters used by apps.
75
+
76
+ ### Adapters (7)
77
+
78
+ Implement domain ports using external libraries/services.
79
+
80
+ #### `@cronicorn/adapter-ai`
81
+ AI SDK integration with mock support (MSW).
82
+ - **Location**: `packages/adapter-ai/`
83
+
84
+ #### `@cronicorn/adapter-cron`
85
+ Cron expression parsing using cron-parser.
86
+ - **Location**: `packages/adapter-cron/`
87
+
88
+ #### `@cronicorn/adapter-drizzle`
89
+ PostgreSQL database adapter with Drizzle ORM schema and repositories.
90
+ - **Location**: `packages/adapter-drizzle/`
91
+
92
+ #### `@cronicorn/adapter-http`
93
+ HTTP request dispatcher for endpoint execution.
94
+ - **Location**: `packages/adapter-http/`
95
+
96
+ #### `@cronicorn/adapter-pino`
97
+ Structured logging with Pino.
98
+ - **Location**: `packages/adapter-pino/`
99
+
100
+ #### `@cronicorn/adapter-stripe`
101
+ Stripe payment integration for subscriptions.
102
+ - **Location**: `packages/adapter-stripe/`
103
+
104
+ #### `@cronicorn/adapter-system-clock`
105
+ System clock implementation for production (vs fake clock for tests).
106
+ - **Location**: `packages/adapter-system-clock/`
107
+
108
+ ### Core Domain (3)
109
+
110
+ #### `@cronicorn/domain`
111
+ Pure domain logic: ports, entities, policies, governor, scheduler (no external dependencies except Zod).
112
+ - **Location**: `packages/domain/`
113
+ - **Key**: All business rules live here
114
+
115
+ #### `@cronicorn/services`
116
+ Business logic layer: job management, scheduling services.
117
+ - **Location**: `packages/services/`
118
+
119
+ #### `@cronicorn/api-contracts`
120
+ OpenAPI contracts and Zod schemas for HTTP API routes (shared between API and Web).
121
+ - **Location**: `packages/api-contracts/`
122
+
123
+ ### Workers (2)
124
+
125
+ #### `@cronicorn/worker-scheduler`
126
+ Core scheduling worker logic with simulation support.
127
+ - **Script**: `pnpm sim` runs deterministic scenarios
128
+ - **Location**: `packages/worker-scheduler/`
129
+
130
+ #### `@cronicorn/worker-ai-planner`
131
+ AI planner worker logic (orchestrates AI hints and nudges).
132
+ - **Location**: `packages/worker-ai-planner/`
133
+
134
+ ### UI (1)
135
+
136
+ #### `@cronicorn/ui-library`
137
+ Shared React component library using shadcn/ui with Radix UI primitives.
138
+ - **Tech**: Tailwind CSS 4, Radix UI, React Hook Form, Recharts
139
+ - **Location**: `packages/ui-library/`
140
+
141
+ ### Content (1)
142
+
143
+ #### `@cronicorn/content`
144
+ Centralized content: brand assets, pricing, FAQs, SEO metadata, business copy.
145
+ - **Exports**: Multiple subpaths (brand, pricing, docs, seo, etc.)
146
+ - **Location**: `packages/content/`
147
+
148
+ ---
149
+
150
+ ## Other folders
151
+
152
+ #### `/docs`
153
+ Central docs folder that is used by the docs app and mcp-server
154
+
155
+
156
+ ## Key Architecture Notes
157
+
158
+ - **Monorepo**: pnpm workspaces with TypeScript project references
159
+ - **Build**: Packages build with `tsc`, apps use `tsx` (dev) or `tsc` (prod)
160
+ - **Env**: Single `.env` file at root, loaded via `dotenv-cli`
161
+ - **Testing**: Vitest with transaction-per-test pattern
162
+ - **Ports & Adapters**: Clean separation between domain and infrastructure
163
+
164
+ ## Finding Code
165
+
166
+ | Looking for... | Check... |
167
+ |----------------|----------|
168
+ | API routes | `apps/api/src/routes/` |
169
+ | Database schema | `packages/adapter-drizzle/src/schema/` |
170
+ | Scheduling logic | `packages/domain/src/scheduler.ts` |
171
+ | UI components | `packages/ui-library/src/components/` |
172
+ | AI prompts | `packages/worker-ai-planner/src/` |
173
+ | HTTP dispatcher | `packages/adapter-http/` |
174
+ | Business logic | `packages/services/` |
175
+
176
+ ## Next Steps
177
+
178
+ - **[System Architecture](../technical/system-architecture.md)** - How components interact at runtime
179
+ - **[Quick Start](./quick-start.md)** - Set up your dev environment