@vurb/core 3.12.1 → 3.12.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.
@@ -82,263 +82,263 @@ export function cloudflareTsconfig() {
82
82
  }
83
83
  /** Generate `wrangler.toml` */
84
84
  export function cloudflareWranglerToml(config) {
85
- return `name = "${config.name}"
86
- main = "src/worker.ts"
87
- compatibility_date = "2024-12-01"
88
- compatibility_flags = ["nodejs_compat"]
89
-
90
- # ── Bindings ────────────────────────────────────────
91
- # Uncomment to enable Cloudflare services:
92
-
93
- # [vars]
94
- # MY_SECRET = "value"
95
-
96
- # [[d1_databases]]
97
- # binding = "DB"
98
- # database_name = "${config.name}-db"
99
- # database_id = "<your-database-id>"
100
-
101
- # [[kv_namespaces]]
102
- # binding = "KV"
103
- # id = "<your-kv-namespace-id>"
104
-
105
- # [[r2_buckets]]
106
- # binding = "BUCKET"
107
- # bucket_name = "${config.name}-bucket"
85
+ return `name = "${config.name}"
86
+ main = "src/worker.ts"
87
+ compatibility_date = "2024-12-01"
88
+ compatibility_flags = ["nodejs_compat"]
89
+
90
+ # ── Bindings ────────────────────────────────────────
91
+ # Uncomment to enable Cloudflare services:
92
+
93
+ # [vars]
94
+ # MY_SECRET = "value"
95
+
96
+ # [[d1_databases]]
97
+ # binding = "DB"
98
+ # database_name = "${config.name}-db"
99
+ # database_id = "<your-database-id>"
100
+
101
+ # [[kv_namespaces]]
102
+ # binding = "KV"
103
+ # id = "<your-kv-namespace-id>"
104
+
105
+ # [[r2_buckets]]
106
+ # binding = "BUCKET"
107
+ # bucket_name = "${config.name}-bucket"
108
108
  `;
109
109
  }
110
110
  /** Generate `src/worker.ts` — The Worker entry point */
111
111
  export function cloudflareWorkerTs(config) {
112
- return `/**
113
- * Cloudflare Worker — MCP Server
114
- *
115
- * Exposes your Vurb tools as a stateless MCP endpoint.
116
- * Connect any MCP client to: POST https://your-worker.workers.dev/
117
- */
118
- import { cloudflareWorkersAdapter } from '@vurb/cloudflare';
119
- import { registry } from './registry.js';
120
- import { createContext } from './context.js';
121
-
122
- export interface Env {
123
- // Add your Cloudflare bindings here:
124
- // DB: D1Database;
125
- // KV: KVNamespace;
126
- // BUCKET: R2Bucket;
127
- }
128
-
129
- export default cloudflareWorkersAdapter<Env, ReturnType<typeof createContext>>({
130
- registry,
131
- serverName: '${config.name}',
132
- contextFactory: async (req, env) => createContext(),
133
- });
112
+ return `/**
113
+ * Cloudflare Worker — MCP Server
114
+ *
115
+ * Exposes your Vurb tools as a stateless MCP endpoint.
116
+ * Connect any MCP client to: POST https://your-worker.workers.dev/
117
+ */
118
+ import { cloudflareWorkersAdapter } from '@vurb/cloudflare';
119
+ import { registry } from './registry.js';
120
+ import { createContext } from './context.js';
121
+
122
+ export interface Env {
123
+ // Add your Cloudflare bindings here:
124
+ // DB: D1Database;
125
+ // KV: KVNamespace;
126
+ // BUCKET: R2Bucket;
127
+ }
128
+
129
+ export default cloudflareWorkersAdapter<Env, ReturnType<typeof createContext>>({
130
+ registry,
131
+ serverName: '${config.name}',
132
+ contextFactory: async (req, env) => createContext(),
133
+ });
134
134
  `;
135
135
  }
