brainx-skill 1.0.13 → 1.0.14

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.
Files changed (44) hide show
  1. package/README.md +26 -0
  2. package/installation/lib/cli.js +16 -4
  3. package/installation/lib/literature-mcp.js +536 -0
  4. package/manifest.json +2 -0
  5. package/mcp-servers/codex/README.md +24 -4
  6. package/mcp-servers/codex/UPSTREAM.md +3 -1
  7. package/mcp-servers/codex/server.mjs +2 -0
  8. package/mcp-servers/codex/system-prompt.md +30 -19
  9. package/mcp-servers/codex/test/server.test.mjs +12 -1
  10. package/mcp-servers/fulltext-resolver/README.md +136 -0
  11. package/mcp-servers/fulltext-resolver/REUSE.md +32 -0
  12. package/mcp-servers/fulltext-resolver/THIRD_PARTY_NOTICES.md +57 -0
  13. package/mcp-servers/fulltext-resolver/server.mjs +128 -0
  14. package/mcp-servers/fulltext-resolver/src/document.mjs +253 -0
  15. package/mcp-servers/fulltext-resolver/src/http.mjs +173 -0
  16. package/mcp-servers/fulltext-resolver/src/identifiers.mjs +123 -0
  17. package/mcp-servers/fulltext-resolver/src/model.mjs +105 -0
  18. package/mcp-servers/fulltext-resolver/src/resolver.mjs +305 -0
  19. package/mcp-servers/fulltext-resolver/src/sources/biorxiv.mjs +135 -0
  20. package/mcp-servers/fulltext-resolver/src/sources/europe-pmc.mjs +132 -0
  21. package/mcp-servers/fulltext-resolver/src/sources/openalex.mjs +165 -0
  22. package/mcp-servers/fulltext-resolver/test/document.test.mjs +82 -0
  23. package/mcp-servers/fulltext-resolver/test/resolver.test.mjs +287 -0
  24. package/mcp-servers/fulltext-resolver/test/server.test.mjs +63 -0
  25. package/mcp-servers/fulltext-resolver/test/sources.test.mjs +229 -0
  26. package/package.json +10 -3
  27. package/skills/bio-neuro-lit/SKILL.md +206 -0
  28. package/skills/bio-neuro-lit/THIRD_PARTY_NOTICES.md +34 -0
  29. package/skills/bio-neuro-lit/agents/openai.yaml +4 -0
  30. package/skills/bio-neuro-lit/references/tool-contracts.md +73 -0
  31. package/skills/bio-neuro-lit/scripts/deepxiv_fetch.py +110 -0
  32. package/skills/bio-neuro-lit/scripts/exa_search.py +190 -0
  33. package/skills/brainx-general-guard/SKILL.md +17 -0
  34. package/skills/brainx-modeling-loop/SKILL.md +33 -20
  35. package/skills/brainx-modeling-loop/references/parameter-fitting-workflow.md +47 -7
  36. package/skills/brainx-visualization/SKILL.md +157 -0
  37. package/skills/brainx-visualization/agents/openai.yaml +4 -0
  38. package/skills/brainx-visualization/references/interactive-and-visualization-styling.md +155 -0
  39. package/skills/brainx-visualization/references/neural-data-visualization.md +141 -0
  40. package/skills/brainx-visualization/references/statistical-and-model-visualization.md +133 -0
  41. package/skills/package-skills/braincell/SKILL.md +16 -6
  42. package/skills/package-skills/braincell/references/braintools/input-current.md +200 -0
  43. package/skills/package-skills/braincell/references/braintools/metric.md +152 -0
  44. package/skills/package-skills/braincell/references/braintools/optimizer.md +179 -0
package/README.md CHANGED
@@ -52,6 +52,32 @@ npx --registry=https://registry.npmmirror.com brainx-skill install
52
52
  npx --registry=https://registry.npmmirror.com brainx-skill update
