@vurb/core 3.8.2 → 3.8.3
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 +1118 -1118
- package/dist/cli/constants.d.ts +1 -1
- package/dist/cli/constants.d.ts.map +1 -1
- package/dist/cli/constants.js +71 -71
- package/dist/cli/constants.js.map +1 -1
- package/dist/cli/templates/cloudflare.js +225 -225
- package/dist/cli/templates/config.js +26 -26
- package/dist/cli/templates/core.js +95 -95
- package/dist/cli/templates/middleware.js +25 -25
- package/dist/cli/templates/model.js +22 -22
- package/dist/cli/templates/readme.js +144 -144
- package/dist/cli/templates/testing.js +84 -84
- package/dist/cli/templates/tools.js +46 -46
- package/dist/cli/templates/vectors/database.js +69 -69
- package/dist/cli/templates/vectors/oauth.js +63 -63
- package/dist/cli/templates/vectors/openapi.js +97 -97
- package/dist/cli/templates/vercel.js +190 -190
- package/dist/core/middleware/InputFirewall.js +28 -28
- package/dist/introspection/SemanticProbe.js +49 -49
- package/dist/presenter/PromptFirewall.js +28 -28
- package/package.json +153 -153
package/dist/cli/constants.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const ansi: {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const VURB_VERSION: string;
|
|
12
12
|
/** Default API endpoint — Vinkius Cloud production */
|
|
13
|
-
export declare const VINKIUS_CLOUD_URL = "https://
|
|
13
|
+
export declare const VINKIUS_CLOUD_URL = "https://deploy.vinkius.com";
|
|
14
14
|
export declare const VALID_TRANSPORTS: readonly ["stdio", "sse"];
|
|
15
15
|
export declare const VALID_VECTORS: readonly ["vanilla", "prisma", "n8n", "openapi", "oauth"];
|
|
16
16
|
export declare const VALID_TARGETS: readonly ["vinkius", "vercel", "cloudflare"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/cli/constants.ts"],"names":[],"mappings":"AASA,qCAAqC;AACrC,eAAO,MAAM,IAAI;uBACD,MAAM,KAAG,MAAM;wBACf,MAAM,KAAG,MAAM;yBACf,MAAM,KAAG,MAAM;sBACf,MAAM,KAAG,MAAM;uBACf,MAAM,KAAG,MAAM;sBACf,MAAM,KAAG,MAAM;;CAErB,CAAC;AAMX,eAAO,MAAM,YAAY,EAAE,MAGvB,CAAC;AAEL,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/cli/constants.ts"],"names":[],"mappings":"AASA,qCAAqC;AACrC,eAAO,MAAM,IAAI;uBACD,MAAM,KAAG,MAAM;wBACf,MAAM,KAAG,MAAM;yBACf,MAAM,KAAG,MAAM;sBACf,MAAM,KAAG,MAAM;uBACf,MAAM,KAAG,MAAM;sBACf,MAAM,KAAG,MAAM;;CAErB,CAAC;AAMX,eAAO,MAAM,YAAY,EAAE,MAGvB,CAAC;AAEL,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAI9D,eAAO,MAAM,gBAAgB,2BAA4B,CAAC;AAC1D,eAAO,MAAM,aAAa,2DAA4D,CAAC;AACvF,eAAO,MAAM,aAAa,8CAA+C,CAAC;AAI1E,qCAAqC;AACrC,eAAO,MAAM,IAAI,QAsET,CAAC"}
|
package/dist/cli/constants.js
CHANGED
|
@@ -27,82 +27,82 @@ export const VURB_VERSION = (() => {
|
|
|
27
27
|
}
|
|
28
28
|
})();
|
|
29
29
|
/** Default API endpoint — Vinkius Cloud production */
|
|
30
|
-
export const VINKIUS_CLOUD_URL = 'https://
|
|
30
|
+
export const VINKIUS_CLOUD_URL = 'https://deploy.vinkius.com';
|
|
31
31
|
// ─── Validation Constants ────────────────────────────────────────
|
|
32
32
|
export const VALID_TRANSPORTS = ['stdio', 'sse'];
|
|
33
33
|
export const VALID_VECTORS = ['vanilla', 'prisma', 'n8n', 'openapi', 'oauth'];
|
|
34
34
|
export const VALID_TARGETS = ['vinkius', 'vercel', 'cloudflare'];
|
|
35
35
|
// ─── Help Text ───────────────────────────────────────────────────
|
|
36
36
|
/** @internal exported for testing */
|
|
37
|
-
export const HELP = `
|
|
38
|
-
vurb — Vurb CLI
|
|
39
|
-
|
|
40
|
-
USAGE
|
|
41
|
-
vurb create <name> Scaffold a new Vurb server
|
|
42
|
-
vurb dev --server <entry> Start HMR dev server with auto-reload
|
|
43
|
-
vurb lock Generate or update ${LOCKFILE_NAME}
|
|
44
|
-
vurb lock --check Verify lockfile is up to date (CI gate)
|
|
45
|
-
vurb deploy Bundle, compress & deploy to Edge
|
|
46
|
-
vurb remote Show current remote configuration
|
|
47
|
-
vurb token Show current token status
|
|
48
|
-
vurb inspect Launch the real-time TUI dashboard
|
|
49
|
-
vurb insp --demo Launch TUI with built-in simulator
|
|
50
|
-
|
|
51
|
-
CREATE OPTIONS
|
|
52
|
-
--transport <stdio|sse> Transport layer (default: stdio)
|
|
53
|
-
--vector <type> Ingestion vector: vanilla, prisma, n8n, openapi, oauth
|
|
54
|
-
--target <platform> Deploy target: vinkius (default), vercel, cloudflare
|
|
55
|
-
--testing Include test suite (default: true)
|
|
56
|
-
--no-testing Skip test suite
|
|
57
|
-
--yes, -y Skip prompts, use defaults
|
|
58
|
-
|
|
59
|
-
DEV OPTIONS
|
|
60
|
-
--server, -s <path> Path to server entrypoint (default: auto-detect)
|
|
61
|
-
--dir, -d <path> Directory to watch for changes (default: auto-detect from server)
|
|
62
|
-
|
|
63
|
-
DEPLOY OPTIONS
|
|
64
|
-
--server, -s <path> Path to server entrypoint (default: auto-detect)
|
|
65
|
-
--token <token> Override VURB_DEPLOY_TOKEN (connection token)
|
|
66
|
-
--allow-insecure Suppress HTTP plaintext warning
|
|
67
|
-
|
|
68
|
-
REMOTE OPTIONS
|
|
69
|
-
vurb remote <url> Override API endpoint (default: Vinkius Cloud)
|
|
70
|
-
vurb remote --server-id <id> Set target server UUID
|
|
71
|
-
--token <token> Save deploy token to .vurbrc
|
|
72
|
-
|
|
73
|
-
TOKEN OPTIONS
|
|
74
|
-
vurb token <token> Save deploy token to .vurbrc
|
|
75
|
-
vurb token Show current token status (masked)
|
|
76
|
-
vurb token --clear Remove token from .vurbrc
|
|
77
|
-
|
|
78
|
-
INSPECTOR OPTIONS
|
|
79
|
-
--demo, -d Launch with built-in simulator (no server needed)
|
|
80
|
-
--out, -o <mode> Output: tui (default), stderr (headless ECS/K8s)
|
|
81
|
-
--pid, -p <pid> Connect to a specific server PID
|
|
82
|
-
--path <path> Custom IPC socket/pipe path
|
|
83
|
-
|
|
84
|
-
LOCK OPTIONS
|
|
85
|
-
--server, -s <path> Path to server entrypoint
|
|
86
|
-
--name, -n <name> Server name for lockfile header
|
|
87
|
-
--cwd <dir> Project root directory
|
|
88
|
-
|
|
89
|
-
GLOBAL
|
|
90
|
-
--help, -h Show this help message
|
|
91
|
-
|
|
92
|
-
EXAMPLES
|
|
93
|
-
vurb create my-server
|
|
94
|
-
vurb create my-server -y
|
|
95
|
-
vurb create my-server --vector prisma --transport sse
|
|
96
|
-
vurb dev --server ./src/server.ts
|
|
97
|
-
vurb dev --server ./src/server.ts --dir ./src/tools
|
|
98
|
-
vurb lock --server ./src/server.ts
|
|
99
|
-
vurb deploy
|
|
100
|
-
vurb remote --server-id abc-123-def
|
|
101
|
-
vurb remote --server-id abc-123-def --token vk_live_xxx
|
|
102
|
-
vurb remote http://localhost:8080 --server-id abc-123-def
|
|
103
|
-
vurb token vk_live_9hfaJlIPOv5xZh
|
|
104
|
-
vurb token --clear
|
|
105
|
-
vurb inspect --demo
|
|
106
|
-
vurb insp --pid 12345
|
|
37
|
+
export const HELP = `
|
|
38
|
+
vurb — Vurb CLI
|
|
39
|
+
|
|
40
|
+
USAGE
|
|
41
|
+
vurb create <name> Scaffold a new Vurb server
|
|
42
|
+
vurb dev --server <entry> Start HMR dev server with auto-reload
|
|
43
|
+
vurb lock Generate or update ${LOCKFILE_NAME}
|
|
44
|
+
vurb lock --check Verify lockfile is up to date (CI gate)
|
|
45
|
+
vurb deploy Bundle, compress & deploy to Edge
|
|
46
|
+
vurb remote Show current remote configuration
|
|
47
|
+
vurb token Show current token status
|
|
48
|
+
vurb inspect Launch the real-time TUI dashboard
|
|
49
|
+
vurb insp --demo Launch TUI with built-in simulator
|
|
50
|
+
|
|
51
|
+
CREATE OPTIONS
|
|
52
|
+
--transport <stdio|sse> Transport layer (default: stdio)
|
|
53
|
+
--vector <type> Ingestion vector: vanilla, prisma, n8n, openapi, oauth
|
|
54
|
+
--target <platform> Deploy target: vinkius (default), vercel, cloudflare
|
|
55
|
+
--testing Include test suite (default: true)
|
|
56
|
+
--no-testing Skip test suite
|
|
57
|
+
--yes, -y Skip prompts, use defaults
|
|
58
|
+
|
|
59
|
+
DEV OPTIONS
|
|
60
|
+
--server, -s <path> Path to server entrypoint (default: auto-detect)
|
|
61
|
+
--dir, -d <path> Directory to watch for changes (default: auto-detect from server)
|
|
62
|
+
|
|
63
|
+
DEPLOY OPTIONS
|
|
64
|
+
--server, -s <path> Path to server entrypoint (default: auto-detect)
|
|
65
|
+
--token <token> Override VURB_DEPLOY_TOKEN (connection token)
|
|
66
|
+
--allow-insecure Suppress HTTP plaintext warning
|
|
67
|
+
|
|
68
|
+
REMOTE OPTIONS
|
|
69
|
+
vurb remote <url> Override API endpoint (default: Vinkius Cloud)
|
|
70
|
+
vurb remote --server-id <id> Set target server UUID
|
|
71
|
+
--token <token> Save deploy token to .vurbrc
|
|
72
|
+
|
|
73
|
+
TOKEN OPTIONS
|
|
74
|
+
vurb token <token> Save deploy token to .vurbrc
|
|
75
|
+
vurb token Show current token status (masked)
|
|
76
|
+
vurb token --clear Remove token from .vurbrc
|
|
77
|
+
|
|
78
|
+
INSPECTOR OPTIONS
|
|
79
|
+
--demo, -d Launch with built-in simulator (no server needed)
|
|
80
|
+
--out, -o <mode> Output: tui (default), stderr (headless ECS/K8s)
|
|
81
|
+
--pid, -p <pid> Connect to a specific server PID
|
|
82
|
+
--path <path> Custom IPC socket/pipe path
|
|
83
|
+
|
|
84
|
+
LOCK OPTIONS
|
|
85
|
+
--server, -s <path> Path to server entrypoint
|
|
86
|
+
--name, -n <name> Server name for lockfile header
|
|
87
|
+
--cwd <dir> Project root directory
|
|
88
|
+
|
|
89
|
+
GLOBAL
|
|
90
|
+
--help, -h Show this help message
|
|
91
|
+
|
|
92
|
+
EXAMPLES
|
|
93
|
+
vurb create my-server
|
|
94
|
+
vurb create my-server -y
|
|
95
|
+
vurb create my-server --vector prisma --transport sse
|
|
96
|
+
vurb dev --server ./src/server.ts
|
|
97
|
+
vurb dev --server ./src/server.ts --dir ./src/tools
|
|
98
|
+
vurb lock --server ./src/server.ts
|
|
99
|
+
vurb deploy
|
|
100
|
+
vurb remote --server-id abc-123-def
|
|
101
|
+
vurb remote --server-id abc-123-def --token vk_live_xxx
|
|
102
|
+
vurb remote http://localhost:8080 --server-id abc-123-def
|
|
103
|
+
vurb token vk_live_9hfaJlIPOv5xZh
|
|
104
|
+
vurb token --clear
|
|
105
|
+
vurb inspect --demo
|
|
106
|
+
vurb insp --pid 12345
|
|
107
107
|
`.trim();
|
|
108
108
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/cli/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,oEAAoE;AAEpE,qCAAqC;AACrC,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,IAAI,EAAI,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,KAAK,EAAG,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,MAAM,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,GAAG,EAAK,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,SAAS;IACnD,IAAI,EAAI,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,SAAS;IACnD,GAAG,EAAK,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,KAAK,EAAE,SAAS;CACV,CAAC;AAEX,oEAAoE;AAEpE,qCAAqC;AACrC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAW,CAAC,GAAG,EAAE;IACtC,IAAI,CAAC;QAAC,OAAQ,QAAQ,CAAC,oBAAoB,CAAyB,CAAC,OAAO,CAAC;IAAC,CAAC;IAC/E,MAAM,CAAC;QAAC,OAAO,OAAO,CAAC;IAAC,CAAC;AAC7B,CAAC,CAAC,EAAE,CAAC;AAEL,sDAAsD;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/cli/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,oEAAoE;AAEpE,qCAAqC;AACrC,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,IAAI,EAAI,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,KAAK,EAAG,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,MAAM,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,GAAG,EAAK,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,SAAS;IACnD,IAAI,EAAI,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,SAAS;IACnD,GAAG,EAAK,CAAC,CAAS,EAAU,EAAE,CAAC,WAAW,CAAC,SAAS;IACpD,KAAK,EAAE,SAAS;CACV,CAAC;AAEX,oEAAoE;AAEpE,qCAAqC;AACrC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAW,CAAC,GAAG,EAAE;IACtC,IAAI,CAAC;QAAC,OAAQ,QAAQ,CAAC,oBAAoB,CAAyB,CAAC,OAAO,CAAC;IAAC,CAAC;IAC/E,MAAM,CAAC;QAAC,OAAO,OAAO,CAAC;IAAC,CAAC;AAC7B,CAAC,CAAC,EAAE,CAAC;AAEL,sDAAsD;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AAE9D,oEAAoE;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,KAAK,CAAU,CAAC;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAC;AAE1E,oEAAoE;AAEpE,qCAAqC;AACrC,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;yDAMqC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgErE,CAAC,IAAI,EAAE,CAAC"}
|
|
@@ -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
|