@fluxfiles/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/README.md CHANGED
@@ -60,6 +60,7 @@ permissions, its quota. No storage credentials are involved.
60
60
  | `FLUXFILES_DISK` | Default disk (default `local`) |
61
61
  | `FLUXFILES_MCP_WRITE` | `1` to expose the write tools |
62
62
  | `FLUXFILES_MCP_DELETE` | `1` (with `WRITE`) to expose `move_to_trash` |
63
+ | `FLUXFILES_MCP_ALLOW_HTTP` | `1` to allow plain `http://` to a non-local host. Off by default — the token would travel in clear text; `localhost` is always allowed |
63
64
 
64
65
  ## Security notes
65
66
 
@@ -9,9 +9,25 @@ var FluxFilesError = class extends Error {
9
9
  status;
10
10
  code;
11
11
  };
12
+ var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
13
+ function assertSafeBaseUrl(baseUrl, allowInsecureHttp = false) {
14
+ let u;
15
+ try {
16
+ u = new URL(baseUrl);
17
+ } catch {
18
+ throw new Error(`FLUXFILES_URL is not a valid URL: ${baseUrl}`);
19
+ }
20
+ if (u.protocol === "https:") return;
21
+ if (u.protocol !== "http:") throw new Error(`FLUXFILES_URL must be http(s), got ${u.protocol}`);
22
+ if (LOCAL_HOSTS.has(u.hostname) || allowInsecureHttp) return;
23
+ throw new Error(
24
+ `Refusing to send the FluxFiles token over plain http to ${u.hostname} \u2014 use https, or set FLUXFILES_MCP_ALLOW_HTTP=1 if this network is trusted.`
25
+ );
26
+ }
12
27
  var FluxFilesClient = class {
13
28
  constructor(cfg) {
14
29
  this.cfg = cfg;
30
+ assertSafeBaseUrl(cfg.baseUrl, cfg.allowInsecureHttp);
15
31
  this.base = cfg.baseUrl.replace(/\/+$/, "");
16
32
  this.f = cfg.fetch ?? fetch;
17
33
  }
@@ -202,9 +218,9 @@ function buildTools(client, opts) {
202
218
 
203
219
  // src/server.ts
204
220
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
205
- var VERSION = "0.1.0";
221
+ var VERSION = "0.1.1";
206
222
  function createServer(cfg) {
207
- const client = new FluxFilesClient({ baseUrl: cfg.baseUrl, token: cfg.token, fetch: cfg.fetch });
223
+ const client = new FluxFilesClient({ baseUrl: cfg.baseUrl, token: cfg.token, fetch: cfg.fetch, allowInsecureHttp: cfg.allowInsecureHttp });
208
224
  const server = new McpServer({ name: "fluxfiles", version: VERSION });
209
225
  const tools = buildTools(client, {
210
226
  disk: cfg.disk ?? "local",
@@ -237,6 +253,7 @@ function createServer(cfg) {
237
253
 
238
254
  export {
239
255
  FluxFilesError,
256
+ assertSafeBaseUrl,
240
257
  FluxFilesClient,
241
258
  buildTools,
242
259
  VERSION,
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createServer
4
- } from "./chunk-KFVXLW54.js";
4
+ } from "./chunk-GKUDKSIV.js";
5
5
 
6
6
  // src/cli.ts
7
7
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -17,6 +17,7 @@ var server = createServer({
17
17
  token,
18
18
  disk: process.env.FLUXFILES_DISK || "local",
19
19
  allowWrite: on(process.env.FLUXFILES_MCP_WRITE),
20
- allowDelete: on(process.env.FLUXFILES_MCP_DELETE)
20
+ allowDelete: on(process.env.FLUXFILES_MCP_DELETE),
21
+ allowInsecureHttp: on(process.env.FLUXFILES_MCP_ALLOW_HTTP)
21
22
  });
22
23
  await server.connect(new StdioServerTransport());
package/dist/index.d.ts CHANGED
@@ -17,7 +17,11 @@ interface ClientConfig {
17
17
  baseUrl: string;
18
18
  token: string;
19
19
  fetch?: typeof fetch;
20
+ /** Allow plain `http://` to a non-local host. Off: the token would cross the network in clear text. */
21
+ allowInsecureHttp?: boolean;
20
22
  }
23
+ /** Refuse to send the bearer token in clear text, except to this machine. */
24
+ declare function assertSafeBaseUrl(baseUrl: string, allowInsecureHttp?: boolean): void;
21
25
  declare class FluxFilesClient {
22
26
  private readonly cfg;
23
27
  private readonly base;
@@ -55,8 +59,9 @@ interface ServerConfig extends Partial<ToolOptions> {
55
59
  baseUrl: string;
56
60
  token: string;
57
61
  fetch?: typeof fetch;
62
+ allowInsecureHttp?: boolean;
58
63
  }
59
- declare const VERSION = "0.1.0";
64
+ declare const VERSION = "0.1.1";
60
65
  declare function createServer(cfg: ServerConfig): McpServer;
61
66
 
62
- export { type ClientConfig, FluxFilesClient, FluxFilesError, type ServerConfig, type ToolDef, type ToolOptions, VERSION, buildTools, createServer };
67
+ export { type ClientConfig, FluxFilesClient, FluxFilesError, type ServerConfig, type ToolDef, type ToolOptions, VERSION, assertSafeBaseUrl, buildTools, createServer };
package/dist/index.js CHANGED
@@ -2,13 +2,15 @@ import {
2
2
  FluxFilesClient,
3
3
  FluxFilesError,
4
4
  VERSION,
5
+ assertSafeBaseUrl,
5
6
  buildTools,
6
7
  createServer
7
- } from "./chunk-KFVXLW54.js";
8
+ } from "./chunk-GKUDKSIV.js";
8
9
  export {
9
10
  FluxFilesClient,
10
11
  FluxFilesError,
11
12
  VERSION,
13
+ assertSafeBaseUrl,
12
14
  buildTools,
13
15
  createServer
14
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxfiles/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Model Context Protocol server for FluxFiles — let AI agents browse, search and read (and optionally write) files through a scoped FluxFiles JWT",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/cli.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * FLUXFILES_DISK default disk (default: local)
8
8
  * FLUXFILES_MCP_WRITE "1" → also expose write_text_file / create_folder
9
9
  * FLUXFILES_MCP_DELETE "1" (with WRITE) → also expose move_to_trash
10
+ * FLUXFILES_MCP_ALLOW_HTTP "1" → allow plain http to a non-local host (token in clear text)
10
11
  */
11
12
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
12
13
  import { createServer } from './server.js';
@@ -25,5 +26,6 @@ const server = createServer({
25
26
  disk: process.env.FLUXFILES_DISK || 'local',
26
27
  allowWrite: on(process.env.FLUXFILES_MCP_WRITE),
27
28
  allowDelete: on(process.env.FLUXFILES_MCP_DELETE),
29
+ allowInsecureHttp: on(process.env.FLUXFILES_MCP_ALLOW_HTTP),
28
30
  });
29
31
  await server.connect(new StdioServerTransport());
package/src/client.ts CHANGED
@@ -16,6 +16,27 @@ export interface ClientConfig {
16
16
  baseUrl: string;
17
17
  token: string;
18
18
  fetch?: typeof fetch;
19
+ /** Allow plain `http://` to a non-local host. Off: the token would cross the network in clear text. */
20
+ allowInsecureHttp?: boolean;
21
+ }
22
+
23
+ const LOCAL_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);
24
+
25
+ /** Refuse to send the bearer token in clear text, except to this machine. */
26
+ export function assertSafeBaseUrl(baseUrl: string, allowInsecureHttp = false): void {
27
+ let u: URL;
28
+ try {
29
+ u = new URL(baseUrl);
30
+ } catch {
31
+ throw new Error(`FLUXFILES_URL is not a valid URL: ${baseUrl}`);
32
+ }
33
+ if (u.protocol === 'https:') return;
34
+ if (u.protocol !== 'http:') throw new Error(`FLUXFILES_URL must be http(s), got ${u.protocol}`);
35
+ if (LOCAL_HOSTS.has(u.hostname) || allowInsecureHttp) return;
36
+ throw new Error(
37
+ `Refusing to send the FluxFiles token over plain http to ${u.hostname} — use https, ` +
38
+ 'or set FLUXFILES_MCP_ALLOW_HTTP=1 if this network is trusted.',
39
+ );
19
40
  }
20
41
 
21
42
  export class FluxFilesClient {
@@ -23,6 +44,7 @@ export class FluxFilesClient {
23
44
  private readonly f: typeof fetch;
24
45
 
25
46
  constructor(private readonly cfg: ClientConfig) {
47
+ assertSafeBaseUrl(cfg.baseUrl, cfg.allowInsecureHttp);
26
48
  this.base = cfg.baseUrl.replace(/\/+$/, '');
27
49
  this.f = cfg.fetch ?? fetch;
28
50
  }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { createServer, VERSION, type ServerConfig } from './server.js';
2
2
  export { buildTools, type ToolDef, type ToolOptions } from './tools.js';
3
- export { FluxFilesClient, FluxFilesError, type ClientConfig } from './client.js';
3
+ export { FluxFilesClient, FluxFilesError, assertSafeBaseUrl, type ClientConfig } from './client.js';
package/src/server.ts CHANGED
@@ -6,12 +6,13 @@ export interface ServerConfig extends Partial<ToolOptions> {
6
6
  baseUrl: string;
7
7
  token: string;
8
8
  fetch?: typeof fetch;
9
+ allowInsecureHttp?: boolean;
9
10
  }
10
11
 
11
- export const VERSION = '0.1.0';
12
+ export const VERSION = '0.1.1';
12
13
 
13
14
  export function createServer(cfg: ServerConfig): McpServer {
14
- const client = new FluxFilesClient({ baseUrl: cfg.baseUrl, token: cfg.token, fetch: cfg.fetch });
15
+ const client = new FluxFilesClient({ baseUrl: cfg.baseUrl, token: cfg.token, fetch: cfg.fetch, allowInsecureHttp: cfg.allowInsecureHttp });
15
16
  const server = new McpServer({ name: 'fluxfiles', version: VERSION });
16
17
  const tools = buildTools(client, {
17
18
  disk: cfg.disk ?? 'local',