@cookiecrumbs-eu/mcp 0.7.0 → 0.7.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/cli/src/auth.js +3 -55
- package/dist/cli/src/credentials.js +60 -0
- package/dist/mcp/src/auth.js +1 -1
- package/dist/mcp/src/server.js +1 -1
- package/package.json +2 -2
package/dist/cli/src/auth.js
CHANGED
|
@@ -1,62 +1,10 @@
|
|
|
1
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
1
|
import { isDeviceTokenOk } from "./api.js";
|
|
5
2
|
import { CliError } from "./errors.js";
|
|
6
3
|
import { human, spinner } from "./output.js";
|
|
7
4
|
import { openBrowser, sleep, pollMs } from "./util.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return process.env.COOKIECRUMBS_CREDENTIALS;
|
|
12
|
-
if (process.platform === 'win32') {
|
|
13
|
-
const base = process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
|
|
14
|
-
return join(base, 'cookiecrumbs', 'credentials.json');
|
|
15
|
-
}
|
|
16
|
-
const base = process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config');
|
|
17
|
-
return join(base, 'cookiecrumbs', 'credentials.json');
|
|
18
|
-
}
|
|
19
|
-
export function readCredentials() {
|
|
20
|
-
const file = credentialsPath();
|
|
21
|
-
if (!existsSync(file))
|
|
22
|
-
return null;
|
|
23
|
-
try {
|
|
24
|
-
const c = JSON.parse(readFileSync(file, 'utf8'));
|
|
25
|
-
return c && typeof c.token === 'string' ? c : null;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export function writeCredentials(c) {
|
|
32
|
-
const file = credentialsPath();
|
|
33
|
-
mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
|
|
34
|
-
writeFileSync(file, JSON.stringify({ ...c, saved_at: new Date().toISOString() }, null, 2) + '\n', { mode: 0o600 });
|
|
35
|
-
try {
|
|
36
|
-
chmodSync(file, 0o600);
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
/* Windows ignores POSIX modes; the file sits under the user's profile */
|
|
40
|
-
}
|
|
41
|
-
return file;
|
|
42
|
-
}
|
|
43
|
-
export function clearCredentials() {
|
|
44
|
-
const file = credentialsPath();
|
|
45
|
-
if (!existsSync(file))
|
|
46
|
-
return false;
|
|
47
|
-
rmSync(file);
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
/** COOKIECRUMBS_TOKEN wins over the credentials file. */
|
|
51
|
-
export function resolveToken() {
|
|
52
|
-
const env = process.env.COOKIECRUMBS_TOKEN?.trim();
|
|
53
|
-
if (env)
|
|
54
|
-
return { token: env, source: 'env', creds: null };
|
|
55
|
-
const creds = readCredentials();
|
|
56
|
-
if (creds)
|
|
57
|
-
return { token: creds.token, source: 'file', creds };
|
|
58
|
-
return { token: null, source: null, creds: null };
|
|
59
|
-
}
|
|
5
|
+
// The credentials file and token resolution live in credentials.ts (shared with the MCP server);
|
|
6
|
+
// re-exported here so every CLI caller keeps importing them from auth.ts.
|
|
7
|
+
export { credentialsPath, readCredentials, writeCredentials, clearCredentials, resolveToken } from "./credentials.js";
|
|
60
8
|
export const DEFAULT_SCOPES = ['banner:read', 'banner:write', 'banner:publish', 'scans:read', 'scans:run', 'logs:read', 'logs:export', 'sites:read', 'sites:write'];
|
|
61
9
|
/** RFC 8628 device flow: print the URL + code, open the browser unless told not to, poll until a token arrives. */
|
|
62
10
|
export async function deviceFlow(api, opts = {}) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The credentials file and token resolution — the part of the CLI's auth the MCP server shares.
|
|
3
|
+
* Deliberately dependency-free (node built-ins only): @cookiecrumbs-eu/mcp compiles this file in and
|
|
4
|
+
* must not drag the CLI's interactive dependencies (@clack/prompts, picocolors) along with it.
|
|
5
|
+
*/
|
|
6
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
/** `%APPDATA%/cookiecrumbs/credentials.json` on Windows, `~/.config/cookiecrumbs/credentials.json` elsewhere. */
|
|
10
|
+
export function credentialsPath() {
|
|
11
|
+
if (process.env.COOKIECRUMBS_CREDENTIALS)
|
|
12
|
+
return process.env.COOKIECRUMBS_CREDENTIALS;
|
|
13
|
+
if (process.platform === 'win32') {
|
|
14
|
+
const base = process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
|
|
15
|
+
return join(base, 'cookiecrumbs', 'credentials.json');
|
|
16
|
+
}
|
|
17
|
+
const base = process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config');
|
|
18
|
+
return join(base, 'cookiecrumbs', 'credentials.json');
|
|
19
|
+
}
|
|
20
|
+
export function readCredentials() {
|
|
21
|
+
const file = credentialsPath();
|
|
22
|
+
if (!existsSync(file))
|
|
23
|
+
return null;
|
|
24
|
+
try {
|
|
25
|
+
const c = JSON.parse(readFileSync(file, 'utf8'));
|
|
26
|
+
return c && typeof c.token === 'string' ? c : null;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function writeCredentials(c) {
|
|
33
|
+
const file = credentialsPath();
|
|
34
|
+
mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
|
|
35
|
+
writeFileSync(file, JSON.stringify({ ...c, saved_at: new Date().toISOString() }, null, 2) + '\n', { mode: 0o600 });
|
|
36
|
+
try {
|
|
37
|
+
chmodSync(file, 0o600);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
/* Windows ignores POSIX modes; the file sits under the user's profile */
|
|
41
|
+
}
|
|
42
|
+
return file;
|
|
43
|
+
}
|
|
44
|
+
export function clearCredentials() {
|
|
45
|
+
const file = credentialsPath();
|
|
46
|
+
if (!existsSync(file))
|
|
47
|
+
return false;
|
|
48
|
+
rmSync(file);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
/** COOKIECRUMBS_TOKEN wins over the credentials file. */
|
|
52
|
+
export function resolveToken() {
|
|
53
|
+
const env = process.env.COOKIECRUMBS_TOKEN?.trim();
|
|
54
|
+
if (env)
|
|
55
|
+
return { token: env, source: 'env', creds: null };
|
|
56
|
+
const creds = readCredentials();
|
|
57
|
+
if (creds)
|
|
58
|
+
return { token: creds.token, source: 'file', creds };
|
|
59
|
+
return { token: null, source: null, creds: null };
|
|
60
|
+
}
|
package/dist/mcp/src/auth.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* a user code to and no browser to open, so an unauthenticated start-up returns instructions
|
|
10
10
|
* instead of blocking on a poll loop.
|
|
11
11
|
*/
|
|
12
|
-
import { credentialsPath, resolveToken } from "../../cli/src/
|
|
12
|
+
import { credentialsPath, resolveToken } from "../../cli/src/credentials.js";
|
|
13
13
|
import { DEFAULT_API } from "./client.js";
|
|
14
14
|
export function resolveCredentials(env = process.env) {
|
|
15
15
|
const { token, source, creds } = resolveToken();
|
package/dist/mcp/src/server.js
CHANGED
|
@@ -18,7 +18,7 @@ import { McpApi, sanitiseClient } from "./client.js";
|
|
|
18
18
|
import { loginInstructions, resolveCredentials } from "./auth.js";
|
|
19
19
|
import { TOOLS, TOOL_MATRIX, resolveSite, toolAllowed } from "./tools.js";
|
|
20
20
|
export const SERVER_NAME = 'cookiecrumbs';
|
|
21
|
-
export const SERVER_VERSION = '0.7.
|
|
21
|
+
export const SERVER_VERSION = '0.7.1';
|
|
22
22
|
const text = (s) => ({ content: [{ type: 'text', text: s }] });
|
|
23
23
|
const failure = (s) => ({ content: [{ type: 'text', text: s }], isError: true });
|
|
24
24
|
/** RFC 9457 problem+json → something an agent can act on. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cookiecrumbs-eu/mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "CookieCrumbs MCP server — let an AI coding agent read and configure your consent banner, sites, scans, services, alerts, webhooks and templates through audited two-step writes",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "CookieCrumbs <hello@cookiecrumbs.eu> (https://cookiecrumbs.eu)",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"type": "module",
|
|
31
31
|
"bin": {
|
|
32
|
-
"cookiecrumbs-mcp": "
|
|
32
|
+
"cookiecrumbs-mcp": "dist/mcp/src/index.js"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|