clipcloud-mcp 0.1.0 → 0.1.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.
package/dist/index.js CHANGED
@@ -8,7 +8,8 @@ const BASE = (process.env.CLIPCLOUD_BASE_URL ?? '').trim() || DEFAULT_BASE;
8
8
  /** Only for tests: a shorter check interval than the 30 seconds the API asks for. */
9
9
  const POLL_MS = Math.max(1, Number(process.env.CLIPCLOUD_POLL_SECONDS) || POLL_SECONDS) * 1000;
10
10
  /** Optional default folder: when set, every finished image is also saved there. */
11
- const SAVE_DIR = (process.env.CLIPCLOUD_SAVE_DIR ?? '').trim() ? absolute(process.env.CLIPCLOUD_SAVE_DIR) : undefined;
11
+ const RAW_SAVE_DIR = (process.env.CLIPCLOUD_SAVE_DIR ?? '').trim();
12
+ const SAVE_DIR = RAW_SAVE_DIR ? absolute(RAW_SAVE_DIR) : undefined;
12
13
  const NO_KEY = `CLIPCLOUD_API_KEY is not set. Tell the user to get a free ClipCloud API key (it starts with "clip-") in the web panel ${PANEL_URL} or in the Telegram bot @clipcloudbot, add it as CLIPCLOUD_API_KEY to the env of the ClipCloud MCP server in their AI app settings, and restart the app.`;
13
14
  function baseUrlProblem() {
14
15
  try {
@@ -41,3 +42,6 @@ if (!KEY)
41
42
  console.error(`clipcloud-mcp: ${NO_KEY}`);
42
43
  if (baseProblem)
43
44
  console.error(`clipcloud-mcp: ${baseProblem}`);
45
+ if (RAW_SAVE_DIR && !SAVE_DIR) {
46
+ console.error(`clipcloud-mcp: CLIPCLOUD_SAVE_DIR "${RAW_SAVE_DIR}" has a variable that could not be replaced, so images are not saved automatically. Use a full path.`);
47
+ }
package/dist/server.js CHANGED
@@ -27,11 +27,37 @@ export function memoryHistory(limit = 50) {
27
27
  find: (id) => items.find((s) => s.id === id),
28
28
  };
29
29
  }
30
- /** "~" means the home folder; a relative path is taken from base (or the home folder). */
30
+ /**
31
+ * Replaces home-folder shortcuts: "~", $HOME, %USERPROFILE% and the MCPB variables ${HOME}, ${DESKTOP}, ${DOCUMENTS},
32
+ * ${DOWNLOADS} (some apps pass a setting's default value without replacing them). Returns undefined if an unknown
33
+ * ${...} is left, so no folder with such a name is ever created.
34
+ */
35
+ export function expandHome(path) {
36
+ const home = homedir();
37
+ const folders = {
38
+ HOME: home,
39
+ USERPROFILE: home,
40
+ DESKTOP: join(home, 'Desktop'),
41
+ DOCUMENTS: join(home, 'Documents'),
42
+ DOWNLOADS: join(home, 'Downloads'),
43
+ };
44
+ let p = path.trim();
45
+ p = p.replace(/\$\{([A-Za-z_]+)\}/g, (all, name) => folders[name.toUpperCase()] ?? all);
46
+ p = p.replace(/%(USERPROFILE|HOMEPATH)%/gi, home);
47
+ p = p.replace(/^\$HOME(?=$|[\\/])/, home);
48
+ if (p === '~')
49
+ p = home;
50
+ else if (p.startsWith('~/') || p.startsWith('~\\'))
51
+ p = join(home, p.slice(2));
52
+ return p.includes('${') ? undefined : p;
53
+ }
54
+ /** A path with home shortcuts expanded; a relative path is taken from base (or the home folder). */
31
55
  export function absolute(path, base) {
32
- const p = path.trim();
33
- const expanded = p === '~' ? homedir() : p.startsWith('~/') || p.startsWith('~\\') ? join(homedir(), p.slice(2)) : p;
34
- return isAbsolute(expanded) ? expanded : resolve(base ?? homedir(), expanded);
56
+ const expanded = expandHome(path);
57
+ if (expanded === undefined)
58
+ return undefined;
59
+ // resolve() also normalizes separators (C:\Users\me/Downloads becomes C:\Users\me\Downloads on Windows)
60
+ return resolve(base ?? homedir(), expanded);
35
61
  }
36
62
  /** A safe file name without folders and extension. */
37
63
  function baseName(name) {
@@ -138,9 +164,12 @@ export function createServer(opts) {
138
164
  const raw = saveDir?.trim();
139
165
  if (!raw)
140
166
  return { dir: opts.saveDir };
141
- const expanded = raw === '~' || raw.startsWith('~/') || raw.startsWith('~\\') ? absolute(raw) : raw;
167
+ const expanded = expandHome(raw);
168
+ if (expanded === undefined) {
169
+ return { problem: `The folder "${raw}" contains a variable that could not be replaced. Use a full path, for example /Users/name/Pictures.` };
170
+ }
142
171
  if (isAbsolute(expanded))
143
- return { dir: expanded };
172
+ return { dir: resolve(expanded) };
144
173
  if (opts.saveDir)
145
174
  return { dir: resolve(opts.saveDir, expanded) };
146
175
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clipcloud-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MCP server for ClipCloud: generate AI images from text in 35 styles from Claude, Cursor and other AI assistants. 25 free images per day.",
5
5
  "mcpName": "io.github.alexmrgit/clipcloud-mcp",
6
6
  "license": "MIT",