53
53
  ```
54
54
 
55
+ ## MCP servers
56
+
57
+ Install and activate every BrainX MCP integration in Codex with one command:
58
+
59
+ ```bash
60
+ npx brainx-skill mcp install
61
+ ```
62
+
63
+ This installs durable runtimes under `~/.brainx/mcp` and registers:
64
+
65
+ | Server | Registration | Purpose |
66
+ |---|---|---|
67
+ | Europe PMC search | `europepmc` | Search biology and neuroscience literature and retrieve structured article metadata. |
68
+ | Full-text resolver | `fulltext_resolver` | Resolve PMC, OpenAlex, and bioRxiv/medRxiv full-text versions with provenance. |
69
+ | BrainX Codex reviewer | `codex` | Run independent BrainX iteration reviews. |
70
+
71
+ The command requires the Codex CLI, a working Codex login, and `uv`. It refuses to overwrite unrelated registrations. An exact reviewer registration from this repository is retained so its existing approval and timeout settings remain intact. Restart Codex or reload MCP configuration after installation.
72
+
73
+ Remove only the registrations and runtime owned by this installer:
74
+
75
+ ```bash
76
+ npx brainx-skill mcp remove
77
+ ```
78
+
79
+ See `mcp-servers/fulltext-resolver/README.md` and `mcp-servers/codex/README.md` for tool behavior, configuration, and development setup.
80
+
55
81
  ## Installation locations
56
82
 
57
83
  Depending on the selected scope, the canonical `brainx-install` skill is installed into:
@@ -4,6 +4,7 @@ const fs = require('node:fs/promises');
4
4
  const os = require('node:os');
5
5
  const path = require('node:path');
6
6
  const { DEFAULT_ADAPTERS, runInstaller } = require('./installer');
7
+ const { runLiteratureMcp } = require('./literature-mcp');
7
8
  const {
8
9
  InstallCancelledError,
9
10
  NonInteractiveInstallError,
@@ -12,13 +13,19 @@ const {
12
13
 
13
14
  const USAGE = `Usage:
14
15
  npx brainx-skill install
15
- npx brainx-skill update`;
16
+ npx brainx-skill update
17
+ npx brainx-skill mcp install
18
+ npx brainx-skill mcp remove`;
16
19
 
17
20
  function parseCommand(args) {
18
- if (args.length !== 1 || (args[0] !== 'install' && args[0] !== 'update')) {
19
- return null;
21
+ if (args.length === 1 && (args[0] === 'install' || args[0] === 'update')) {
22
+ return args[0];
20
23
  }
21
- return args[0];
24
+ if (args.length === 2 && args[0] === 'mcp'
25
+ && (args[1] === 'install' || args[1] === 'remove')) {
26
+ return `mcp:${args[1]}`;
27
+ }
28
+ return null;
22
29
  }
23
30
 
24
31
  async function runCli(args, options = {}) {
@@ -28,6 +35,11 @@ async function runCli(args, options = {}) {
28
35
  stderr.write(`${USAGE}\n`);
29
36
  return 1;
30
37
  }
38
+ if (command.startsWith('mcp:')) {
39
+ const mcpInstaller = options.mcpInstaller || runLiteratureMcp;
40
+ return mcpInstaller(command.slice(4), options);
41
+ }
42
+
31
43
  const installer = options.installer || runInstaller;
32
44
  if (command === 'update') {
33
45
  return installer(command, options);
@@ -0,0 +1,536 @@
1
+ 'use strict';
2
+
3
+ const childProcess = require('node:child_process');
4
+ const fs = require('node:fs/promises');
5
+ const os = require('node:os');
6
+ const path = require('node:path');
7
+
8
+ const EUROPE_PMC_NAME = 'europepmc';
9
+ const FULLTEXT_NAME = 'fulltext_resolver';
10
+ const CODEX_REVIEWER_NAME = 'codex';
11
+ const EUROPE_PMC_SOURCE = 'git+https://github.com/CoChatAI/europepmc-mcp-server@a1af9d06ec7f5f2caef56005fdc1d9d4f12cb115';
12
+ const RUNTIME_SCHEMA_VERSION = 1;
13
+
14
+ function writeLine(stream, text = '') {
15
+ stream.write(`${text}\n`);
16
+ }
17
+
18
+ function defaultRunner(command, args, options = {}) {
19
+ return childProcess.spawnSync(command, args, {
20
+ cwd: options.cwd,
21
+ env: options.env || process.env,
22
+ encoding: 'utf8',
23
+ stdio: options.stdio || 'pipe',
24
+ });
25
+ }
26
+
27
+ function resultText(result) {
28
+ return [result.stdout, result.stderr, result.error && result.error.message]
29
+ .filter(Boolean)
30
+ .join('\n')
31
+ .trim();
32
+ }
33
+
34
+ async function runChecked(runner, command, args, options, label) {
35
+ const result = await runner(command, args, options);
36
+ if (result.error || result.status !== 0) {
37
+ const detail = resultText(result);
38
+ throw new Error(`${label} failed${detail ? `: ${detail}` : ''}`);
39
+ }
40
+ return result;
41
+ }
42
+
43
+ function executableName(name, platform) {
44
+ return platform === 'win32' ? `${name}.exe` : name;
45
+ }
46
+
47
+ function runtimePaths(homeDir, pathApi, platform) {
48
+ const root = pathApi.resolve(homeDir, '.brainx', 'mcp');
49
+ const europePmcRoot = pathApi.join(root, 'europepmc');
50
+ const europePmcBinDir = pathApi.join(europePmcRoot, 'bin');
51
+ const bundleRoot = pathApi.join(root, 'bundle');
52
+ return {
53
+ root,
54
+ receiptPath: pathApi.join(root, 'receipt.json'),
55
+ packageJsonPath: pathApi.join(root, 'package.json'),
56
+ resolverRoot: pathApi.join(root, 'fulltext-resolver'),
57
+ resolverServer: pathApi.join(root, 'fulltext-resolver', 'server.mjs'),
58
+ bundleRoot,
59
+ codexReviewerRoot: pathApi.join(bundleRoot, 'mcp-servers', 'codex'),
60
+ codexReviewerServer: pathApi.join(bundleRoot, 'mcp-servers', 'codex', 'server.mjs'),
61
+ reviewerSkillsRoot: pathApi.join(bundleRoot, 'skills'),
62
+ europePmcRoot,
63
+ europePmcBinDir,
64
+ europePmcExecutable: pathApi.join(
65
+ europePmcBinDir,
66
+ executableName('europepmc-mcp-server', platform),
67
+ ),
68
+ };
69
+ }
70
+
71
+ function expectedServers(paths, nodeBin) {
72
+ return {
73
+ [EUROPE_PMC_NAME]: {
74
+ command: paths.europePmcExecutable,
75
+ args: [],
76
+ },
77
+ [FULLTEXT_NAME]: {
78
+ command: nodeBin,
79
+ args: [paths.resolverServer],
80
+ },
81
+ [CODEX_REVIEWER_NAME]: {
82
+ command: nodeBin,
83
+ args: [paths.codexReviewerServer],
84
+ },
85
+ };
86
+ }
87
+
88
+ function sameStringArray(left, right) {
89
+ return Array.isArray(left)
90
+ && Array.isArray(right)
91
+ && left.length === right.length
92
+ && left.every((value, index) => value === right[index]);
93
+ }
94
+
95
+ function matchesExpected(server, expected) {
96
+ return Boolean(
97
+ server
98
+ && server.transport
99
+ && server.transport.type === 'stdio'
100
+ && server.transport.command === expected.command
101
+ && sameStringArray(server.transport.args || [], expected.args),
102
+ );
103
+ }
104
+
105
+ async function getCodexServer(runner, codexBin, name) {
106
+ const result = await runner(codexBin, ['mcp', 'get', name, '--json'], {});
107
+ if (!result.error && result.status === 0) {
108
+ try {
109
+ return JSON.parse(result.stdout);
110
+ } catch (error) {
111
+ throw new Error(`Codex returned invalid MCP configuration for ${name}: ${error.message}`);
112
+ }
113
+ }
114
+
115
+ const detail = resultText(result);
116
+ if (/No MCP server named|not found/i.test(detail)) {
117
+ return null;
118
+ }
119
+ throw new Error(`Cannot inspect Codex MCP server ${name}${detail ? `: ${detail}` : ''}`);
120
+ }
121
+
122
+ async function inspectServers(runner, codexBin, expected) {
123
+ const inspected = {};
124
+ for (const [name, spec] of Object.entries(expected)) {
125
+ const existing = await getCodexServer(runner, codexBin, name);
126
+ inspected[name] = {
127
+ existing,
128
+ matches: matchesExpected(existing, spec),
129
+ };
130
+ }
131
+ return inspected;
132
+ }
133
+
134
+ function conflictingNames(inspected) {
135
+ return Object.entries(inspected)
136
+ .filter(([, state]) => state.existing && !state.matches)
137
+ .map(([name]) => name);
138
+ }
139
+
140
+ function asServerSpec(server) {
141
+ if (!server || !server.transport || server.transport.type !== 'stdio') {
142
+ return null;
143
+ }
144
+ return {
145
+ command: server.transport.command,
146
+ args: server.transport.args || [],
147
+ };
148
+ }
149
+
150
+ function legacyReviewerSpec(server, packageRoot, pathApi) {
151
+ const spec = asServerSpec(server);
152
+ if (!spec || spec.args.length !== 1) {
153
+ return null;
154
+ }
155
+ const commandName = pathApi.basename(spec.command).toLowerCase();
156
+ if (commandName !== 'node' && commandName !== 'node.exe') {
157
+ return null;
158
+ }
159
+ const legacyServer = pathApi.resolve(packageRoot, 'mcp-servers', 'codex', 'server.mjs');
160
+ if (pathApi.resolve(spec.args[0]) !== legacyServer) {
161
+ return null;
162
+ }
163
+ const environment = server.transport.env;
164
+ if (environment && Object.keys(environment).length > 0) {
165
+ return null;
166
+ }
167
+ return spec;
168
+ }
169
+
170
+ async function pathExists(fsApi, target) {
171
+ try {
172
+ await fsApi.access(target);
173
+ return true;
174
+ } catch {
175
+ return false;
176
+ }
177
+ }
178
+
179
+ async function readRuntimeReceipt(paths, fsApi) {
180
+ if (!(await pathExists(fsApi, paths.receiptPath))) {
181
+ return null;
182
+ }
183
+ let receipt;
184
+ try {
185
+ receipt = JSON.parse(await fsApi.readFile(paths.receiptPath, 'utf8'));
186
+ } catch (error) {
187
+ throw new Error(`Cannot read the BrainX MCP receipt: ${error.message}`);
188
+ }
189
+ const validServers = receipt.servers
190
+ && typeof receipt.servers === 'object'
191
+ && Object.values(receipt.servers).every((spec) => (
192
+ spec
193
+ && typeof spec.command === 'string'
194
+ && spec.command.length > 0
195
+ && Array.isArray(spec.args)
196
+ && spec.args.every((arg) => typeof arg === 'string')
197
+ ));
198
+ if (receipt.schemaVersion !== RUNTIME_SCHEMA_VERSION || !validServers) {
199
+ throw new Error('The BrainX MCP receipt has an unsupported format');
200
+ }
201
+ return receipt;
202
+ }
203
+
204
+ function receiptOwns(receipt, expected) {
205
+ return Boolean(
206
+ receipt
207
+ && Object.entries(expected).every(([name, spec]) => (
208
+ receipt.servers[name]
209
+ && receipt.servers[name].command === spec.command
210
+ && sameStringArray(receipt.servers[name].args, spec.args)
211
+ )),
212
+ );
213
+ }
214
+
215
+ async function readPackageDependencies(packageRoot, fsApi, pathApi) {
216
+ const packagePath = pathApi.join(packageRoot, 'package.json');
217
+ const packageJson = JSON.parse(await fsApi.readFile(packagePath, 'utf8'));
218
+ const names = [
219
+ '@modelcontextprotocol/sdk',
220
+ 'linkedom',
221
+ 'turndown',
222
+ 'zod',
223
+ ];
224
+ const dependencies = {};
225
+ for (const name of names) {
226
+ const version = packageJson.dependencies && packageJson.dependencies[name];
227
+ if (!version) {
228
+ throw new Error(`package.json is missing the resolver dependency ${name}`);
229
+ }
230
+ dependencies[name] = version;
231
+ }
232
+ return dependencies;
233
+ }
234
+
235
+ async function installRuntimes(options) {
236
+ const {
237
+ fsApi,
238
+ pathApi,
239
+ packageRoot,
240
+ paths,
241
+ runner,
242
+ npmBin,
243
+ uvBin,
244
+ stdout,
245
+ } = options;
246
+
247
+ const resolverSource = pathApi.join(packageRoot, 'mcp-servers', 'fulltext-resolver');
248
+ const codexReviewerSource = pathApi.join(packageRoot, 'mcp-servers', 'codex');
249
+ const skillsSource = pathApi.join(packageRoot, 'skills');
250
+ if (!(await pathExists(fsApi, pathApi.join(resolverSource, 'server.mjs')))) {
251
+ throw new Error(`Bundled Full-Text Resolver is missing: ${resolverSource}`);
252
+ }
253
+ if (!(await pathExists(fsApi, pathApi.join(codexReviewerSource, 'server.mjs')))) {
254
+ throw new Error(`Bundled BrainX Codex reviewer is missing: ${codexReviewerSource}`);
255
+ }
256
+ if (!(await pathExists(fsApi, skillsSource))) {
257
+ throw new Error(`Bundled BrainX skills are missing: ${skillsSource}`);
258
+ }
259
+
260
+ await fsApi.mkdir(paths.root, { recursive: true });
261
+ await fsApi.cp(resolverSource, paths.resolverRoot, {
262
+ recursive: true,
263
+ force: true,
264
+ });
265
+ await fsApi.rm(paths.bundleRoot, { recursive: true, force: true });
266
+ await fsApi.mkdir(pathApi.dirname(paths.codexReviewerRoot), { recursive: true });
267
+ await fsApi.cp(codexReviewerSource, paths.codexReviewerRoot, {
268
+ recursive: true,
269
+ force: true,
270
+ });
271
+ await fsApi.cp(skillsSource, paths.reviewerSkillsRoot, {
272
+ recursive: true,
273
+ force: true,
274
+ });
275
+
276
+ const runtimePackage = {
277
+ private: true,
278
+ type: 'module',
279
+ dependencies: await readPackageDependencies(packageRoot, fsApi, pathApi),
280
+ };
281
+ await fsApi.writeFile(
282
+ paths.packageJsonPath,
283
+ `${JSON.stringify(runtimePackage, null, 2)}\n`,
284
+ 'utf8',
285
+ );
286
+
287
+ writeLine(stdout, 'Installing the Full-Text Resolver runtime...');
288
+ await runChecked(
289
+ runner,
290
+ npmBin,
291
+ ['install', '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund'],
292
+ { cwd: paths.root },
293
+ 'Full-Text Resolver dependency installation',
294
+ );
295
+
296
+ await fsApi.mkdir(paths.europePmcBinDir, { recursive: true });
297
+ writeLine(stdout, 'Installing the pinned Europe PMC MCP runtime...');
298
+ await runChecked(
299
+ runner,
300
+ uvBin,
301
+ ['tool', 'install', '--force', '--from', EUROPE_PMC_SOURCE, 'europepmc-mcp-server'],
302
+ {
303
+ env: {
304
+ ...process.env,
305
+ UV_TOOL_DIR: pathApi.join(paths.europePmcRoot, 'tools'),
306
+ UV_TOOL_BIN_DIR: paths.europePmcBinDir,
307
+ },
308
+ },
309
+ 'Europe PMC MCP installation',
310
+ );
311
+
312
+ if (!(await pathExists(fsApi, paths.europePmcExecutable))) {
313
+ throw new Error(`Europe PMC executable was not created: ${paths.europePmcExecutable}`);
314
+ }
315
+ if (!(await pathExists(fsApi, paths.resolverServer))) {
316
+ throw new Error(`Full-Text Resolver server was not created: ${paths.resolverServer}`);
317
+ }
318
+ if (!(await pathExists(fsApi, paths.codexReviewerServer))) {
319
+ throw new Error(`BrainX Codex reviewer server was not created: ${paths.codexReviewerServer}`);
320
+ }
321
+ }
322
+
323
+ async function addServer(runner, codexBin, name, spec) {
324
+ await runChecked(
325
+ runner,
326
+ codexBin,
327
+ ['mcp', 'add', name, '--', spec.command, ...spec.args],
328
+ {},
329
+ `Codex MCP registration for ${name}`,
330
+ );
331
+ }
332
+
333
+ async function removeServer(runner, codexBin, name) {
334
+ await runChecked(
335
+ runner,
336
+ codexBin,
337
+ ['mcp', 'remove', name],
338
+ {},
339
+ `Codex MCP removal for ${name}`,
340
+ );
341
+ }
342
+
343
+ async function installLiteratureMcp(options) {
344
+ const {
345
+ fsApi,
346
+ pathApi,
347
+ paths,
348
+ runner,
349
+ codexBin,
350
+ stdout,
351
+ packageRoot,
352
+ } = options;
353
+
354
+ let expected = options.expected;
355
+ const inspected = await inspectServers(runner, codexBin, expected);
356
+ const legacyReviewer = legacyReviewerSpec(
357
+ inspected[CODEX_REVIEWER_NAME].existing,
358
+ packageRoot,
359
+ pathApi,
360
+ );
361
+ if (legacyReviewer) {
362
+ expected = { ...expected, [CODEX_REVIEWER_NAME]: legacyReviewer };
363
+ inspected[CODEX_REVIEWER_NAME].matches = true;
364
+ }
365
+ const conflicts = conflictingNames(inspected);
366
+ if (conflicts.length) {
367
+ throw new Error(
368
+ `Refusing to overwrite existing Codex MCP configuration: ${conflicts.join(', ')}`,
369
+ );
370
+ }
371
+
372
+ const receipt = await readRuntimeReceipt(paths, fsApi);
373
+ if (legacyReviewer && !receipt) {
374
+ writeLine(stdout, 'Keeping the existing BrainX Codex reviewer registration and settings.');
375
+ }
376
+ if (!receiptOwns(receipt, expected)) {
377
+ const exactButUnowned = Object.entries(inspected)
378
+ .filter(([name, state]) => (
379
+ state.matches && (name !== CODEX_REVIEWER_NAME || !legacyReviewer)
380
+ ))
381
+ .map(([name]) => name);
382
+ if (exactButUnowned.length) {
383
+ throw new Error(
384
+ `Refusing to adopt existing Codex MCP configuration without a BrainX receipt: ${exactButUnowned.join(', ')}`,
385
+ );
386
+ }
387
+ }
388
+
389
+ const runtimesExist = await pathExists(fsApi, paths.europePmcExecutable)
390
+ && await pathExists(fsApi, paths.resolverServer)
391
+ && await pathExists(fsApi, paths.codexReviewerServer)
392
+ && await pathExists(fsApi, pathApi.join(paths.root, 'node_modules'));
393
+ if (
394
+ runtimesExist
395
+ && receiptOwns(receipt, expected)
396
+ && Object.values(inspected).every((state) => state.matches)
397
+ ) {
398
+ writeLine(stdout, 'BrainX MCP servers are already registered.');
399
+ return 0;
400
+ }
401
+
402
+ await installRuntimes(options);
403
+
404
+ const added = [];
405
+ try {
406
+ for (const [name, spec] of Object.entries(expected)) {
407
+ if (!inspected[name].matches) {
408
+ await addServer(runner, codexBin, name, spec);
409
+ added.push(name);
410
+ }
411
+ }
412
+
413
+ const nextReceipt = {
414
+ schemaVersion: RUNTIME_SCHEMA_VERSION,
415
+ servers: expected,
416
+ };
417
+ await fsApi.writeFile(
418
+ paths.receiptPath,
419
+ `${JSON.stringify(nextReceipt, null, 2)}\n`,
420
+ 'utf8',
421
+ );
422
+ } catch (error) {
423
+ for (const name of added.reverse()) {
424
+ try {
425
+ await removeServer(runner, codexBin, name);
426
+ } catch {
427
+ // Preserve the original failure; the user can remove a residual entry manually.
428
+ }
429
+ }
430
+ throw error;
431
+ }
432
+
433
+ writeLine(stdout, 'Registered Codex MCP servers: europepmc, fulltext_resolver, codex');
434
+ writeLine(stdout, 'Restart Codex or reload MCP configuration before using the new tools.');
435
+ return 0;
436
+ }
437
+
438
+ async function removeLiteratureMcp(options) {
439
+ const {
440
+ fsApi,
441
+ paths,
442
+ runner,
443
+ codexBin,
444
+ stdout,
445
+ } = options;
446
+
447
+ const receipt = await readRuntimeReceipt(paths, fsApi);
448
+ const expectedNames = Object.keys(options.expected);
449
+ const receiptHasEveryServer = receipt
450
+ && expectedNames.every((name) => receipt.servers[name])
451
+ && Object.keys(receipt.servers).every((name) => expectedNames.includes(name));
452
+ const expected = receiptHasEveryServer ? receipt.servers : options.expected;
453
+ const inspected = await inspectServers(runner, codexBin, expected);
454
+ const conflicts = conflictingNames(inspected);
455
+ if (conflicts.length) {
456
+ throw new Error(
457
+ `Refusing to remove MCP configuration not owned by BrainX: ${conflicts.join(', ')}`,
458
+ );
459
+ }
460
+
461
+ const hasRegistrations = Object.values(inspected).some((state) => state.existing);
462
+ const hasRuntime = await pathExists(fsApi, paths.root);
463
+ if (!receiptHasEveryServer || !receiptOwns(receipt, expected)) {
464
+ if (!hasRegistrations && !hasRuntime) {
465
+ writeLine(stdout, 'No BrainX-managed MCP servers are installed.');
466
+ return 0;
467
+ }
468
+ throw new Error('Refusing to remove MCP state without a valid BrainX receipt');
469
+ }
470
+
471
+ for (const name of Object.keys(expected)) {
472
+ if (inspected[name].matches) {
473
+ await removeServer(runner, codexBin, name);
474
+ }
475
+ }
476
+ await fsApi.rm(paths.root, { recursive: true, force: true });
477
+ writeLine(stdout, 'Removed the BrainX MCP registrations and managed runtime.');
478
+ return 0;
479
+ }
480
+
481
+ async function runLiteratureMcp(command, options = {}) {
482
+ const fsApi = options.fsApi || fs;
483
+ const pathApi = options.pathApi || path;
484
+ const homeDir = options.homeDir || os.homedir();
485
+ const packageRoot = options.packageRoot || path.resolve(__dirname, '../..');
486
+ const runner = options.runner || defaultRunner;
487
+ const stdout = options.stdout || process.stdout;
488
+ const stderr = options.stderr || process.stderr;
489
+ const codexBin = options.codexBin || 'codex';
490
+ const npmBin = options.npmBin || 'npm';
491
+ const uvBin = options.uvBin || 'uv';
492
+ const platform = options.platform || process.platform;
493
+ const paths = runtimePaths(homeDir, pathApi, platform);
494
+ const expected = expectedServers(paths, options.nodeBin || process.execPath);
495
+
496
+ try {
497
+ await runChecked(runner, codexBin, ['--version'], {}, 'Codex CLI check');
498
+ const shared = {
499
+ ...options,
500
+ fsApi,
501
+ pathApi,
502
+ homeDir,
503
+ packageRoot,
504
+ runner,
505
+ stdout,
506
+ stderr,
507
+ codexBin,
508
+ npmBin,
509
+ uvBin,
510
+ platform,
511
+ paths,
512
+ expected,
513
+ };
514
+ if (command === 'install') {
515
+ return await installLiteratureMcp(shared);
516
+ }
517
+ if (command === 'remove') {
518
+ return await removeLiteratureMcp(shared);
519
+ }
520
+ throw new Error(`Unknown literature MCP command: ${command}`);
521
+ } catch (error) {
522
+ writeLine(stderr, `x BrainX MCP ${command} failed: ${error.message}`);
523
+ return 1;
524
+ }
525
+ }
526
+
527
+ module.exports = {
528
+ CODEX_REVIEWER_NAME,
529
+ EUROPE_PMC_NAME,
530
+ EUROPE_PMC_SOURCE,
531
+ FULLTEXT_NAME,
532
+ expectedServers,
533
+ matchesExpected,
534
+ runLiteratureMcp,
535
+ runtimePaths,
536
+ };
package/manifest.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "skills": [
4
+ "bio-neuro-lit",
4
5
  "brainx-modeling-loop",
6
+ "brainx-visualization",
5
7
  "brainx-acceleration",
6
8
  "brainx-general-guard",
7
9
  "braincell",
@@ -23,7 +23,15 @@ All `codex-reply` calls and other MCP messages pass through unchanged.
23
23
 
24
24
  ## Register
25
25
 
26
- From this repository, register the proxy under the `codex` server name:
26
+ Install and register this reviewer together with Europe PMC search and the Full-Text Resolver:
27
+
28
+ ```bash
29
+ npx brainx-skill mcp install
30
+ ```
31
+
32
+ The installer copies a durable reviewer bundle and its required BrainX skills under `~/.brainx/mcp`, registers it as `codex`, and refuses to overwrite an unrelated registration. An exact reviewer registration from this repository is retained so its existing approval and timeout settings remain intact. Restart Codex or reload MCP configuration after installation. Use `npx brainx-skill mcp remove` to remove the managed registrations and runtime.
33
+
34
+ For repository development or another MCP host, register the proxy manually under the `codex` server name:
27
35
 
28
36
  ```bash
29
37
  claude mcp remove codex -s user
@@ -36,22 +44,34 @@ For a project-scoped Codex host, add the equivalent STDIO server to `.codex/conf
36
44
  [mcp_servers.codex]
37
45
  command = "node"
38
46
  args = ["/absolute/path/to/brainx-skill-bundle/mcp-servers/codex/server.mjs"]
47
+ default_tools_approval_mode = "approve"
39
48
  tool_timeout_sec = 1800
40
49
  ```
41
50
 
51
+ Set `default_tools_approval_mode = "approve"` when a non-interactive Codex host
52
+ must call the reviewer. Without it, Codex cannot present the MCP approval prompt,
53
+ terminates the server before dispatching `tools/call`, and may report the denial
54
+ as `user cancelled MCP tool call`.
55
+
42
56
  Keep `tool_timeout_sec` above the longest expected review turn. A full artifact
43
57
  review commonly exceeds Codex's default MCP tool-call budget; when the host
44
58
  cancels that call, the caller may report `user cancelled MCP tool call` even
45
59
  though no user cancelled it.
46
60
 
61
+ The proxy forces fresh reviews to `sandbox = "read-only"` and
62
+ `approval-policy = "never"` before forwarding them upstream. Auto-approving the
63
+ MCP tool therefore does not grant the reviewer write access or command approval.
64
+
47
65
  Set `BRAINX_CODEX_BIN` only when `codex` is not on `PATH` for the MCP host.
48
66
 
49
67
  ## Use
50
68
 
51
69
  Start a review with `mcp__codex__codex`. Its returned `content` is the reviewer
52
- response available to the calling agent in the same turn. Preserve the returned
53
- `threadId`, then use `mcp__codex__codex-reply` only for a follow-up that must
54
- continue the reviewer's context.
70
+ response available to the calling agent in the same turn. The response is a
71
+ complete Markdown document; the reviewer remains read-only and does not create
72
+ the file. The calling modeling agent saves `content` verbatim as
73
+ `reviews/iteration-<N>.md`, records that path and the returned `threadId`, and
74
+ uses `codex-reply` only for a follow-up that must continue the reviewer's context.
55
75
 
56
76
  Edit `system-prompt.md` to change the reviewer contract. Edit `skills.json` to change the BrainX skills exposed to fresh reviewer sessions.
57
77
 
@@ -17,4 +17,6 @@ Upstream inspected on 2026-08-23:
17
17
  - JSON-RPC dispatch: `codex-rs/mcp-server/src/message_processor.rs`
18
18
  - License: Apache-2.0, the same license used by this repository
19
19
 
20
- Modified behavior is confined to `server.mjs`: fresh `codex` tool calls receive the BrainX system prompt and skill configuration before being forwarded upstream.
20
+ Modified behavior is confined to `server.mjs`: fresh `codex` tool calls receive
21
+ the BrainX system prompt and skill configuration and are forced to read-only,
22
+ no-approval execution before being forwarded upstream.
@@ -92,8 +92,10 @@ function transformMessage(message) {
92
92
  arguments: {
93
93
  ...args,
94
94
  config,
95
+ 'approval-policy': 'never',
95
96
  'base-instructions': systemPrompt,
96
97
  'developer-instructions': skillInstructions,
98
+ sandbox: 'read-only',
97
99
  },
98
100
  },
99
101
  };