@sota-io/mcp 1.5.0 → 1.7.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.
Files changed (81) hide show
  1. package/CLAUDE.md +19 -4
  2. package/README.md +11 -4
  3. package/dist/auth/token-bridge.d.ts +16 -0
  4. package/dist/auth/token-bridge.d.ts.map +1 -1
  5. package/dist/auth/token-bridge.js +49 -9
  6. package/dist/auth/token-bridge.js.map +1 -1
  7. package/dist/auth/verify-jwt.js +6 -6
  8. package/dist/auth/verify-jwt.js.map +1 -1
  9. package/dist/http-app.d.ts +27 -0
  10. package/dist/http-app.d.ts.map +1 -0
  11. package/dist/http-app.js +324 -0
  12. package/dist/http-app.js.map +1 -0
  13. package/dist/http.d.ts +3 -15
  14. package/dist/http.d.ts.map +1 -1
  15. package/dist/http.js +13 -251
  16. package/dist/http.js.map +1 -1
  17. package/dist/index.js +11 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/lib/account.d.ts +63 -0
  20. package/dist/lib/account.d.ts.map +1 -0
  21. package/dist/lib/account.js +64 -0
  22. package/dist/lib/account.js.map +1 -0
  23. package/dist/lib/archive-builder.d.ts +39 -5
  24. package/dist/lib/archive-builder.d.ts.map +1 -1
  25. package/dist/lib/archive-builder.js +131 -37
  26. package/dist/lib/archive-builder.js.map +1 -1
  27. package/dist/lib/auth-config.d.ts +37 -0
  28. package/dist/lib/auth-config.d.ts.map +1 -0
  29. package/dist/lib/auth-config.js +95 -0
  30. package/dist/lib/auth-config.js.map +1 -0
  31. package/dist/lib/guide.d.ts +33 -0
  32. package/dist/lib/guide.d.ts.map +1 -0
  33. package/dist/lib/guide.js +82 -0
  34. package/dist/lib/guide.js.map +1 -0
  35. package/dist/lib/hosted-guard.d.ts +26 -0
  36. package/dist/lib/hosted-guard.d.ts.map +1 -0
  37. package/dist/lib/hosted-guard.js +48 -0
  38. package/dist/lib/hosted-guard.js.map +1 -0
  39. package/dist/lib/ignore.d.ts +16 -0
  40. package/dist/lib/ignore.d.ts.map +1 -0
  41. package/dist/lib/ignore.js +131 -0
  42. package/dist/lib/ignore.js.map +1 -0
  43. package/dist/lib/log.d.ts +17 -0
  44. package/dist/lib/log.d.ts.map +1 -0
  45. package/dist/lib/log.js +41 -0
  46. package/dist/lib/log.js.map +1 -0
  47. package/dist/lib/project-url.d.ts +14 -0
  48. package/dist/lib/project-url.d.ts.map +1 -0
  49. package/dist/lib/project-url.js +16 -0
  50. package/dist/lib/project-url.js.map +1 -0
  51. package/dist/lib/version.d.ts +22 -0
  52. package/dist/lib/version.d.ts.map +1 -0
  53. package/dist/lib/version.js +36 -0
  54. package/dist/lib/version.js.map +1 -0
  55. package/dist/oauth-proxy.d.ts +31 -0
  56. package/dist/oauth-proxy.d.ts.map +1 -0
  57. package/dist/oauth-proxy.js +212 -0
  58. package/dist/oauth-proxy.js.map +1 -0
  59. package/dist/tools/account.d.ts +10 -0
  60. package/dist/tools/account.d.ts.map +1 -0
  61. package/dist/tools/account.js +104 -0
  62. package/dist/tools/account.js.map +1 -0
  63. package/dist/tools/create-account.d.ts.map +1 -1
  64. package/dist/tools/create-account.js +23 -1
  65. package/dist/tools/create-account.js.map +1 -1
  66. package/dist/tools/deploy.d.ts +19 -1
  67. package/dist/tools/deploy.d.ts.map +1 -1
  68. package/dist/tools/deploy.js +129 -77
  69. package/dist/tools/deploy.js.map +1 -1
  70. package/dist/tools/env.js +2 -2
  71. package/dist/tools/env.js.map +1 -1
  72. package/dist/tools/logs.js +1 -1
  73. package/dist/tools/logs.js.map +1 -1
  74. package/dist/tools/projects.d.ts +8 -1
  75. package/dist/tools/projects.d.ts.map +1 -1
  76. package/dist/tools/projects.js +13 -5
  77. package/dist/tools/projects.js.map +1 -1
  78. package/dist/tools/status.d.ts.map +1 -1
  79. package/dist/tools/status.js +8 -3
  80. package/dist/tools/status.js.map +1 -1
  81. package/package.json +1 -1
@@ -12,24 +12,56 @@
12
12
  *
13
13
  * Limits (deliberately generous — we want to lean permissive at launch):
14
14
  * files: MAX_INLINE_FILES entries, MAX_INLINE_TOTAL_BYTES total
15
- * git_url: MAX_CLONE_BYTES on disk after `git clone --depth=1`
15
+ * git_url: MAX_CLONE_BYTES of archived files after `git clone --depth=1`
16
+ *
17
+ * The hosted server (mcp.sota.io) only uses `files`; directory and git_url
18
+ * are local (stdio) modes, see tools/deploy.ts and lib/hosted-guard.ts.
16
19
  *
17
20
  * Security:
