@contextful-com/contextful-mcp 0.0.0-stage → 0.2.0

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
@@ -1,3 +1,83 @@
1
- # Temporary Holding Version
1
+ # Contextful
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Connect Claude Code or Codex to your Contextful Hub. The installer sets up the
4
+ local MCP server, hooks, and skills, and guides you through account connection.
5
+ Your Hub runs separately in the cloud or on your own infrastructure.
6
+
7
+ ## Install
8
+
9
+ Run this from your project, using the Hub URL provided by your dashboard:
10
+
11
+ ```sh
12
+ npx @contextful-com/contextful-mcp@latest install --hub https://YOUR-HUB
13
+ ```
14
+
15
+ Follow the browser sign-in and choose your agent when prompted. The installer
16
+ discovers the Hub endpoints and your organizations. It reuses a saved or sole
17
+ organization; otherwise, choose an organization by name. It asks before uploading
18
+ committed repository history. Private prompt history and usage are opt-in.
19
+ It then asks whether to upload new commits on your default branch automatically
20
+ and, when your Hub offers it, whether to share the lessons your agent writes down.
21
+
22
+ To choose an agent explicitly, add `--client codex` or `--client claude`.
23
+
24
+ ## Ask your agent to install
25
+
26
+ Copy this prompt and replace the Hub URL:
27
+
28
+ > Install Contextful for this project using https://YOUR-HUB and the official
29
+ > @contextful-com/contextful-mcp npm package. Use the current agent, or ask whether
30
+ > I want Codex or Claude Code. Guide me through browser sign-in and complete the
31
+ > MCP, hooks, and skills installation. Ask before uploading repository history,
32
+ > turning on automatic updates, or sharing lessons.
33
+
34
+ Instructions for the installing agent:
35
+
36
+ - Run the package's `install --hub <URL>` command from the project and supply
37
+ `--client codex` or `--client claude`. Use `--scope repo --project .` for this
38
+ project, and `--json --no-open --no-wait --no-history` to handle progress and
39
+ keep private history local. If no project is available, ask which folder to use.
40
+ - `npx -y` accepts npm's package download prompt. The install command's `--yes`
41
+ separately approves committed-history upload; use it only after user approval.
42
+ - `--yes` answers no other question. Ask whether to upload new commits on the
43
+ default branch automatically and whether to share the lessons the agent writes
44
+ down; add `--auto-refresh` and `--share-lessons` or `--no-share-lessons` only
45
+ after the user answers. Without them, automatic updates stay off.
46
+ - Show `authorization_required`'s link and code immediately, and keep the process
47
+ running while the user signs in. Do not request passwords or read stored tokens.
48
+ - On `organization_required`, ask the user to choose from the returned names;
49
+ supply the selected ID internally when resuming. On `consent_required`, obtain
50
+ approval for the stated Hub and upload, then resume with the returned arguments.
51
+ Prefix returned `contextful-mcp` commands with this npm package when needed.
52
+ - After `complete`, report the installed agent and required activation actions.
53
+ Hub training may still be running. Do not report pending training as ready, or
54
+ bypass the agent's hook trust. Rerun the same install command to resume failures.
55
+
56
+ ## Requirements
57
+
58
+ - Node.js 24 or newer and npm to run the npm launcher.
59
+ - A supported Claude Code or Codex installation. The installer checks its version.
60
+ - macOS ARM64/x64, Linux ARM64/x64 with glibc, or Windows x64.
61
+
62
+ npm installs the matching prebuilt binary. No compiler or Bun installation is
63
+ needed. Installed plugins keep their own executable, so they continue working
64
+ independently of npm's cache and without Node or Bun on their runtime path.
65
+
66
+ ## Update or uninstall
67
+
68
+ Rerun the install command with `@latest` to update your integration. To select a
69
+ specific release, replace `latest` with its version.
70
+
71
+ ```sh
72
+ npx @contextful-com/contextful-mcp@latest uninstall
73
+ ```
74
+
75
+ For a persistent command on your PATH:
76
+
77
+ ```sh
78
+ npm install -g @contextful-com/contextful-mcp
79
+ contextful-mcp install --hub https://YOUR-HUB
80
+ ```
81
+
82
+ Removing the global npm package removes the launcher. Use `contextful-mcp uninstall`
83
+ to remove the installed agent integration.
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ // Public npm bootstrap. The application runs in the selected standalone binary.
3
+ import * as fs from 'node:fs';
4
+ import * as path from 'node:path';
5
+ import { Buffer } from 'node:buffer';
6
+ import { createHash } from 'node:crypto';
7
+ import { createRequire } from 'node:module';
8
+ import { spawn } from 'node:child_process';
9
+ import { constants } from 'node:os';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ export function selectTarget(platform, arch, glibc) {
13
+ const target = `${platform}-${arch}`;
14
+ if (!['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64'].includes(target)) {
15
+ throw new Error(`Unsupported platform: ${target}. Contextful supports macOS ARM64/x64, Linux ARM64/x64 (glibc), and Windows x64.`);
16
+ }
17
+ if (platform === 'linux' && !glibc) throw new Error('Contextful requires glibc on Linux. musl/Alpine is not supported by this release.');
18
+ return target;
19
+ }
20
+
21
+ function checksum(file) {
22
+ const hash = createHash('sha256');
23
+ const buffer = Buffer.alloc(1024 * 1024);
24
+ const fd = fs.openSync(file, 'r');
25
+ try {
26
+ let bytes;
27
+ while ((bytes = fs.readSync(fd, buffer, 0, buffer.length, null))) hash.update(buffer.subarray(0, bytes));
28
+ return hash.digest('hex');
29
+ } finally { fs.closeSync(fd); }
30
+ }
31
+
32
+ export function resolveBinary(packageRoot) {
33
+ const target = selectTarget(process.platform, process.arch,
34
+ process.platform === 'linux' ? process.report.getReport().header.glibcVersionRuntime : undefined);
35
+ const pkg = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
36
+ const manifest = JSON.parse(fs.readFileSync(path.join(packageRoot, 'native-manifest.json'), 'utf8'));
37
+ const record = manifest.targets?.[target];
38
+ if (manifest.schemaVersion !== 1 || manifest.version !== pkg.version || !record
39
+ || pkg.optionalDependencies?.[record.package] !== pkg.version) {
40
+ throw new Error('The npm launcher and binary manifest have different versions. Reinstall Contextful.');
41
+ }
42
+ let dependency;
43
+ try { dependency = createRequire(path.join(packageRoot, 'package.json')).resolve(`${record.package}/package.json`); }
44
+ catch { throw new Error(`Missing ${record.package}. Reinstall Contextful with optional dependencies enabled (remove --omit=optional).`); }
45
+ const installed = JSON.parse(fs.readFileSync(dependency, 'utf8'));
46
+ if (installed.name !== record.package || installed.version !== pkg.version) {
47
+ throw new Error(`The ${record.package} version does not match the launcher (${pkg.version}). Reinstall Contextful.`);
48
+ }
49
+ const expectedPath = `bin/contextful-mcp${process.platform === 'win32' ? '.exe' : ''}`;
50
+ if (record.executable !== expectedPath || !/^[a-f0-9]{64}$/.test(record.sha256)) {
51
+ throw new Error('Invalid Contextful binary manifest. Reinstall Contextful.');
52
+ }
53
+ const executable = path.join(path.dirname(dependency), expectedPath);
54
+ const info = fs.lstatSync(executable);
55
+ if (!info.isFile() || info.size !== record.size || checksum(executable) !== record.sha256) {
56
+ throw new Error(`Binary checksum verification failed for ${record.package}. Reinstall Contextful.`);
57
+ }
58
+ return executable;
59
+ }
60
+
61
+ function main() {
62
+ let executable;
63
+ try { executable = resolveBinary(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')); }
64
+ catch (error) {
65
+ process.stderr.write(`Contextful could not start: ${error.message}\n`);
66
+ process.exitCode = 1;
67
+ return;
68
+ }
69
+ const child = spawn(executable, process.argv.slice(2), { stdio: 'inherit', shell: false });
70
+ const handlers = new Map(['SIGINT', 'SIGTERM', 'SIGHUP'].map(signal => [signal, () => { child.kill(signal); }]));
71
+ for (const [signal, handler] of handlers) process.on(signal, handler);
72
+ const cleanup = () => { for (const [signal, handler] of handlers) process.off(signal, handler); };
73
+ child.once('error', error => {
74
+ cleanup();
75
+ process.stderr.write(`Contextful could not start its binary: ${error.message}\n`);
76
+ process.exitCode = 1;
77
+ });
78
+ child.once('exit', (code, signal) => {
79
+ cleanup();
80
+ if (signal && process.platform !== 'win32') process.kill(process.pid, signal);
81
+ else process.exitCode = code ?? (signal ? 128 + (constants.signals[signal] ?? 1) : 1);
82
+ });
83
+ }
84
+
85
+ if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) main();
@@ -0,0 +1,36 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "version": "0.2.0",
4
+ "targets": {
5
+ "darwin-arm64": {
6
+ "package": "@contextful-com/contextful-mcp-darwin-arm64",
7
+ "executable": "bin/contextful-mcp",
8
+ "sha256": "d9ab0e49d4439290df575d5a00fa1090a92ecfa335290c038c015d312e269f7c",
9
+ "size": 65991666
10
+ },
11
+ "darwin-x64": {
12
+ "package": "@contextful-com/contextful-mcp-darwin-x64",
13
+ "executable": "bin/contextful-mcp",
14
+ "sha256": "148cb3f6dd6a01e3de04eb10f2d5647683b2a59da7d0cbafdf2efbcaa39b9a63",
15
+ "size": 73068816
16
+ },
17
+ "linux-arm64": {
18
+ "package": "@contextful-com/contextful-mcp-linux-arm64",
19
+ "executable": "bin/contextful-mcp",
20
+ "sha256": "2567f022f54df6f62a60ca422bb95547ef781415faf566130bbdb703082c243e",
21
+ "size": 85051688
22
+ },
23
+ "linux-x64": {
24
+ "package": "@contextful-com/contextful-mcp-linux-x64",
25
+ "executable": "bin/contextful-mcp",
26
+ "sha256": "beccfc11eba4f6f080e6ddf5d14667f237a0e4407385ae07eccee83f30faf044",
27
+ "size": 85050848
28
+ },
29
+ "win32-x64": {
30
+ "package": "@contextful-com/contextful-mcp-win32-x64",
31
+ "executable": "bin/contextful-mcp.exe",
32
+ "sha256": "81d71b9a147c43b1b149a7b9de7f6986ae26a15823a7d45cd7122c7aebd6ba15",
33
+ "size": 89822720
34
+ }
35
+ }
36
+ }
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@contextful-com/contextful-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "license": "UNLICENSED",
5
+ "publishConfig": {
6
+ "access": "public",
7
+ "registry": "https://registry.npmjs.org/"
8
+ },
9
+ "description": "Install Contextful MCP, hooks and skills for Claude Code and Codex",
10
+ "type": "module",
11
+ "engines": {
12
+ "node": ">=24.0.0"
13
+ },
14
+ "bin": {
15
+ "contextful-mcp": "bin/contextful-mcp.mjs"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "native-manifest.json"
20
+ ],
21
+ "optionalDependencies": {
22
+ "@contextful-com/contextful-mcp-darwin-arm64": "0.2.0",
23
+ "@contextful-com/contextful-mcp-darwin-x64": "0.2.0",
24
+ "@contextful-com/contextful-mcp-linux-arm64": "0.2.0",
25
+ "@contextful-com/contextful-mcp-linux-x64": "0.2.0",
26
+ "@contextful-com/contextful-mcp-win32-x64": "0.2.0"
27
+ }
28
+ }