@floomhq/floom-mcp-sync 1.0.11 → 1.0.12
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 +1 -1
- package/dist/auto-sync.js +16 -2
- package/dist/server.js +2 -2
- package/package.json +8 -3
- package/dist/tools/install.js +0 -117
- package/dist/tools/libraries.js +0 -28
- package/dist/tools/publish.js +0 -24
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ Version 1 sync does not replace existing local files. Remote updates, existing u
|
|
|
59
59
|
|
|
60
60
|
The poll uses HTTP `If-None-Match` against `/api/v1/me/skills`, so unchanged responses are `304` with no body. If a Floom-tracked local file is missing after a `304`, MCP refetches once without the ETag so Version 1 can recreate missing files without overwriting existing files.
|
|
61
61
|
|
|
62
|
-
Configure the
|
|
62
|
+
Configure the poll interval with `FLOOM_SYNC_INTERVAL_MS` (default `60000`, minimum `10000`).
|
|
63
63
|
|
|
64
64
|
## Tools
|
|
65
65
|
|
package/dist/auto-sync.js
CHANGED
|
@@ -23,6 +23,17 @@ const PACKAGE_FILE_LIMIT = 100;
|
|
|
23
23
|
const PACKAGE_TOTAL_BYTES_LIMIT = 1_000_000;
|
|
24
24
|
const PACKAGE_FILE_BYTES_LIMIT = 500_000;
|
|
25
25
|
const BASE64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
26
|
+
function hasStructuredPath(skill) {
|
|
27
|
+
return Boolean(skill.library_slug || skill.folder);
|
|
28
|
+
}
|
|
29
|
+
function dedupeSyncSkills(skills) {
|
|
30
|
+
const structuredSlugs = new Set();
|
|
31
|
+
for (const skill of skills) {
|
|
32
|
+
if (hasStructuredPath(skill))
|
|
33
|
+
structuredSlugs.add(skill.slug);
|
|
34
|
+
}
|
|
35
|
+
return skills.filter((skill) => !structuredSlugs.has(skill.slug) || hasStructuredPath(skill));
|
|
36
|
+
}
|
|
26
37
|
async function localState(path) {
|
|
27
38
|
try {
|
|
28
39
|
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
@@ -280,9 +291,12 @@ export async function autoSync(log = (message) => process.stderr.write(`${messag
|
|
|
280
291
|
}
|
|
281
292
|
for (const skill of payload.skills)
|
|
282
293
|
validateSyncSkillShape(skill);
|
|
283
|
-
// Version 1
|
|
294
|
+
// Version 1 receives published, saved, and subscribed library skills through
|
|
295
|
+
// the single /me/skills response. If a slug appears both at top level and in
|
|
296
|
+
// a library/folder placement, keep only the structured placement so agents do
|
|
297
|
+
// not see duplicate native packages.
|
|
284
298
|
const buckets = [
|
|
285
|
-
{ skills: payload.skills, defaultLib: null },
|
|
299
|
+
{ skills: dedupeSyncSkills(payload.skills), defaultLib: null },
|
|
286
300
|
];
|
|
287
301
|
let unchanged = 0;
|
|
288
302
|
let updated = 0;
|
package/dist/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { autoSync } from "./auto-sync.js";
|
|
|
5
5
|
import { getSkill } from "./tools/get.js";
|
|
6
6
|
import { searchSkills } from "./tools/search.js";
|
|
7
7
|
import { syncStatus } from "./tools/status.js";
|
|
8
|
-
const SERVER_VERSION = "1.0.
|
|
8
|
+
const SERVER_VERSION = "1.0.12";
|
|
9
9
|
const DEFAULT_INTERVAL_MS = 60_000;
|
|
10
10
|
const MIN_INTERVAL_MS = 10_000;
|
|
11
11
|
const SEARCH_TYPES = new Set(["knowledge", "instruction", "workflow", "skill"]);
|
|
@@ -30,7 +30,7 @@ function abortAutoSync() {
|
|
|
30
30
|
function usage() {
|
|
31
31
|
return `
|
|
32
32
|
floom-mcp-sync v${SERVER_VERSION}
|
|
33
|
-
Floom MCP server for Version 1
|
|
33
|
+
Floom MCP server for Version 1 sync.
|
|
34
34
|
|
|
35
35
|
Usage
|
|
36
36
|
floom-mcp-sync
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floomhq/floom-mcp-sync",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Lightweight Floom MCP server for
|
|
3
|
+
"version": "1.0.12",
|
|
4
|
+
"description": "Lightweight Floom MCP server for search, on-demand skill fetch, status, and sync.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"bin",
|
|
12
|
-
"dist",
|
|
12
|
+
"dist/auto-sync.js",
|
|
13
|
+
"dist/lib",
|
|
14
|
+
"dist/server.js",
|
|
15
|
+
"dist/tools/get.js",
|
|
16
|
+
"dist/tools/search.js",
|
|
17
|
+
"dist/tools/status.js",
|
|
13
18
|
"README.md",
|
|
14
19
|
"LICENSE"
|
|
15
20
|
],
|
package/dist/tools/install.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { constants } from "node:fs";
|
|
2
|
-
import { lstat, mkdir, open } from "node:fs/promises";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
-
import { apiUrlFromConfig, readConfig, DEFAULT_API_URL } from "../lib/config.js";
|
|
6
|
-
import { getText } from "../lib/api.js";
|
|
7
|
-
import { assertValidSlug } from "../lib/slug.js";
|
|
8
|
-
import { skillPath, skillsDir } from "../lib/paths.js";
|
|
9
|
-
const FD_PATH_ROOT = "/proc/self/fd";
|
|
10
|
-
export async function installSkill(slug) {
|
|
11
|
-
assertValidSlug(slug);
|
|
12
|
-
const cfg = await readConfig();
|
|
13
|
-
const apiUrl = cfg ? apiUrlFromConfig(cfg) : (process.env.FLOOM_API_URL ?? DEFAULT_API_URL).replace(/\/$/, "");
|
|
14
|
-
const body = await getText(`${apiUrl}/s/${slug}.md`);
|
|
15
|
-
if (typeof body !== "string")
|
|
16
|
-
throw new Error("Invalid skill response");
|
|
17
|
-
const target = skillPath(slug);
|
|
18
|
-
const remoteHash = sha256(body);
|
|
19
|
-
const existing = await localHash(target);
|
|
20
|
-
if (existing !== null && existing !== remoteHash) {
|
|
21
|
-
throw new Error("Local skill already exists with different content");
|
|
22
|
-
}
|
|
23
|
-
if (existing === null)
|
|
24
|
-
await writeInstallFile(target, body);
|
|
25
|
-
return { slug, path: target, bytes: Buffer.byteLength(body) };
|
|
26
|
-
}
|
|
27
|
-
function sha256(input) {
|
|
28
|
-
return createHash("sha256").update(input).digest("hex");
|
|
29
|
-
}
|
|
30
|
-
async function localHash(path) {
|
|
31
|
-
try {
|
|
32
|
-
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
33
|
-
try {
|
|
34
|
-
const stat = await handle.stat();
|
|
35
|
-
if (!stat.isFile())
|
|
36
|
-
throw new Error("path is blocked by an existing local file or directory");
|
|
37
|
-
return sha256(await handle.readFile("utf8"));
|
|
38
|
-
}
|
|
39
|
-
finally {
|
|
40
|
-
await handle.close();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
if (err.code === "ENOENT")
|
|
45
|
-
return null;
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async function writeInstallFile(target, body) {
|
|
50
|
-
const parent = await openSafeParentDirectory(skillsDir(), target);
|
|
51
|
-
let handle = null;
|
|
52
|
-
try {
|
|
53
|
-
handle = await open(childCreatePath(parent, dirname(target), basename(target)), constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
54
|
-
await writeAll(handle, body);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
await handle?.close();
|
|
58
|
-
await parent.close();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function openSafeParentDirectory(root, target) {
|
|
62
|
-
await ensureSafeParentDirectory(root, target);
|
|
63
|
-
return open(dirname(target), constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
64
|
-
}
|
|
65
|
-
function childCreatePath(parent, fallbackParent, name) {
|
|
66
|
-
if (process.platform === "linux")
|
|
67
|
-
return `${FD_PATH_ROOT}/${parent.fd}/${name}`;
|
|
68
|
-
return join(resolve(fallbackParent), name);
|
|
69
|
-
}
|
|
70
|
-
async function writeAll(handle, body) {
|
|
71
|
-
const buffer = Buffer.from(body, "utf8");
|
|
72
|
-
let offset = 0;
|
|
73
|
-
while (offset < buffer.length) {
|
|
74
|
-
const result = await handle.write(buffer, offset, buffer.length - offset, offset);
|
|
75
|
-
if (result.bytesWritten === 0)
|
|
76
|
-
throw new Error("failed to write local skill file");
|
|
77
|
-
offset += result.bytesWritten;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async function ensureSafeParentDirectory(root, target) {
|
|
81
|
-
const resolvedRoot = resolve(root);
|
|
82
|
-
const resolvedParent = resolve(dirname(target));
|
|
83
|
-
const relativeParent = relative(resolvedRoot, resolvedParent);
|
|
84
|
-
if (relativeParent === ".." || relativeParent.startsWith(`..${sep}`) || isAbsolute(relativeParent)) {
|
|
85
|
-
throw new Error("Invalid skill target path");
|
|
86
|
-
}
|
|
87
|
-
await mkdir(resolvedRoot, { recursive: true, mode: 0o700 });
|
|
88
|
-
await assertSafeDirectory(resolvedRoot);
|
|
89
|
-
if (!relativeParent || relativeParent === ".")
|
|
90
|
-
return;
|
|
91
|
-
let current = resolvedRoot;
|
|
92
|
-
for (const segment of relativeParent.split(sep).filter(Boolean)) {
|
|
93
|
-
current = join(current, segment);
|
|
94
|
-
try {
|
|
95
|
-
await assertSafeDirectory(current);
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
if (err.code !== "ENOENT")
|
|
99
|
-
throw err;
|
|
100
|
-
await mkdir(current, { mode: 0o700 });
|
|
101
|
-
await assertSafeDirectory(current);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async function assertSafeDirectory(path) {
|
|
106
|
-
const stat = await lstat(path);
|
|
107
|
-
if (stat.isSymbolicLink()) {
|
|
108
|
-
const err = new Error("path contains a symbolic link");
|
|
109
|
-
err.code = "ELOOP";
|
|
110
|
-
throw err;
|
|
111
|
-
}
|
|
112
|
-
if (!stat.isDirectory()) {
|
|
113
|
-
const err = new Error("path is blocked by an existing local file or directory");
|
|
114
|
-
err.code = "ENOTDIR";
|
|
115
|
-
throw err;
|
|
116
|
-
}
|
|
117
|
-
}
|
package/dist/tools/libraries.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { apiUrlFromConfig, readConfig, DEFAULT_API_URL } from "../lib/config.js";
|
|
2
|
-
import { deleteRequest, getJson, postJson, putJson } from "../lib/api.js";
|
|
3
|
-
export async function listLibraries() {
|
|
4
|
-
const cfg = await readConfig();
|
|
5
|
-
const apiUrl = cfg ? apiUrlFromConfig(cfg) : (process.env.FLOOM_API_URL ?? DEFAULT_API_URL).replace(/\/$/, "");
|
|
6
|
-
return await getJson(`${apiUrl}/api/v1/libraries`, cfg?.accessToken);
|
|
7
|
-
}
|
|
8
|
-
export async function subscribeLibrary(slug) {
|
|
9
|
-
const cfg = await readConfig();
|
|
10
|
-
if (!cfg)
|
|
11
|
-
throw new Error("Not signed in. Run `npx -y @floomhq/floom login` first.");
|
|
12
|
-
const apiUrl = apiUrlFromConfig(cfg);
|
|
13
|
-
return await postJson(`${apiUrl}/api/v1/me/subscriptions`, cfg.accessToken, { library_slug: slug });
|
|
14
|
-
}
|
|
15
|
-
export async function unsubscribeLibrary(slug) {
|
|
16
|
-
const cfg = await readConfig();
|
|
17
|
-
if (!cfg)
|
|
18
|
-
throw new Error("Not signed in. Run `npx -y @floomhq/floom login` first.");
|
|
19
|
-
const apiUrl = apiUrlFromConfig(cfg);
|
|
20
|
-
return await deleteRequest(`${apiUrl}/api/v1/me/subscriptions/${encodeURIComponent(slug)}`, cfg.accessToken);
|
|
21
|
-
}
|
|
22
|
-
export async function moveSkill(slug, folder, tags) {
|
|
23
|
-
const cfg = await readConfig();
|
|
24
|
-
if (!cfg)
|
|
25
|
-
throw new Error("Not signed in. Run `npx -y @floomhq/floom login` first.");
|
|
26
|
-
const apiUrl = apiUrlFromConfig(cfg);
|
|
27
|
-
return await putJson(`${apiUrl}/api/v1/me/skills/${encodeURIComponent(slug)}/override`, cfg.accessToken, { folder, tags });
|
|
28
|
-
}
|
package/dist/tools/publish.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { apiUrlFromConfig, readConfig } from "../lib/config.js";
|
|
2
|
-
import { postJson } from "../lib/api.js";
|
|
3
|
-
export async function publishSkill(name, content, description, visibility = "unlisted", assetType = "skill", installsAs = "claude_skill", version) {
|
|
4
|
-
const cfg = await readConfig();
|
|
5
|
-
if (!cfg)
|
|
6
|
-
throw new Error("Not signed in. Run `npx -y @floomhq/floom login` first.");
|
|
7
|
-
const apiUrl = apiUrlFromConfig(cfg);
|
|
8
|
-
const data = await postJson(`${apiUrl}/api/skills`, cfg.accessToken, {
|
|
9
|
-
title: name,
|
|
10
|
-
description: description ?? null,
|
|
11
|
-
body_md: content,
|
|
12
|
-
visibility,
|
|
13
|
-
asset_type: assetType,
|
|
14
|
-
source: "markdown",
|
|
15
|
-
installs_as: installsAs,
|
|
16
|
-
version: version ?? null,
|
|
17
|
-
published_via: "mcp",
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
slug: data.slug,
|
|
21
|
-
url: data.url ?? `${apiUrl}/s/${data.slug}.md`,
|
|
22
|
-
...(data.version ? { version: data.version } : {}),
|
|
23
|
-
};
|
|
24
|
-
}
|