21
+ * - .git, node_modules, .DS_Store and the local/secret env files (.env,
22
+ * .env.local, .env.*.local, .envrc; any depth, any case) are left out
23
+ * of every archive, whatever the mode.
24
+ * - directory deploys honour the root .sotaignore (or, without one, the
25
+ * .gitignore, keeping .env.production and .env.example); git_url
26
+ * deploys honour only a .sotaignore (lib/ignore.ts, 261125-mcg).
27
+ * - git and tar run via execFile (no shell).
18
28
  * - Inline file paths are normalised + rejected if they contain ".." or
19
29
  * start with "/" or contain NUL.
20
30
  * - Symlinks are not honoured for inline files (we only write regular files).
21
31
  * - Git clone uses `--depth=1` and `--single-branch` to bound bandwidth.
22
32
  * - Both modes write to a fresh /tmp dir which is removed after tar.gz is read.
23
33
  */
24
- import { execSync } from 'child_process';
25
- import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, statSync, } from 'fs';
34
+ import { execFileSync } from 'child_process';
35
+ import { lstatSync, mkdtempSync, mkdirSync, readdirSync, writeFileSync, readFileSync, rmSync, statSync, } from 'fs';
26
36
  import { tmpdir } from 'os';
37
+ import { NO_RULES, ignoredBy, loadIgnoreRules } from './ignore.js';
27
38
  import { dirname, join, resolve, sep } from 'path';
39
+ /**
40
+ * Names excluded from every archive, at any directory depth, in any case:
41
+ * the local/secret env files `.env`, `.env.local`, `.env.<anything>.local`
42
+ * and direnv's `.envrc`. Committed variants such as `.env.production`,
43
+ * `.env.development`, `.env.test` and `.env.example` are KEPT: sota builds
44
+ * (railpack, docker build) never see set-env values, so apps rely on them
45
+ * for build-time values like NEXT_PUBLIC_*.
46
+ */
47
+ const LOCAL_ENV_FILE = /^\.env(?:(?:\.[^/]+)?\.local|rc)?$/i;
48
+ const ALWAYS_EXCLUDED = new Set(['.git', 'node_modules', '.DS_Store', '.sota.json', '__pycache__', '.venv']);
49
+ export function isExcludedName(name) {
50
+ // Same always-excluded names as the CLI (cli/internal/archive defaultIgnores)
51
+ // where that is safe; the CLI's vendor/ and .env.* are deliberately not
52
+ // copied: vendored dependencies are needed for the build, and committed
53
+ // .env.production / .env.example carry public build-time values.
54
+ if (ALWAYS_EXCLUDED.has(name))
55
+ return true;
56
+ if (name.toLowerCase().endsWith('.log'))
57
+ return true;
58
+ return LOCAL_ENV_FILE.test(name);
59
+ }
28
60
  /** Upper bound on inline file count (per single `deploy` call). */
29
61
  export const MAX_INLINE_FILES = 200;
30
62
  /** Upper bound on combined inline content length, in bytes. */
31
63
  export const MAX_INLINE_TOTAL_BYTES = 10 * 1024 * 1024; // 10 MB
32
- /** Upper bound on a cloned git repo size (du -sb on the workdir), in bytes. */
64
+ /** Upper bound on a cloned git repo, in bytes: the summed size of the files the tree walk would archive (collectEntries), so excluded paths such as .git do not count. */
33
65
  export const MAX_CLONE_BYTES = 200 * 1024 * 1024; // 200 MB
34
66
  /** Upper bound on path component count, to defeat absurd nesting attacks. */
35
67
  const MAX_PATH_DEPTH = 32;
@@ -111,7 +143,7 @@ export function archiveFromGitUrl(gitUrl, gitBranch) {
111
143
  }
112
144
  args.push('--', url, workdir);