136
136
  /** Generate `src/registry.ts` — Tool registry (cold-start) */
137
137
  export function cloudflareRegistryTs() {
138
- return `/**
139
- * Tool Registry — Cold Start Initialization
140
- *
141
- * Registered tools are compiled once during cold start.
142
- * Warm requests only instantiate McpServer + Transport.
143
- */
144
- import { f } from './vurb.js';
145
- import healthTool from './tools/system/health.js';
146
- import echoTool from './tools/system/echo.js';
147
-
148
- export const registry = f.registry();
149
- registry.register(healthTool);
150
- registry.register(echoTool);
138
+ return `/**
139
+ * Tool Registry — Cold Start Initialization
140
+ *
141
+ * Registered tools are compiled once during cold start.
142
+ * Warm requests only instantiate McpServer + Transport.
143
+ */
144
+ import { f } from './vurb.js';
145
+ import healthTool from './tools/system/health.js';
146
+ import echoTool from './tools/system/echo.js';
147
+
148
+ export const registry = f.registry();
149
+ registry.register(healthTool);
150
+ registry.register(echoTool);
151
151
  `;
152
152
  }
153
153
  /** Generate `src/vurb.ts` — initVurb instance */
154
154
  export function cloudflareVurbTs() {
155
- return `/**
156
- * Vurb Instance — Context Initialization
157
- *
158
- * Define your context type ONCE. Every f.query(), f.mutation(),
159
- * and f.presenter() call inherits AppContext.
160
- */
161
- import { initVurb } from '@vurb/core';
162
- import type { AppContext } from './context.js';
163
-
164
- export const f = initVurb<AppContext>();
155
+ return `/**
156
+ * Vurb Instance — Context Initialization
157
+ *
158
+ * Define your context type ONCE. Every f.query(), f.mutation(),
159
+ * and f.presenter() call inherits AppContext.
160
+ */
161
+ import { initVurb } from '@vurb/core';
162
+ import type { AppContext } from './context.js';
163
+
164
+ export const f = initVurb<AppContext>();
165
165
  `;
166
166
  }
167
167
  /** Generate `src/context.ts` — Application context */
