@theronap/cortex-mcp 0.9.35 → 0.9.36

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 (2) hide show
  1. package/lib/server.mjs +53 -0
  2. package/package.json +1 -1
package/lib/server.mjs CHANGED
@@ -403,6 +403,59 @@ export async function runServer(version) {
403
403
  },
404
404
  )
405
405
 
406
+ server.registerTool(
407
+ 'my_brains',
408
+ {
409
+ title: 'List your brains + which one writes land in',
410
+ description: 'List the brains (orgs/workspaces) you belong to and show which one is your ACTIVE WRITE brain — where author/log_session/capture currently land. Reads span all your brains; writes go to the active one. Use this to see your options before set_active_brain, or when a session seems to belong to a different brain than the one you are writing to.',
411
+ inputSchema: {},
412
+ },
413
+ async () => {
414
+ let res
415
+ try {
416
+ res = await fetchCortex(`${BASE}/api/brains`, { headers: { Authorization: `Bearer ${TOKEN}` } })
417
+ } catch (e) {
418
+ return { content: [{ type: 'text', text: `Could not list brains: ${e.message}` }] }
419
+ }
420
+ if (!res.ok) {
421
+ const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
422
+ return { content: [{ type: 'text', text: `Could not list brains: ${d.message}` }] }
423
+ }
424
+ const { brains, activeIsExplicit } = await res.json()
425
+ if (!brains?.length) return { content: [{ type: 'text', text: 'You have no brains.' }] }
426
+ const lines = brains.map((b) => `${b.isActive ? '▶' : ' '} ${b.name} (${b.role}${b.status !== 'active' ? `, ${b.status}` : ''}) [${b.orgId}]`)
427
+ const note = activeIsExplicit ? '' : '\n(active brain is the default — you have one brain; set_active_brain once you hold more.)'
428
+ return { content: [{ type: 'text', text: `Your brains (▶ = writes land here):\n${lines.join('\n')}${note}` }] }
429
+ },
430
+ )
431
+
432
+ server.registerTool(
433
+ 'set_active_brain',
434
+ {
435
+ title: 'Choose the brain your writes go to',
436
+ description: 'Point your writes (author / log_session / capture) at one of your brains, by its org id (from my_brains). Sticky — it stays until you change it. Pass org_id = null to clear it and fall back to the default. You can only select a brain you are a member of.',
437
+ inputSchema: { org_id: z.string().nullable().describe('the org id of the brain to write to (from my_brains), or null to clear the pointer') },
438
+ },
439
+ async ({ org_id }) => {
440
+ let res
441
+ try {
442
+ res = await fetchCortex(`${BASE}/api/brains`, {
443
+ method: 'PUT',
444
+ headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
445
+ body: JSON.stringify({ orgId: org_id ?? null }),
446
+ })
447
+ } catch (e) {
448
+ return { content: [{ type: 'text', text: `Could not set active brain: ${e.message}` }] }
449
+ }
450
+ if (!res.ok) {
451
+ const d = classify(res.status, res.headers.get('content-type'), await res.text(), res.headers.get('x-vercel-id'))
452
+ return { content: [{ type: 'text', text: `Could not set active brain: ${d.message}` }] }
453
+ }
454
+ const r = await res.json()
455
+ return { content: [{ type: 'text', text: r.activeOrgId ? `Writes now land in brain ${r.activeOrgId}.` : 'Cleared your active-brain pointer (writes fall back to your default brain).' }] }
456
+ },
457
+ )
458
+
406
459
  server.registerTool(
407
460
  'list_records',
408
461
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/cortex-mcp",
3
- "version": "0.9.35",
3
+ "version": "0.9.36",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {