@usefillo/mcp 0.10.0 → 0.11.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.
Files changed (3) hide show
  1. package/README.md +13 -4
  2. package/dist/index.js +266 -27
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -25,18 +25,27 @@ human CLI user.
25
25
 
26
26
  One click, if your editor supports it:
27
27
 
28
- [![Add to Cursor](https://img.shields.io/badge/Add_to_Cursor-black?style=for-the-badge&logo=cursor&logoColor=white)](cursor://anysphere.cursor-deeplink/mcp/install?name=fillo&config=eyJ0eXBlIjoic3RkaW8iLCJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkB1c2VmaWxsby9tY3AiXX0=)
29
- [![Add to VS Code](https://img.shields.io/badge/Add_to_VS_Code-007ACC?style=for-the-badge&logo=visual-studio-code&logoColor=white)](vscode:mcp/install?name=fillo&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40usefillo%2Fmcp%22%5D%7D)
28
+ [![Add to Cursor](https://img.shields.io/badge/Add_to_Cursor-black?style=for-the-badge&logo=cursor&logoColor=white)](cursor://anysphere.cursor-deeplink/mcp/install?name=fillo&config=eyJ0eXBlIjoic3RkaW8iLCJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkB1c2VmaWxsby9tY3BAbGF0ZXN0Il19)
29
+ [![Add to VS Code](https://img.shields.io/badge/Add_to_VS_Code-007ACC?style=for-the-badge&logo=visual-studio-code&logoColor=white)](vscode:mcp/install?name=fillo&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40usefillo%2Fmcp%40latest%22%5D%7D)
30
30
 
31
31
  Claude Code:
32
32
 
33
33
  ```sh
34
- claude mcp add fillo -- npx -y @usefillo/mcp
34
+ claude mcp add fillo -- npx -y @usefillo/mcp@latest
35
35
  ```
36
36
 
37
- Any other MCP client: run `npx -y @usefillo/mcp` over stdio. Set `FILLO_API` to
37
+ Any other MCP client: run `npx -y @usefillo/mcp@latest` over stdio. Set `FILLO_API` to
38
38
  point at a non-production deployment.
39
39
 
40
+ The local server checks for a newer stable release at startup, at most once an
41
+ hour, and runs it from `~/.fillo/runtime`. Reconnect to acquire updates; a running
42
+ connection keeps its version until it ends. Failed or offline downloads keep the
43
+ installed server available. Update diagnostics go to stderr, preserving the
44
+ JSON-RPC channel. Set `FILLO_AUTO_UPDATE=0` to pin your installed version; CI and
45
+ development checkouts skip updates. Existing installations acquire this behavior
46
+ by reconnecting with the `@latest` command above. The hosted MCP server uses the
47
+ deployed server version directly.
48
+
40
49
  ### Choose a focused toolset
41
50
 
42
51
  The default server loads the complete catalogue. Set `FILLO_MCP_TOOLSET` in the server's environment to choose a task area:
package/dist/index.js CHANGED
@@ -3,57 +3,262 @@
3
3
  // src/index.ts
4
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
5
 
6
+ // ../agent-runtime/index.mjs
7
+ import { spawn } from "child_process";
8
+ import {
9
+ existsSync,
10
+ mkdirSync,
11
+ mkdtempSync,
12
+ readFileSync,
13
+ realpathSync,
14
+ renameSync,
15
+ rmSync,
16
+ writeFileSync
17
+ } from "fs";
18
+ import { constants, homedir } from "os";
19
+ import { delimiter, dirname, join } from "path";
20
+ import { fileURLToPath } from "url";
21
+ var REGISTRY = "https://registry.npmjs.org";
22
+ var PACKAGES = /* @__PURE__ */ new Set(["@usefillo/cli", "@usefillo/mcp"]);
23
+ var CHECK_INTERVAL = 60 * 60 * 1e3;
24
+ var stableVersion = (value) => typeof value === "string" && /^\d+\.\d+\.\d+$/.test(value);
25
+ var readJson = (path) => {
26
+ try {
27
+ return JSON.parse(readFileSync(path, "utf8"));
28
+ } catch {
29
+ return null;
30
+ }
31
+ };
32
+ function newer(candidate, current) {
33
+ const next = candidate.split(".").map(Number);
34
+ const before = current.split(".").map(Number);
35
+ for (let i = 0; i < 3; i++) {
36
+ if (next[i] !== before[i]) return next[i] > before[i];
37
+ }
38
+ return false;
39
+ }
40
+ function npmEntry() {
41
+ const nodeDir = dirname(realpathSync(process.execPath));
42
+ const candidates = [
43
+ process.env.npm_execpath,
44
+ join(nodeDir, "node_modules/npm/bin/npm-cli.js"),
45
+ join(nodeDir, "../lib/node_modules/npm/bin/npm-cli.js"),
46
+ ...(process.env.PATH ?? "").split(delimiter).map((dir) => join(dir, "npm"))
47
+ ];
48
+ for (const candidate of candidates) {
49
+ if (!candidate) continue;
50
+ try {
51
+ const path = realpathSync(candidate);
52
+ if (path.endsWith("npm-cli.js")) return path;
53
+ } catch {
54
+ }
55
+ }
56
+ return null;
57
+ }
58
+ async function installPackage(packageName, version, prefix) {
59
+ const npm = npmEntry();
60
+ if (!npm) return false;
61
+ return new Promise((resolve) => {
62
+ const child = spawn(
63
+ process.execPath,
64
+ [
65
+ npm,
66
+ "install",
67
+ `${packageName}@${version}`,
68
+ "--prefix",
69
+ prefix,
70
+ "--ignore-scripts",
71
+ "--engine-strict",
72
+ "--no-save",
73
+ "--package-lock=false",
74
+ "--audit=false",
75
+ "--fund=false",
76
+ `--registry=${REGISTRY}`,
77
+ `--@usefillo:registry=${REGISTRY}`,
78
+ "--fetch-timeout=10000",
79
+ "--fetch-retries=0",
80
+ "--loglevel=error"
81
+ ],
82
+ {
83
+ // Optional npm diagnostics have no stable machine format and may contain
84
+ // private configuration. Keep both CLI JSON and MCP channels clean.
85
+ stdio: ["ignore", "ignore", "ignore"],
86
+ timeout: 3e4,
87
+ killSignal: "SIGKILL",
88
+ windowsHide: true
89
+ }
90
+ );
91
+ child.once("error", () => resolve(false));
92
+ child.once("exit", (code) => resolve(code === 0));
93
+ });
94
+ }
95
+ function installedEntry(prefix, packageName, version) {
96
+ const root = join(prefix, "node_modules", packageName);
97
+ const pkg = readJson(join(root, "package.json"));
98
+ const entry = join(root, "dist/index.js");
99
+ return pkg?.name === packageName && pkg.version === version && existsSync(entry) ? entry : null;
100
+ }
101
+ async function resolveLatestRuntime(packageName, packageRoot, {
102
+ cacheRoot = join(homedir(), ".fillo/runtime"),
103
+ env = process.env,
104
+ fetchVersion = async () => {
105
+ const response = await fetch(`${REGISTRY}/${encodeURIComponent(packageName)}/latest`, {
106
+ signal: AbortSignal.timeout(2e3),
107
+ redirect: "error"
108
+ });
109
+ if (!response.ok) throw new Error("Version check unavailable");
110
+ return (await response.json()).version;
111
+ },
112
+ install = installPackage,
113
+ now = Date.now()
114
+ } = {}) {
115
+ if (!PACKAGES.has(packageName)) return null;
116
+ if (env.FILLO_AUTO_UPDATE === "0" || env.FILLO_RUNTIME_UPDATED === "1" || env.CI) return null;
117
+ if (existsSync(join(packageRoot, "src/index.ts"))) return null;
118
+ const current = readJson(join(packageRoot, "package.json"))?.version;
119
+ if (!stableVersion(current)) return null;
120
+ const name = packageName.split("/")[1];
121
+ const metadataPath = join(cacheRoot, `${name}-latest.json`);
122
+ const cached = readJson(metadataPath);
123
+ let version = stableVersion(cached?.version) ? cached.version : null;
124
+ let online = false;
125
+ const age = now - cached?.checkedAt;
126
+ if (!version || !Number.isFinite(age) || age < 0 || age >= CHECK_INTERVAL) {
127
+ try {
128
+ const latest = await fetchVersion();
129
+ if (!stableVersion(latest)) return null;
130
+ version = latest;
131
+ online = true;
132
+ try {
133
+ mkdirSync(cacheRoot, { recursive: true, mode: 448 });
134
+ writeFileSync(metadataPath, JSON.stringify({ version, checkedAt: now }), { mode: 384 });
135
+ } catch {
136
+ }
137
+ } catch {
138
+ }
139
+ } else {
140
+ online = true;
141
+ }
142
+ if (!version || !newer(version, current)) return null;
143
+ const destination = join(cacheRoot, `${name}-${version}-node${process.versions.node}`);
144
+ const existing = installedEntry(destination, packageName, version);
145
+ if (existing) return existing;
146
+ if (!online) return null;
147
+ const failureAge = now - cached?.failedAt;
148
+ if (Number.isFinite(failureAge) && failureAge >= 0 && failureAge < CHECK_INTERVAL) return null;
149
+ let staging;
150
+ try {
151
+ mkdirSync(cacheRoot, { recursive: true, mode: 448 });
152
+ staging = mkdtempSync(join(cacheRoot, `${name}-${version}.install-`));
153
+ if (!await install(packageName, version, staging) || !installedEntry(staging, packageName, version)) {
154
+ writeFileSync(metadataPath, JSON.stringify({ version, checkedAt: now, failedAt: now }), {
155
+ mode: 384
156
+ });
157
+ return null;
158
+ }
159
+ try {
160
+ renameSync(staging, destination);
161
+ } catch {
162
+ if (!installedEntry(destination, packageName, version)) return null;
163
+ }
164
+ return installedEntry(destination, packageName, version);
165
+ } catch {
166
+ return null;
167
+ } finally {
168
+ if (staging) {
169
+ try {
170
+ rmSync(staging, { recursive: true, force: true });
171
+ } catch {
172
+ }
173
+ }
174
+ }
175
+ }
176
+ async function runLatest(packageName, entryUrl) {
177
+ const root = fileURLToPath(new URL("../", entryUrl));
178
+ const entry = await resolveLatestRuntime(packageName, root);
179
+ if (!entry) return false;
180
+ const message = `Fillo: using the latest downloaded ${packageName}.`;
181
+ process.stderr.write(
182
+ packageName === "@usefillo/cli" && process.argv.includes("--json") ? `${JSON.stringify({ status: "runtime_updated", package: packageName, message })}
183
+ ` : `${message}
184
+ `
185
+ );
186
+ const child = spawn(process.execPath, [entry, ...process.argv.slice(2)], {
187
+ stdio: "inherit",
188
+ env: { ...process.env, FILLO_RUNTIME_UPDATED: "1" }
189
+ });
190
+ const forwardInt = () => child.kill("SIGINT");
191
+ const forwardTerm = () => child.kill("SIGTERM");
192
+ process.on("SIGINT", forwardInt);
193
+ process.on("SIGTERM", forwardTerm);
194
+ let started = false;
195
+ child.once("spawn", () => {
196
+ started = true;
197
+ });
198
+ try {
199
+ const result = await new Promise((resolve) => {
200
+ child.once("error", () => resolve(started ? 1 : null));
201
+ child.once("exit", (code, signal) => resolve(code ?? 128 + (constants.signals[signal] ?? 1)));
202
+ });
203
+ if (result === null) return false;
204
+ process.exitCode = result;
205
+ return true;
206
+ } finally {
207
+ process.removeListener("SIGINT", forwardInt);
208
+ process.removeListener("SIGTERM", forwardTerm);
209
+ }
210
+ }
211
+
6
212
  // src/config.ts
7
- import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "fs";
8
- import { homedir } from "os";
9
- import { join } from "path";
213
+ import { chmodSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
214
+ import { homedir as homedir2 } from "os";
215
+ import { join as join2 } from "path";
10
216
  var DEFAULT_API = "https://fillo.so";
11
217
  var REQUEST_TIMEOUT_MS = 3e4;
12
218
  var CLIENT_VERSION = `@usefillo/mcp@${packageVersion()}`;
13
219
  function packageVersion() {
14
220
  try {
15
- const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
221
+ const pkg = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8"));
16
222
  return typeof pkg.version === "string" ? pkg.version : "0.0.0";
17
223
  } catch {
18
224
  return "0.0.0";
19
225
  }
20
226
  }
21
227
  function apiOrigin() {
22
- return (process.env.FILLO_API ?? DEFAULT_API).replace(/\/$/, "");
228
+ return (process.env.FILLO_API?.trim() || DEFAULT_API).replace(/\/+$/, "");
23
229
  }
24
230
  function configDir() {
25
- return process.env.FILLO_CONFIG_DIR?.trim() || join(homedir(), ".fillo");
231
+ return process.env.FILLO_CONFIG_DIR?.trim() || join2(homedir2(), ".fillo");
26
232
  }
27
233
  function configPath() {
28
- return join(configDir(), "config.json");
234
+ return join2(configDir(), "config.json");
29
235
  }
30
236
  function readConfig() {
31
237
  try {
32
- const parsed = JSON.parse(readFileSync(configPath(), "utf8"));
238
+ const parsed = JSON.parse(readFileSync2(configPath(), "utf8"));
33
239
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
34
240
  const record = parsed;
35
- const provision = record.provision && typeof record.provision === "object" && !Array.isArray(record.provision) ? record.provision : void 0;
36
- return {
37
- ...record.activeContext === "account" || record.activeContext === "provisional" ? { activeContext: record.activeContext } : {},
38
- ...typeof record.token === "string" ? { token: record.token } : {},
39
- ...typeof record.tokenApi === "string" ? { tokenApi: record.tokenApi } : {},
40
- ...typeof record.pk === "string" ? { pk: record.pk } : {},
41
- ...typeof record.apiKey === "string" ? { apiKey: record.apiKey } : {},
42
- ...typeof record.apiKeyApi === "string" ? { apiKeyApi: record.apiKeyApi } : {},
43
- ...provision ? { provision } : {}
44
- };
241
+ const result = { ...record };
242
+ for (const key of ["token", "tokenApi", "pk", "apiKey", "apiKeyApi"]) {
243
+ if (typeof record[key] !== "string") delete result[key];
244
+ }
245
+ if (record.activeContext !== "account" && record.activeContext !== "provisional")
246
+ delete result.activeContext;
247
+ if (!record.provision || typeof record.provision !== "object" || Array.isArray(record.provision))
248
+ delete result.provision;
249
+ return result;
45
250
  } catch {
46
251
  return {};
47
252
  }
48
253
  }
49
254
  function writeConfig(next) {
50
255
  const dir = configDir();
51
- mkdirSync(dir, { recursive: true, mode: 448 });
256
+ mkdirSync2(dir, { recursive: true, mode: 448 });
52
257
  try {
53
258
  chmodSync(dir, 448);
54
259
  } catch {
55
260
  }
56
- writeFileSync(configPath(), JSON.stringify(next, null, 2), { mode: 384 });
261
+ writeFileSync2(configPath(), JSON.stringify(next, null, 2), { mode: 384 });
57
262
  try {
58
263
  chmodSync(configPath(), 384);
59
264
  } catch {
@@ -6178,8 +6383,23 @@ function saveSelection(project) {
6178
6383
  slug: value.slug,
6179
6384
  publishableKey: value.publishableKey
6180
6385
  };
6181
- const { apiKey: _apiKey, provision: _provision, ...current } = readConfig();
6182
- writeConfig({ ...current, activeContext: "account", pk: selected.publishableKey });
6386
+ const {
6387
+ apiKey: _apiKey,
6388
+ apiKeyApi: _apiKeyApi,
6389
+ provision: _provision,
6390
+ claimToken: _claimToken,
6391
+ claimUrl: _claimUrl,
6392
+ email: _email,
6393
+ name: _name,
6394
+ preview: _preview,
6395
+ ...current
6396
+ } = readConfig();
6397
+ writeConfig({
6398
+ ...current,
6399
+ activeContext: "account",
6400
+ pk: selected.publishableKey,
6401
+ pkApi: apiOrigin()
6402
+ });
6183
6403
  return selected;
6184
6404
  }
6185
6405
  function environmentWarning() {
@@ -6306,11 +6526,27 @@ function registerProvisionWorkspace(server) {
6306
6526
  const responseCap = typeof res.json.limits?.responses === "number" ? res.json.limits.responses : void 0;
6307
6527
  const expiresAt = typeof res.json.limits?.expiresAt === "string" ? res.json.limits.expiresAt : void 0;
6308
6528
  const emailedTo = typeof res.json.claim?.email === "string" ? res.json.claim.email : email;
6309
- const { apiKey: _apiKey, ...current } = readConfig();
6529
+ const {
6530
+ apiKey: _apiKey,
6531
+ apiKeyApi: _apiKeyApi,
6532
+ claimUrl: _claimUrl,
6533
+ claimToken: _claimToken,
6534
+ name: _name,
6535
+ preview: _preview,
6536
+ ...current
6537
+ } = readConfig();
6310
6538
  writeConfig({
6311
6539
  ...current,
6312
6540
  activeContext: "provisional",
6313
6541
  pk: key,
6542
+ pkApi: apiOrigin(),
6543
+ email: emailedTo,
6544
+ ...name ? { name } : {},
6545
+ preview: {
6546
+ workspace: typeof res.json.workspaceName === "string" ? res.json.workspaceName : `${name?.trim().split(/\s+/)[0] || emailedTo.split("@")[0]}'s workspace`,
6547
+ ...responseCap !== void 0 && expiresAt ? { limits: { responses: responseCap, expiresAt } } : {},
6548
+ ...typeof res.json.canPublishFileFields === "boolean" ? { canPublishFileFields: res.json.canPublishFileFields } : {}
6549
+ },
6314
6550
  provision: { organizationId, email: emailedTo, responseCap, expiresAt, api: apiOrigin() }
6315
6551
  });
6316
6552
  return ok(
@@ -6453,16 +6689,18 @@ function registerPushForm(server) {
6453
6689
  }
6454
6690
  const { formId, slug, url, updated, warning, warningUrl } = res.json;
6455
6691
  const status = res.json.status === "draft" ? "draft" : "published";
6456
- const live = status === "published" && url ? url : void 0;
6692
+ const staged = res.json.staged === true;
6693
+ const live = status === "published" && !staged && url ? url : void 0;
6457
6694
  const warningText = (typeof warning === "string" && warning ? ` Note: ${warning}` : "") + (typeof warningUrl === "string" && warningUrl ? ` Storage settings: ${warningUrl}.` : "");
6458
6695
  return ok(
6459
- status === "published" ? `${updated ? "Updated" : "Published"} form "${formId}"${live ? `, live at ${live}` : ""}. Embed it with <FilloForm formId="${formId}" />.` + warningText : publish === false && !warning ? `Saved form "${formId}" as a private review draft. Use fillo_publish_form when it is ready.` : `Saved form "${formId}" as a draft for storage setup and final preview. Use fillo_publish_form after review.` + warningText,
6696
+ staged ? `Staged changes to form "${formId}" for review. The published version remains unchanged. Use fillo_publish_form when ready.` + warningText : status === "published" ? `${updated ? "Updated" : "Published"} form "${formId}"${live ? `, live at ${live}` : ""}. Embed it with <FilloForm formId="${formId}" />.` + warningText : publish === false && !warning ? `Saved form "${formId}" as a private review draft. Use fillo_publish_form when it is ready.` : `Saved form "${formId}" as a draft for storage setup and final preview. Use fillo_publish_form after review.` + warningText,
6460
6697
  {
6461
6698
  mode: "token",
6462
6699
  formId,
6463
6700
  slug,
6464
6701
  url: live,
6465
6702
  status,
6703
+ staged,
6466
6704
  updated: !!updated,
6467
6705
  ...typeof warning === "string" ? { warning } : {},
6468
6706
  ...typeof warningUrl === "string" ? { warningUrl } : {}
@@ -6493,8 +6731,8 @@ function registerPushForm(server) {
6493
6731
  return fail(message, syncError?.code ? { code: syncError.code } : void 0);
6494
6732
  }
6495
6733
  const { formId, slug, status, staged, warning, warningUrl } = res.json;
6496
- const live = status === "published" && slug ? `${apiOrigin()}/f/${slug}` : void 0;
6497
- const label = status === "published" ? `Live at ${live}` : staged ? "Staged as a draft for dashboard review" : "Saved as a draft";
6734
+ const live = status === "published" && !staged && slug ? `${apiOrigin()}/f/${slug}` : void 0;
6735
+ const label = staged ? "Staged changes for review; use fillo_publish_form when ready" : status === "published" ? `Live at ${live}` : staged ? "Staged as a draft for dashboard review" : "Saved as a draft";
6498
6736
  return ok(
6499
6737
  `Synced form "${formId}" (${status ?? "draft"}). ${label}. Embed it with <FilloForm formId="${formId}" />.` + (warning ? ` Note: ${warning}` : "") + (warningUrl ? ` Storage settings: ${warningUrl}.` : ""),
6500
6738
  {
@@ -8216,6 +8454,7 @@ function registerDiscovery(server) {
8216
8454
 
8217
8455
  // src/index.ts
8218
8456
  async function main() {
8457
+ if (await runLatest("@usefillo/mcp", import.meta.url)) return;
8219
8458
  const version = CLIENT_VERSION.split("@").pop() ?? "0.0.0";
8220
8459
  const server = new ObservedMcpServer({ name: "fillo", version });
8221
8460
  const toolset = parseToolset(process.env.FILLO_MCP_TOOLSET);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usefillo/mcp",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "mcpName": "io.github.jacobfunch/usefillo",
5
5
  "description": "Fillo MCP server — provision, scaffold, publish, and query forms from your coding agent.",
6
6
  "license": "MIT",
@@ -41,7 +41,8 @@
41
41
  "devDependencies": {
42
42
  "@types/node": "^22.10.0",
43
43
  "tsup": "^8.4.0",
44
- "typescript": "^5.8.3"
44
+ "typescript": "^5.8.3",
45
+ "@usefillo/agent-runtime": "0.0.0"
45
46
  },
46
47
  "scripts": {
47
48
  "build": "tsup",