168
168
  export function cloudflareContextTs() {
169
- return `/**
170
- * Application Context — Shared State for Every Tool Handler
171
- *
172
- * Every f.query() / f.mutation() handler receives (input, ctx)
173
- * where ctx is this AppContext.
174
- */
175
-
176
- export interface AppContext {
177
- /** Current user role for RBAC checks */
178
- role: 'ADMIN' | 'USER' | 'GUEST';
179
-
180
- /** Tenant identifier (multi-tenancy) */
181
- tenantId: string;
182
- }
183
-
184
- /**
185
- * Create the application context for each tool invocation.
186
- *
187
- * In production, hydrate from Cloudflare env bindings,
188
- * request headers, or secrets.
189
- */
190
- export function createContext(): AppContext {
191
- return {
192
- role: 'ADMIN',
193
- tenantId: 'default',
194
- };
195
- }
169
+ return `/**
170
+ * Application Context — Shared State for Every Tool Handler
171
+ *
172
+ * Every f.query() / f.mutation() handler receives (input, ctx)
173
+ * where ctx is this AppContext.
174
+ */
175
+
176
+ export interface AppContext {
177
+ /** Current user role for RBAC checks */
178
+ role: 'ADMIN' | 'USER' | 'GUEST';
179
+
180
+ /** Tenant identifier (multi-tenancy) */
181
+ tenantId: string;
182
+ }
183
+
184
+ /**
185
+ * Create the application context for each tool invocation.
186
+ *
187
+ * In production, hydrate from Cloudflare env bindings,
188
+ * request headers, or secrets.
189
+ */
190
+ export function createContext(): AppContext {
191
+ return {
192
+ role: 'ADMIN',
193
+ tenantId: 'default',
194
+ };
195
+ }
196
196
  `;
197
197
  }
198
198
  /** Generate `.env.example` for Cloudflare */
199
199
  export function cloudflareEnvExample(config) {
200
- let env = `# ── Vurb + Cloudflare Workers Environment ─────
201
- # Secrets are managed via wrangler:
202
- # wrangler secret put MY_SECRET
203
-
204
- NODE_ENV=development
200
+ let env = `# ── Vurb + Cloudflare Workers Environment ─────
201
+ # Secrets are managed via wrangler:
202
+ # wrangler secret put MY_SECRET
203
+
204
+ NODE_ENV=development
205
205
  `;
206
206
  if (config.vector === 'prisma') {
207
- env += `
208
- # Database (Prisma — Hyperdrive or external)
209
- DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
207
+ env += `
208
+ # Database (Prisma — Hyperdrive or external)
209
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
210
210
  `;
211
211
  }
212
212
  return env;
213
213
  }
214
214
  /** Generate `.gitignore` for Cloudflare Workers */
215
215
  export function cloudflareGitignore() {
216
- return `node_modules/
217
- dist/
218
- .wrangler/
219
- *.tsbuildinfo
220
- .env
221
- .dev.vars
222
- coverage/
216
+ return `node_modules/
217
+ dist/
218
+ .wrangler/
219
+ *.tsbuildinfo
220
+ .env
221
+ .dev.vars
222
+ coverage/
223
223
  `;
224
224
  }
225
225
  /** Generate `README.md` for Cloudflare project */
226
226
  export function cloudflareReadme(config) {
227
- return `# ${config.name}
228
-
229
- MCP Server built with [Vurb](https://vurb.vinkius.com/) — deployed to Cloudflare Workers.
230
-
231
- ## Quick Start
232
-
233
- \`\`\`bash
234
- npm install
235
- npm run dev
236
- \`\`\`
237
-
238
- The MCP endpoint is available at \`POST http://localhost:8787/\`.
239
-
240
- ## Deploy to Cloudflare
241
-
242
- \`\`\`bash
243
- npm run deploy
244
- \`\`\`
245
-
246
- Or directly:
247
-
248
- \`\`\`bash
249
- npx wrangler deploy
250
- \`\`\`
251
-
252
- ## Client Configuration
253
-
254
- ### Cursor / VS Code
255
-
256
- \`\`\`json
257
- {
258
- "mcpServers": {
259
- "${config.name}": {
260
- "url": "https://${config.name}.your-subdomain.workers.dev/"
261
- }
262
- }
263
- }
264
- \`\`\`
265
-
266
- ### Claude Desktop
267
-
268
- Add to your \`claude_desktop_config.json\`:
269
-
270
- \`\`\`json
271
- {
272
- "mcpServers": {
273
- "${config.name}": {
274
- "url": "https://${config.name}.your-subdomain.workers.dev/"
275
- }
276
- }
277
- }
278
- \`\`\`
279
-
280
- ## Project Structure
281
-
282
- \`\`\`
283
- src/
284
- ├── worker.ts # Worker entry → cloudflareWorkersAdapter()
285
- ├── vurb.ts # initVurb<AppContext>()
286
- ├── context.ts # AppContext type + factory
287
- ├── registry.ts # Tool registry (cold-start)
288
- └── tools/
289
- └── system/
290
- ├── health.ts # Health check
291
- └── echo.ts # Echo tool
292
- wrangler.toml # Cloudflare configuration
293
- \`\`\`
294
-
295
- ## Cloudflare Bindings
296
-
297
- Uncomment bindings in \`wrangler.toml\` and update \`Env\` in \`worker.ts\`:
298
-
299
- \`\`\`typescript
300
- // worker.ts
301
- export interface Env {
302
- DB: D1Database;
303
- KV: KVNamespace;
304
- }
305
-
306
- export default cloudflareWorkersAdapter<Env, MyContext>({
307
- registry,
308
- contextFactory: async (req, env) => ({
309
- db: env.DB,
310
- tenantId: req.headers.get('x-tenant-id') || 'public',
311
- }),
312
- });
313
- \`\`\`
314
-
315
- ## Adding New Tools
316
-
317
- 1. Create a tool in \`src/tools/\`:
318
-
319
- \`\`\`typescript
320
- import { f } from '../../vurb.js';
321
-
322
- export default f.query('my_tool')
323
- .describe('What this tool does')
324
- .withString('query', 'Search query')
325
- .handle(async (input, ctx) => {
326
- return { result: input.query };
327
- });
328
- \`\`\`
329
-
330
- 2. Register it in \`src/registry.ts\`:
331
-
332
- \`\`\`typescript
333
- import myTool from './tools/my-domain/my-tool.js';
334
- registry.register(myTool);
335
- \`\`\`
336
-
337
- ## Documentation
338
-
339
- - [Vurb Docs](https://vurb.vinkius.com/)
340
- - [Cloudflare Adapter](https://vurb.vinkius.com/cloudflare-adapter)
341
- - [Presenter — Egress Firewall](https://vurb.vinkius.com/presenter)
227
+ return `# ${config.name}
228
+
229
+ MCP Server built with [Vurb](https://vurb.vinkius.com/) — deployed to Cloudflare Workers.
230
+
231
+ ## Quick Start
232
+
233
+ \`\`\`bash
234
+ npm install
235
+ npm run dev
236
+ \`\`\`
237
+
238
+ The MCP endpoint is available at \`POST http://localhost:8787/\`.
239
+
240
+ ## Deploy to Cloudflare
241
+
242
+ \`\`\`bash
243
+ npm run deploy
244
+ \`\`\`
245
+
246
+ Or directly:
247
+
248
+ \`\`\`bash
249
+ npx wrangler deploy
250
+ \`\`\`
251
+
252
+ ## Client Configuration
253
+
254
+ ### Cursor / VS Code
255
+
256
+ \`\`\`json
257
+ {
258
+ "mcpServers": {
259
+ "${config.name}": {
260
+ "url": "https://${config.name}.your-subdomain.workers.dev/"
261
+ }
262
+ }
263
+ }
264
+ \`\`\`
265
+
266
+ ### Claude Desktop
267
+
268
+ Add to your \`claude_desktop_config.json\`:
269
+
270
+ \`\`\`json
271
+ {
272
+ "mcpServers": {
273
+ "${config.name}": {
274
+ "url": "https://${config.name}.your-subdomain.workers.dev/"
275
+ }
276
+ }
277
+ }
278
+ \`\`\`
279
+
280
+ ## Project Structure
281
+
282
+ \`\`\`
283
+ src/
284
+ ├── worker.ts # Worker entry → cloudflareWorkersAdapter()
285
+ ├── vurb.ts # initVurb<AppContext>()
286
+ ├── context.ts # AppContext type + factory
287
+ ├── registry.ts # Tool registry (cold-start)
288
+ └── tools/
289
+ └── system/
290
+ ├── health.ts # Health check
291
+ └── echo.ts # Echo tool
292
+ wrangler.toml # Cloudflare configuration
293
+ \`\`\`
294
+
295
+ ## Cloudflare Bindings
296
+
297
+ Uncomment bindings in \`wrangler.toml\` and update \`Env\` in \`worker.ts\`:
298
+
299
+ \`\`\`typescript
300
+ // worker.ts
301
+ export interface Env {
302
+ DB: D1Database;
303
+ KV: KVNamespace;
304
+ }
305
+
306
+ export default cloudflareWorkersAdapter<Env, MyContext>({
307
+ registry,
308
+ contextFactory: async (req, env) => ({
309
+ db: env.DB,
310
+ tenantId: req.headers.get('x-tenant-id') || 'public',
311
+ }),
312
+ });
313
+ \`\`\`
314
+
315
+ ## Adding New Tools
316
+
317
+ 1. Create a tool in \`src/tools/\`:
318
+
319
+ \`\`\`typescript
320
+ import { f } from '../../vurb.js';
321
+
322
+ export default f.query('my_tool')
323
+ .describe('What this tool does')
324
+ .withString('query', 'Search query')
325
+ .handle(async (input, ctx) => {
326
+ return { result: input.query };
327
+ });
328
+ \`\`\`
329
+
330
+ 2. Register it in \`src/registry.ts\`:
331
+
332
+ \`\`\`typescript
333
+ import myTool from './tools/my-domain/my-tool.js';
334
+ registry.register(myTool);
335
+ \`\`\`
336
+
337
+ ## Documentation
338
+
339
+ - [Vurb Docs](https://vurb.vinkius.com/)
340
+ - [Cloudflare Adapter](https://vurb.vinkius.com/cloudflare-adapter)
341
+ - [Presenter — Egress Firewall](https://vurb.vinkius.com/presenter)
342
342
  `;
343
343
  }
344
344
  //# sourceMappingURL=cloudflare.js.map
@@ -85,47 +85,47 @@ export function tsconfig() {
85
85
  }
86
86
  /** Generate `.gitignore` */
87
87
  export function gitignore() {
88
- return `node_modules/
89
- dist/
90
- *.tsbuildinfo
91
- .env
92
- .env.local
93
- coverage/
88
+ return `node_modules/
89
+ dist/
90
+ *.tsbuildinfo
91
+ .env
92
+ .env.local
93
+ coverage/
94
94
  `;
95
95
  }
96
96
  /** Generate `.env.example` with vector-specific vars */
97
97
  export function envExample(config) {
98
- let env = `# ── Vurb Server Environment ─────────────────────
99
- # Copy this to .env and fill in your values.
100
-
101
- # Server
102
- NODE_ENV=development
98
+ let env = `# ── Vurb Server Environment ─────────────────────
99
+ # Copy this to .env and fill in your values.
100
+
101
+ # Server
102
+ NODE_ENV=development
103
103
  `;
104
104
  if (config.vector === 'prisma') {
105
- env += `
106
- # Database (Prisma)
107
- DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
105
+ env += `
106
+ # Database (Prisma)
107
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
108
108
  `;
109
109
  }
110
110
  if (config.vector === 'n8n') {
111
- env += `
112
- # n8n Workflow Automation
113
- N8N_BASE_URL=http://localhost:5678
114
- N8N_API_KEY=your-api-key-here
111
+ env += `
112
+ # n8n Workflow Automation
113
+ N8N_BASE_URL=http://localhost:5678
114
+ N8N_API_KEY=your-api-key-here
115
115
  `;
116
116
  }
117
117
  if (config.vector === 'oauth') {
118
- env += `
119
- # OAuth Device Flow (RFC 8628)
120
- OAUTH_CLIENT_ID=your-client-id
121
- OAUTH_AUTH_ENDPOINT=https://api.example.com/oauth/device/code
122
- OAUTH_TOKEN_ENDPOINT=https://api.example.com/oauth/device/token
118
+ env += `
119
+ # OAuth Device Flow (RFC 8628)
120
+ OAUTH_CLIENT_ID=your-client-id
121
+ OAUTH_AUTH_ENDPOINT=https://api.example.com/oauth/device/code
122
+ OAUTH_TOKEN_ENDPOINT=https://api.example.com/oauth/device/token
123
123
  `;
124
124
  }
125
125
  if (config.transport === 'sse') {
126
- env += `
127
- # Streamable HTTP Transport
128
- PORT=3001
126
+ env += `
127
+ # Streamable HTTP Transport
128
+ PORT=3001
129
129
  `;
130
130
  }
131
131
  return env;