113
145
  try {
114
- execSync(`git ${args.map(shellQuote).join(' ')}`, {
146
+ execFileSync('git', args, {
115
147
  stdio: 'pipe',
116
148
  timeout: 120_000,
117
149
  });
@@ -121,11 +153,14 @@ export function archiveFromGitUrl(gitUrl, gitBranch) {
121
153
  throw new ArchiveBuilderError('git_clone_failed', `git clone failed (URL=${url.slice(0, 120)}${branch ? `, branch=${branch}` : ''}): ${detail.slice(0, 300)}`);
122
154
  }
123
155
  // Hard size cap: refuse repos that ballooned past MAX_CLONE_BYTES.
124
- const sizeBytes = duBytes(workdir);
156
+ // A clone holds only tracked files: .gitignore must not drop tracked
157
+ // ones (e.g. committed build output), so only a .sotaignore applies.
158
+ const rules = loadIgnoreRules(workdir, { gitignoreFallback: false });
159
+ const sizeBytes = collectEntries(workdir, rules).totalBytes;
125
160
  if (sizeBytes > MAX_CLONE_BYTES) {
126
161
  throw new ArchiveBuilderError('clone_too_large', `cloned repo is ${(sizeBytes / 1024 / 1024).toFixed(1)} MB (max ${(MAX_CLONE_BYTES / 1024 / 1024).toFixed(0)} MB)`);
127
162
  }
128
- return tarGzWorkdir(workdir);
163
+ return tarGzWorkdir(workdir, rules);
129
164
  }
130
165
  finally {
131
166
  rmSync(workdir, { recursive: true, force: true });
@@ -133,35 +168,110 @@ export function archiveFromGitUrl(gitUrl, gitBranch) {
133
168
  }
134
169
  /**
135
170
  * Pack an existing local directory into a tar.gz Buffer using the same
136
- * ignore rules as the directory-mode `deploy` (excludes .git, node_modules,
137
- * .env, .DS_Store). Exported so the deploy tool can re-use a single
138
- * code path for archive construction.
171
+ * ignore rules as every other mode (see isExcludedName: .git, node_modules,
172
+ * .DS_Store and the local/secret .env files). Exported so the deploy tool can re-use a
173
+ * single code path for archive construction.
139
174
  */
140
175
  export function archiveFromDirectory(dir) {
176
+ return archiveDirectoryWithReport(dir).archive;
177
+ }
178
+ export function archiveDirectoryWithReport(dir) {
141
179
  const abs = resolve(dir);
180
+ let isDir = false;
142
181
  try {
143
- statSync(abs);
182
+ isDir = statSync(abs).isDirectory();
144
183
  }
145
184
  catch {
146
185
  throw new ArchiveBuilderError('not_found', `Directory not found: ${abs}`);
147
186
  }
148
- return tarGzWorkdir(abs);
187
+ if (!isDir) {
188
+ throw new ArchiveBuilderError('not_a_directory', `Not a directory: ${abs}`);
189
+ }
190
+ const rules = loadIgnoreRules(abs, { gitignoreFallback: true });
191
+ const { files } = collectEntries(abs, rules);
192
+ return { archive: tarGzWorkdir(abs, rules), files, ignoreFile: rules.source };
193
+ }
194
+ /**
195
+ * Walk `root` and return the archive entries ("./rel/path", parents before
196
+ * children) plus the byte size of the regular files. Excluded names are
197
+ * skipped at every depth, and excluded directories are not descended into.
198
+ * Symlinks are archived as links and never followed.
199
+ */
200
+ export function collectEntries(root, rules = NO_RULES) {
201
+ const entries = [];
202
+ let totalBytes = 0;
203
+ let files = 0;
204
+ const walk = (absDir, relDir) => {
205
+ const dirents = readdirSync(absDir, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
206
+ for (const d of dirents) {
207
+ if (isExcludedName(d.name))
208
+ continue;
209
+ const abs = join(absDir, d.name);
210
+ const rel = `${relDir}/${d.name}`;
211
+ if (ignoredBy(rules, rel.slice(2), d.isDirectory()))
212
+ continue;
213
+ entries.push(rel);
214
+ if (d.isDirectory()) {
215
+ walk(abs, rel);
216
+ }
217
+ else if (d.isFile()) {
218
+ totalBytes += lstatSync(abs).size;
219
+ files++;
220
+ }
221
+ }
222
+ };
223
+ walk(root, '.');
224
+ return { entries, totalBytes, files };
149
225
  }
150
- function tarGzWorkdir(workdir) {
151
- const archivePath = join(tmpdir(), `sota-deploy-${Date.now()}-${process.pid}.tar.gz`);
226
+ function tarGzWorkdir(workdir, rules = NO_RULES) {
227
+ const { entries } = collectEntries(workdir, rules);
228
+ // The explicit NUL-separated file list (instead of tar --exclude patterns)
229
+ // makes the exclusions identical on GNU tar and bsdtar (macOS, Windows)
230
+ // and case-insensitive for the .env names.
231
+ const scratch = mkdtempSync(join(tmpdir(), 'sota-deploy-'));
232
+ const archivePath = join(scratch, 'source.tar.gz');
233
+ const listPath = join(scratch, 'files.list');
152
234
  try {
153
- execSync(`tar -czf ${shellQuote(archivePath)} --exclude='.git' --exclude='node_modules' --exclude='.env' --exclude='.DS_Store' -C ${shellQuote(workdir)} .`, { stdio: 'pipe' });
154
- return readFileSync(archivePath);
155
- }
156
- finally {
235
+ writeFileSync(listPath, entries.map((e) => `${e}\0`).join(''));
157
236
  try {
158
- rmSync(archivePath, { force: true });
237
+ execFileSync('tar', ['-czf', archivePath, '-C', workdir, '--no-recursion', '--null', '-T', listPath], { stdio: 'pipe' });
159
238
  }
160
- catch {
161
- // best-effort cleanup
239
+ catch (err) {
240
+ if (!isUnknownNullOption(err))
241
+ throw tarFailed(err);
242
+ // BusyBox tar (Alpine) has no --null. It reads the list line by line
243
+ // and takes every line literally, so a newline-separated list is the
244
+ // same thing as long as no name contains a newline.
245
+ if (entries.some((e) => e.includes('\n'))) {
246
+ throw new ArchiveBuilderError('tar_failed', 'a file name contains a line break, and the tar on this system (BusyBox) cannot pack such names; rename the file or install GNU tar');
247
+ }
248
+ rmSync(archivePath, { force: true });
249
+ writeFileSync(listPath, entries.map((e) => `${e}\n`).join(''));
250
+ try {
251
+ execFileSync('tar', ['-czf', archivePath, '-C', workdir, '--no-recursion', '-T', listPath], { stdio: 'pipe' });
252
+ }
253
+ catch (err2) {
254
+ throw tarFailed(err2);
255
+ }
162
256
  }
257
+ return readFileSync(archivePath);
258
+ }
259
+ finally {
260
+ rmSync(scratch, { recursive: true, force: true });
163
261
  }
164
262
  }
263
+ function tarStderr(err) {
264
+ const raw = err?.stderr;
265
+ return raw ? raw.toString() : err instanceof Error ? err.message : String(err);
266
+ }
267
+ /** True when tar refused to start because it does not know `--null`. */
268
+ export function isUnknownNullOption(err) {
269
+ const text = tarStderr(err);
270
+ return /(unrecognized|unknown|invalid|illegal) option/i.test(text) && /null/i.test(text);
271
+ }
272
+ function tarFailed(err) {
273
+ return new ArchiveBuilderError('tar_failed', `could not pack the source archive: ${tarStderr(err).trim().slice(0, 300)}`);
274
+ }
165
275
  function sanitiseInlinePath(raw) {
166
276
  if (!raw || typeof raw !== 'string') {
167
277
  throw new ArchiveBuilderError('bad_path', 'file path must be a non-empty string');
@@ -202,20 +312,4 @@ function isPlausibleGitURL(s) {
202
312
  return true;
203
313
  return false;
204
314
  }
205
- function shellQuote(arg) {
206
- // Single-quote and escape any embedded single quotes for safe shell pasting.
207
- return `'${arg.replace(/'/g, `'\\''`)}'`;
208
- }
209
- function duBytes(dir) {
210
- try {
211
- const out = execSync(`du -sb ${shellQuote(dir)}`, { stdio: ['ignore', 'pipe', 'pipe'] })
212
- .toString()
213
- .trim();
214
- const n = parseInt(out.split(/\s+/)[0] ?? '0', 10);
215
- return Number.isFinite(n) ? n : 0;
216
- }
217
- catch {
218
- return 0;
219
- }
220
- }
221
315
  //# sourceMappingURL=archive-builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"archive-builder.js","sourceRoot":"","sources":["../../src/lib/archive-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,WAAW,EACX,SAAS,EACT,aAAa,EACb,YAAY,EACZ,MAAM,EACN,QAAQ,GACT,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEnD,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AAChE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,SAAS;AAC3D,6EAA6E;AAC7E,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,CAAS;IACtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAA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,UAAU,EAAE,sBAAsB,GAAG,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,QAAQ,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;QACrC,MAAM,IAAI,mBAAmB,CAC3B,UAAU,EACV,kBAAkB,QAAQ,CAAC,MAAM,kBAAkB,cAAc,MAAM,GAAG,EAAE,CAC7E,CAAC;IACJ,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC9C,MAAM,IAAI,mBAAmB,CAAC,UAAU,EAAE,4BAA4B,GAAG,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAS;IAClC,IAAI,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IACrE,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * auth-config.ts — env-driven auth settings of the hosted MCP server (GDPR-3).
3
+ *
4
+ * Two values used to be hard-coded for prod (GDPR-3 ADR §11):
5
+ * - the OAuth proxy upstream (oauth-proxy.ts)
6
+ * - the accepted JWT issuers (auth/verify-jwt.ts)
7
+ *
8
+ * Env:
9
+ * AUTH_SERVER upstream GoTrue base incl. /auth/v1. Already set by
10
+ * compose (platform.yml: ${SUPABASE_URL}/auth/v1).
11
+ * Unset/blank → https://auth.sota.io/auth/v1 (prod).
12
+ * SUPABASE_JWT_ISSUERS comma-separated accepted iss values, exact match.
13
+ * Same name and rules as the Go API (config.go
14
+ * JWTIssuers). Unset/blank → today's two prod issuers.
15
+ *
16
+ * The upstream is always accepted as an issuer as well: GoTrue writes its own
17
+ * public URL into iss, so a dev or self-hosted setup only has to set
18
+ * AUTH_SERVER. Signature checking (SUPABASE_JWT_SECRET) stays the real gate.
19
+ *
20
+ * Invalid values throw, so the server fails at startup instead of answering
21
+ * 401 to every request later.
22
+ */
23
+ export declare const DEFAULT_AUTH_UPSTREAM = "https://auth.sota.io/auth/v1";
24
+ export declare const DEFAULT_ACCEPTED_ISSUERS: readonly string[];
25
+ /**
26
+ * Resolve the OAuth proxy upstream from AUTH_SERVER. Trailing slashes are
27
+ * trimmed; https is required (http only for localhost / 127.0.0.1).
28
+ */
29
+ export declare function resolveAuthUpstream(env?: NodeJS.ProcessEnv): string;
30
+ /**
31
+ * Parse SUPABASE_JWT_ISSUERS with the same rules as the Go API: absolute URL,
32
+ * no query/fragment/credentials, lower-case host, no trailing slash, https
33
+ * (http only for localhost). Blank → DEFAULT_ACCEPTED_ISSUERS. The upstream
34
+ * is appended when it is not in the list yet.
35
+ */
36
+ export declare function resolveAcceptedIssuers(env?: NodeJS.ProcessEnv, upstream?: string): string[];
37
+ //# sourceMappingURL=auth-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-config.d.ts","sourceRoot":"","sources":["../../src/lib/auth-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,eAAO,MAAM,qBAAqB,iCAAiC,CAAC;AAEpE,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAGrD,CAAC;AAMF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAsBhF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,QAAQ,GAAE,MAAiC,GAC1C,MAAM,EAAE,CA+BV"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * auth-config.ts — env-driven auth settings of the hosted MCP server (GDPR-3).
3
+ *
4
+ * Two values used to be hard-coded for prod (GDPR-3 ADR §11):
5
+ * - the OAuth proxy upstream (oauth-proxy.ts)
6
+ * - the accepted JWT issuers (auth/verify-jwt.ts)
7
+ *
8
+ * Env:
9
+ * AUTH_SERVER upstream GoTrue base incl. /auth/v1. Already set by
10
+ * compose (platform.yml: ${SUPABASE_URL}/auth/v1).
11
+ * Unset/blank → https://auth.sota.io/auth/v1 (prod).
12
+ * SUPABASE_JWT_ISSUERS comma-separated accepted iss values, exact match.
13
+ * Same name and rules as the Go API (config.go
14
+ * JWTIssuers). Unset/blank → today's two prod issuers.
15
+ *
16
+ * The upstream is always accepted as an issuer as well: GoTrue writes its own
17
+ * public URL into iss, so a dev or self-hosted setup only has to set
18
+ * AUTH_SERVER. Signature checking (SUPABASE_JWT_SECRET) stays the real gate.
19
+ *
20
+ * Invalid values throw, so the server fails at startup instead of answering
21
+ * 401 to every request later.
22
+ */
23
+ export const DEFAULT_AUTH_UPSTREAM = 'https://auth.sota.io/auth/v1';
24
+ export const DEFAULT_ACCEPTED_ISSUERS = [
25
+ 'https://wnwsdtqhywfxxlnyqafk.supabase.co/auth/v1',
26
+ 'https://auth.sota.io/auth/v1',
27
+ ];
28
+ function isLocalHost(hostname) {
29
+ return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '[::1]';
30
+ }
31
+ /**
32
+ * Resolve the OAuth proxy upstream from AUTH_SERVER. Trailing slashes are
33
+ * trimmed; https is required (http only for localhost / 127.0.0.1).
34
+ */
35
+ export function resolveAuthUpstream(env = process.env) {
36
+ const raw = (env.AUTH_SERVER ?? '').trim();
37
+ if (raw === '')
38
+ return DEFAULT_AUTH_UPSTREAM;
39
+ let u;
40
+ try {
41
+ u = new URL(raw);
42
+ }
43
+ catch {
44
+ throw new Error(`AUTH_SERVER: ${JSON.stringify(raw)} is not an absolute URL`);
45
+ }
46
+ if (u.username || u.password || u.search || u.hash) {
47
+ throw new Error(`AUTH_SERVER: ${JSON.stringify(raw)} must not carry credentials, a query or a fragment`);
48
+ }
49
+ if (u.protocol !== 'https:' && !(u.protocol === 'http:' && isLocalHost(u.hostname))) {
50
+ throw new Error(`AUTH_SERVER: ${JSON.stringify(raw)} must use https (http only for localhost/127.0.0.1)`);
51
+ }
52
+ // origin lower-cases the host; pathname keeps /auth/v1.
53
+ return `${u.origin}${u.pathname}`.replace(/\/+$/, '');
54
+ }
55
+ /**
56
+ * Parse SUPABASE_JWT_ISSUERS with the same rules as the Go API: absolute URL,
57
+ * no query/fragment/credentials, lower-case host, no trailing slash, https
58
+ * (http only for localhost). Blank → DEFAULT_ACCEPTED_ISSUERS. The upstream
59
+ * is appended when it is not in the list yet.
60
+ */
61
+ export function resolveAcceptedIssuers(env = process.env, upstream = resolveAuthUpstream(env)) {
62
+ const parsed = [];
63
+ for (const part of (env.SUPABASE_JWT_ISSUERS ?? '').split(',')) {
64
+ const iss = part.trim();
65
+ if (iss === '')
66
+ continue;
67
+ let u;
68
+ try {
69
+ u = new URL(iss);
70
+ }
71
+ catch {
72
+ throw new Error(`SUPABASE_JWT_ISSUERS: ${JSON.stringify(iss)} is not an absolute URL`);
73
+ }
74
+ if (u.username || u.password || u.search || u.hash || iss.includes('?') || iss.includes('#')) {
75
+ throw new Error(`SUPABASE_JWT_ISSUERS: ${JSON.stringify(iss)} is not an absolute URL`);
76
+ }
77
+ // URL lower-cases the host itself, so compare against the raw authority.
78
+ const rawAuthority = iss.slice(iss.indexOf('//') + 2).split('/')[0];
79
+ if (rawAuthority !== rawAuthority.toLowerCase()) {
80
+ throw new Error(`SUPABASE_JWT_ISSUERS: ${JSON.stringify(iss)} must have a lower-case host`);
81
+ }
82
+ if (iss.endsWith('/')) {
83
+ throw new Error(`SUPABASE_JWT_ISSUERS: ${JSON.stringify(iss)} must not end with a slash`);
84
+ }
85
+ if (u.protocol !== 'https:' && !(u.protocol === 'http:' && isLocalHost(u.hostname))) {
86
+ throw new Error(`SUPABASE_JWT_ISSUERS: ${JSON.stringify(iss)} must use https`);
87
+ }
88
+ parsed.push(iss);
89
+ }
90
+ const list = parsed.length > 0 ? parsed : [...DEFAULT_ACCEPTED_ISSUERS];
91
+ if (!list.includes(upstream))
92
+ list.push(upstream);
93
+ return list;
94
+ }
95
+ //# sourceMappingURL=auth-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-config.js","sourceRoot":"","sources":["../../src/lib/auth-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,8BAA8B,CAAC;AAEpE,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACzD,kDAAkD;IAClD,8BAA8B;CAC/B,CAAC;AAEF,SAAS,WAAW,CAAC,QAAgB;IACnC,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,OAAO,CAAC;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACtE,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,qBAAqB,CAAC;IAE7C,IAAI,CAAM,CAAC;IACX,IAAI,CAAC;QACH,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,gB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AAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC;IACxE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The build and identity contract an agent must follow on sota.io, in one
3
+ * place (quick task 261125-mcg). The server instructions, the tool
4
+ * descriptions, the get-account tool, the enterprise-app-checklist prompt and
5
+ * the docs page web/src/app/docs/enterprise/build-with-ai/page.mdx all state
6
+ * it with these exact lines; test/guide.test.mjs fails when the docs page and
7
+ * this file drift apart.
8
+ *
9
+ * Every line is Markdown and keeps anything in angle brackets inside
10
+ * backticks, so the same text renders in MDX.
11
+ */
12
+ /** Rules for every sota app (Enterprise or not). */
13
+ export declare const BUILD_CONTRACT: readonly string[];
14
+ /** Extra rules for an app on a sota Enterprise account. */
15
+ export declare const ENTERPRISE_CONTRACT: readonly string[];
16
+ /** What the owner does after a deploy, before anyone can open the app. */
17
+ export declare const ENTERPRISE_ACCESS_STEPS: readonly string[];
18
+ export declare const DOCS: {
19
+ readonly buildWithAi: "https://sota.io/docs/enterprise/build-with-ai";
20
+ readonly identity: "https://sota.io/docs/enterprise/app-identity";
21
+ readonly limits: "https://sota.io/docs/enterprise/limits";
22
+ readonly mcpTools: "https://sota.io/docs/mcp/tools";
23
+ };
24
+ /**
25
+ * Server instructions (MCP `initialize`). Short on purpose: clients put them
26
+ * into the agent's context; the details come from get-account.
27
+ */
28
+ export declare const SERVER_INSTRUCTIONS: string;
29
+ export declare function bullets(lines: readonly string[]): string;
30
+ export declare function numbered(lines: readonly string[]): string;
31
+ /** The Enterprise checklist (prompt + get-account), account-independent. */
32
+ export declare function enterpriseChecklist(): string;
33
+ //# sourceMappingURL=guide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guide.d.ts","sourceRoot":"","sources":["../../src/lib/guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oDAAoD;AACpD,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAS3C,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAUhD,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAMpD,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;CAKP,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAKlB,CAAC;AAEf,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAExD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEzD;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,IAAI,MAAM,CAe5C"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The build and identity contract an agent must follow on sota.io, in one
3
+ * place (quick task 261125-mcg). The server instructions, the tool
4
+ * descriptions, the get-account tool, the enterprise-app-checklist prompt and
5
+ * the docs page web/src/app/docs/enterprise/build-with-ai/page.mdx all state
6
+ * it with these exact lines; test/guide.test.mjs fails when the docs page and
7
+ * this file drift apart.
8
+ *
9
+ * Every line is Markdown and keeps anything in angle brackets inside
10
+ * backticks, so the same text renders in MDX.
11
+ */
12
+ /** Rules for every sota app (Enterprise or not). */
13
+ export const BUILD_CONTRACT = [
14
+ 'One project runs one container with one web process. There is no second service, no worker container and no persistent disk: files written inside the container are lost on every deploy, so keep state in the database.',
15
+ 'Build: a `Dockerfile` in the project root wins. Without one, sota accepts Node.js (a `package.json`; Next.js when there is a `next.config.*`) and Python (`requirements.txt` or `pyproject.toml`) and builds them with railpack. Any other language needs a `Dockerfile`.',
16
+ 'Listen on `0.0.0.0` and the port in the `PORT` environment variable: 8080 for detected frameworks, the `EXPOSE` port of a Dockerfile.',
17
+ 'Health gate: after the build, sota calls `GET /health` inside the container, and `GET /` when `/health` answers 404, without any identity headers. It must answer 2xx or 3xx within 60 seconds, or the deploy fails and the previous version keeps running.',
18
+ 'Database: the first deploy creates a PostgreSQL 17 database and injects `DATABASE_URL` plus `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD` and `PGDATABASE`. `DATABASE_URL` goes through PgBouncer in transaction mode: no `LISTEN`/`NOTIFY`, no session state (`SET`, session advisory locks, temporary tables) and no named prepared statements (Prisma: add `?pgbouncer=true`). Run migrations at start, make them safe to run twice and keep them backwards compatible: during a deploy the previous version keeps serving on the same database until the new one passes the health gate.',
19
+ 'Settings and secrets: `set-env`, then deploy again. They are only available at runtime, never at build time. Public build-time values such as `NEXT_PUBLIC_*` belong in `.env.production`; secrets never go into an uploaded file.',
20
+ 'Uploads from a folder (local MCP server): `.git`, `node_modules`, `.DS_Store`, `.sota.json`, `__pycache__`, `.venv`, `*.log` and the local env files `.env`, `.env.local`, `.env.*.local` and `.envrc` are always left out. A `.sotaignore` in the root is used when it exists (an empty one uploads everything else); otherwise the `.gitignore` is used, but `.env.production` and `.env.example` are uploaded even when it lists them. Add a `.sotaignore` before deploying a folder that holds notes, credentials or data that must not leave the machine. A `git_url` deploy uploads the tracked files and reads only a `.sotaignore`. The hosted connector takes inline files only: at most 200 files and 10 MB.',
21
+ 'Logs: `get-logs` shows the build and deploy log; when a deploy fails, `get-status` shows the reason. Logs of the running app are not available yet.',
22
+ ];
23
+ /** Extra rules for an app on a sota Enterprise account. */
24
+ export const ENTERPRISE_CONTRACT = [
25
+ 'Address: a project named `app` gets the slug `<label>-app` and the one URL `https://app.<label>.sota.io`. There is no `<slug>.sota.io` address.',
26
+ 'Sign-in: sota Access signs people in with the company\'s Microsoft 365 on every path before a request reaches the app. Do not build a login, sign-up, password reset or session handling.',
27
+ 'Identity: every signed-in request carries `X-Sota-Access-User-Id` (a stable UUID: use it as the user key), `X-Sota-Access-Email` (lower-case it before comparing; it can be the tenant sign-in name such as `name@company.onmicrosoft.com` instead of the mailbox) and `X-Sota-Access-Name` (display only). The headers carry no role: keep roles in the app\'s own database.',
28
+ 'Fail closed: every route that shows or changes data answers 401 when `X-Sota-Access-User-Id` is missing. Only `GET /health` and `GET /` answer without it, and they show no data.',
29
+ 'Health without identity: the health gate and the edge\'s check of `GET /` (every 30 seconds, redirects not followed) send no identity headers. `GET /health` must answer 200 and `GET /` 2xx or 3xx without them, for example a short "not signed in" page or a redirect. An app that answers 401 on `/` is marked down and nobody can open it.',
30
+ 'Sign out: link to `/.sota/access/logout`. Paths under `/.sota/` belong to sota Access.',
31
+ 'No public paths yet: webhooks, API clients and scripts without a browser cannot reach the app, and `POST`, `PUT`, `PATCH` or `DELETE` requests from other websites are refused.',
32
+ 'Apps of the same account run on the same server. A direct call from one app to another skips the sign-in, and the caller can set any identity header: never treat such a call as a signed-in user, and authenticate app-to-app calls with your own shared secret.',
33
+ 'Local development: the headers are missing on your machine. Use a fixed test user behind a development-only switch that is off in the deployed app.',
34
+ ];
35
+ /** What the owner does after a deploy, before anyone can open the app. */
36
+ export const ENTERPRISE_ACCESS_STEPS = [
37
+ 'Nobody can open a new app yet, the owner included.',
38
+ 'The person opens the app URL once and signs in with Microsoft 365. This creates an access request.',
39
+ 'The account owner signs in to the sota dashboard, opens Users & access, approves the person and ticks this app.',
40
+ 'The person reloads the app. People approved earlier also need this app ticked.',
41
+ 'API keys and MCP cannot approve people or change grants: tell the human what to do instead.',
42
+ ];
43
+ export const DOCS = {
44
+ buildWithAi: 'https://sota.io/docs/enterprise/build-with-ai',
45
+ identity: 'https://sota.io/docs/enterprise/app-identity',
46
+ limits: 'https://sota.io/docs/enterprise/limits',
47
+ mcpTools: 'https://sota.io/docs/mcp/tools',
48
+ };
49
+ /**
50
+ * Server instructions (MCP `initialize`). Short on purpose: clients put them
51
+ * into the agent's context; the details come from get-account.
52
+ */
53
+ export const SERVER_INSTRUCTIONS = [
54
+ 'sota.io deploys web apps (EU, Germany). Before you write or deploy code for the user, call get-account once: it says whether the account is a sota Enterprise account and returns the build contract the app must follow.',
55
+ 'Every app: one container, one web process, listen on the PORT env var, answer GET /health (or GET /) with 2xx/3xx within 60 s, no persistent disk, DATABASE_URL via PgBouncer in transaction mode.',
56
+ 'Enterprise accounts: the company sign-in sits in front of every path, so never build a login; read the X-Sota-Access-* headers, fail closed without them except on GET /health and GET /, which must answer without identity. After a deploy nobody can open the app until the owner approves people and ticks the app under Users & access in the dashboard; MCP cannot do that, so tell the human.',
57
+ 'deploy starts a build and returns at once: poll get-status until the deployment is running or failed.',
58
+ ].join('\n\n');
59
+ export function bullets(lines) {
60
+ return lines.map((l) => `- ${l}`).join('\n');
61
+ }
62
+ export function numbered(lines) {
63
+ return lines.map((l, i) => `${i + 1}. ${l}`).join('\n');
64
+ }
65
+ /** The Enterprise checklist (prompt + get-account), account-independent. */
66
+ export function enterpriseChecklist() {
67
+ return [
68
+ '# Enterprise app checklist (sota.io)',
69
+ '',
70
+ '## Every sota app',
71
+ bullets(BUILD_CONTRACT),
72
+ '',
73
+ '## On a sota Enterprise account',
74
+ bullets(ENTERPRISE_CONTRACT),
75
+ '',
76
+ '## After the deploy: who can open the app',
77
+ numbered(ENTERPRISE_ACCESS_STEPS),
78
+ '',
79
+ `Docs: ${DOCS.buildWithAi}`,
80
+ ].join('\n');
81
+ }
82
+ //# sourceMappingURL=guide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guide.js","sourceRoot":"","sources":["../../src/lib/guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,0NAA0N;IAC1N,2QAA2Q;IAC3Q,uIAAuI;IACvI,6PAA6P;IAC7P,2jBAA2jB;IAC3jB,oOAAoO;IACpO,wrBAAwrB;IACxrB,qJAAqJ;CACtJ,CAAC;AAEF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAs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CAAC;QACjC,EAAE;QACF,SAAS,IAAI,CAAC,WAAW,EAAE;KAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Request guard for the hosted MCP server (mcp.sota.io).
3
+ *
4
+ * The hosted `deploy` tool only accepts inline `files`. Its schema does not
5
+ * advertise `directory`, `git_url` or `git_branch`, but a client can send
6
+ * them anyway. A directory deploy would pack the sota-mcp container's own
7
+ * filesystem (process.cwd() or any absolute path) into the caller's
8
+ * project, and git_url would make the server fetch arbitrary URLs. This
9
+ * guard rejects such calls before any tool code runs, independent of how
10
+ * the MCP SDK validates or strips unknown arguments. The deploy tool itself
11
+ * refuses every non-`files` mode in hosted mode as a second layer.
12
+ */
13
+ /** deploy arguments the hosted server refuses. */
14
+ export declare const HOSTED_FORBIDDEN_DEPLOY_ARGS: readonly ["directory", "git_url", "git_branch"];
15
+ export interface HostedRejection {
16
+ /** JSON-RPC id of the offending message, if it had one. */
17
+ id: string | number | null;
18
+ message: string;
19
+ }
20
+ export declare const HOSTED_FILES_ONLY_HINT = "Pass the source inline as `files`, or deploy a directory or a git repository with the local server (npx @sota-io/mcp) or the CLI (`sota deploy`).";
21
+ /**
22
+ * Returns a rejection when any JSON-RPC message in `body` (a single message
23
+ * or a batch) is a `tools/call` of `deploy` carrying a forbidden argument.
24
+ */
25
+ export declare function hostedDeployRejection(body: unknown): HostedRejection | null;
26
+ //# sourceMappingURL=hosted-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-guard.d.ts","sourceRoot":"","sources":["../../src/lib/hosted-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,kDAAkD;AAClD,eAAO,MAAM,4BAA4B,iDAAkD,CAAC;AAE5F,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,sBAAsB,sJACkH,CAAC;AAEtJ;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAuB3E"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Request guard for the hosted MCP server (mcp.sota.io).
3
+ *
4
+ * The hosted `deploy` tool only accepts inline `files`. Its schema does not
5
+ * advertise `directory`, `git_url` or `git_branch`, but a client can send
6
+ * them anyway. A directory deploy would pack the sota-mcp container's own
7
+ * filesystem (process.cwd() or any absolute path) into the caller's
8
+ * project, and git_url would make the server fetch arbitrary URLs. This
9
+ * guard rejects such calls before any tool code runs, independent of how
10
+ * the MCP SDK validates or strips unknown arguments. The deploy tool itself
11
+ * refuses every non-`files` mode in hosted mode as a second layer.
12
+ */
13
+ /** deploy arguments the hosted server refuses. */
14
+ export const HOSTED_FORBIDDEN_DEPLOY_ARGS = ['directory', 'git_url', 'git_branch'];
15
+ export const HOSTED_FILES_ONLY_HINT = 'Pass the source inline as `files`, or deploy a directory or a git repository with the local server (npx @sota-io/mcp) or the CLI (`sota deploy`).';
16
+ /**
17
+ * Returns a rejection when any JSON-RPC message in `body` (a single message
18
+ * or a batch) is a `tools/call` of `deploy` carrying a forbidden argument.
19
+ */
20
+ export function hostedDeployRejection(body) {
21
+ const messages = Array.isArray(body) ? body : [body];
22
+ for (const msg of messages) {
23
+ if (!msg || typeof msg !== 'object')
24
+ continue;
25
+ const m = msg;
26
+ if (m.method !== 'tools/call')
27
+ continue;
28
+ const params = m.params;
29
+ if (!params || typeof params !== 'object')
30
+ continue;
31
+ const p = params;
32
+ if (p.name !== 'deploy')
33
+ continue;
34
+ const args = p.arguments;
35
+ if (!args || typeof args !== 'object')
36
+ continue;
37
+ const forbidden = HOSTED_FORBIDDEN_DEPLOY_ARGS.filter((k) => Object.prototype.hasOwnProperty.call(args, k));
38
+ if (forbidden.length === 0)
39
+ continue;
40
+ const id = typeof m.id === 'string' || typeof m.id === 'number' ? m.id : null;
41
+ return {
42
+ id,
43
+ message: `The hosted sota.io MCP server does not accept ${forbidden.map((k) => `\`${k}\``).join(', ')}. ${HOSTED_FILES_ONLY_HINT}`,
44
+ };
45
+ }
46
+ return null;
47
+ }
48
+ //# sourceMappingURL=hosted-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-guard.js","sourceRoot":"","sources":["../../src/lib/hosted-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,kDAAkD;AAClD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,YAAY,CAAU,CAAC;AAQ5F,MAAM,CAAC,MAAM,sBAAsB,GACjC,mJAAmJ,CAAC;AAEtJ;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAa;IACjD,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACrD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,SAAS;QAC9C,MAAM,CAAC,GAAG,GAA8B,CAAC;QACzC,IAAI,CAAC,CAAC,MAAM,KAAK,YAAY;YAAE,SAAS;QACxC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,SAAS;QACpD,MAAM,CAAC,GAAG,MAAiC,CAAC;QAC5C,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;YAAE,SAAS;QAClC,MAAM,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC;QACzB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,SAAS;QAChD,MAAM,SAAS,GAAG,4BAA4B,CAAC,MAAM,CA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