@reddb-io/ui-mcp 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.
@@ -0,0 +1,39 @@
1
+ // Target mode detection for the MCP App (#47, ADR-0006).
2
+ //
3
+ // The MCP can be asked to open red-ui against two kinds of target:
4
+ // - REMOTE: an http(s):// or red(s):// URL (or a bare host:port). The browser
5
+ // Surface fetches it directly via the Open Contract (`?cs=`); nothing is
6
+ // spawned.
7
+ // - LOCAL: a filesystem path / `file://` / a `*.rdb` file. A browser cannot
8
+ // reach a file, so this is routed to the local handler seam, which (per
9
+ // ADR-0006, issue #48) spawns a local `red server` in front of the file.
10
+ // Until #48 lands the seam returns a clear "not yet" message.
11
+ //
12
+ // This module is the pure classifier; the `open_red_ui` tool consults it.
13
+ const SCHEME_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
14
+ const RDB_RE = /\.rdb($|[?#])/i;
15
+ const FS_PATH_RE = /^(\.\/|\.\.\/|\/|~\/?|[a-zA-Z]:[\\/])/;
16
+ /**
17
+ * Classify a connection target. An empty/absent target is `remote` (a cold
18
+ * open / Connect screen — there is nothing local to serve). `file://` and
19
+ * filesystem paths (including a bare `*.rdb`) are `local`; every other URL
20
+ * scheme — `http(s)://`, `red(s)://`, `grpc://` — and a bare `host:port` are
21
+ * `remote`. `red://` is remote on purpose: it is browser-reachable as an
22
+ * http(s) alias (ADR-0003), not a local file.
23
+ */
24
+ export function classifyTarget(target) {
25
+ const t = (target ?? "").trim();
26
+ if (!t)
27
+ return "remote";
28
+ if (/^file:\/\//i.test(t))
29
+ return "local";
30
+ // Any explicit URL scheme (http/https/red/reds/grpc/…) is a server endpoint.
31
+ if (SCHEME_RE.test(t))
32
+ return "remote";
33
+ // No scheme: a .rdb file or a filesystem-looking path is a local file.
34
+ if (RDB_RE.test(t) || FS_PATH_RE.test(t))
35
+ return "local";
36
+ // Bare host:port (or hostname) — normalizeUrl prepends http:// → remote.
37
+ return "remote";
38
+ }
39
+ //# sourceMappingURL=target-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target-mode.js","sourceRoot":"","sources":["../src/target-mode.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,mEAAmE;AACnE,gFAAgF;AAChF,6EAA6E;AAC7E,eAAe;AACf,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,0EAA0E;AAI1E,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAC7C,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAChC,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,MAAiC;IAC9D,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,CAAC;QAAE,OAAO,QAAQ,CAAC;IACxB,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,OAAO,CAAC;IAC1C,6EAA6E;IAC7E,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvC,uEAAuE;IACvE,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,OAAO,CAAC;IACzD,yEAAyE;IACzE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@reddb-io/ui-mcp",
3
+ "version": "0.1.1",
4
+ "private": false,
5
+ "description": "MCP Apps server for embedding RedDB UI in MCP clients.",
6
+ "type": "module",
7
+ "bin": {
8
+ "ui-mcp": "./dist/index.js"
9
+ },
10
+ "engines": {
11
+ "node": ">=20"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "dependencies": {
20
+ "@modelcontextprotocol/ext-apps": "^1.7.2",
21
+ "@modelcontextprotocol/sdk": "^1.29.0",
22
+ "zod": "^4.1.13"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^25.9.1",
26
+ "tsx": "^4.22.3",
27
+ "typescript": "^5.7.2"
28
+ },
29
+ "license": "Apache-2.0",
30
+ "homepage": "https://github.com/reddb-io/red-ui",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/reddb-io/red-ui.git",
34
+ "directory": "packages/mcp"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/reddb-io/red-ui/issues"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.json",
41
+ "check": "tsc -p tsconfig.json --noEmit",
42
+ "test": "pnpm build && node test/mcp-app-smoke.mjs && node test/target-mode.test.mjs && node test/local-server.test.mjs && node test/embed-server.test.mjs && node test/data-tools.test.mjs",
43
+ "start": "tsx src/index.ts --stdio"
44
+ }
45
+ }