@theronap/cortex-mcp 0.9.26 → 0.9.27

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 +34 -7
  2. package/package.json +1 -1
package/lib/server.mjs CHANGED
@@ -249,12 +249,44 @@ export async function runServer(version) {
249
249
  description:
250
250
  'READ the full authored wiki page for one node (project/person/org/you) by its canonical name — every section, every tier you can see. This is how you READ a node; `grep` only LOCATES pages (snippets + their [[links]]), it does not read them. Navigate like a researcher: read the page you need, then FOLLOW its inline [[links]] by calling read_page on each linked name — keep following while the linked pages stay relevant, stop when they do not. You decide how deep to go. Returns only what you are permitted to see.',
251
251
  inputSchema: {
252
- name: z.string().describe('the canonical node name exactly as written (e.g. "Cortex", "Ben", or a [[link]] target)'),
252
+ name: z.string().describe('the canonical node name exactly as written (e.g. "Cortex", "Ben", or a [[link]] target) — identifier links ([[repo:owner/name]]) resolve to their authored HOME + a visible-event count'),
253
253
  kind: z.enum(['project', 'person', 'org', 'user']).optional().describe('node kind (default project; pass person/org for people/teams)'),
254
+ expand: z.boolean().optional().describe('identifier names only: also list recent visible timeline events for this identifier (default: home + count)'),
254
255
  },
255
256
  },
256
- async ({ name, kind }) => {
257
+ async ({ name, kind, expand }) => {
257
258
  const k = kind ?? 'project'
259
+ // IDENTIFIER RESOLUTION (slice 3): an identifier-shaped name is a JOIN KEY, not a page — resolve
260
+ // it to its authored home + a viewer-honest event count instead of 404ing. Loose shape-detect here;
261
+ // the server enforces the strict canonical law (identifiers.ts) and 400s malformed forms with an
262
+ // actionable message we surface verbatim.
263
+ if (/^[a-z][a-z0-9_-]*:.+/i.test(name)) {
264
+ try {
265
+ const qs = new URLSearchParams({ id: name, ...(expand ? { expand: '1' } : {}) })
266
+ const r = await fetchCortex(`${BASE}/api/identifier/resolve?${qs}`, { headers: { Authorization: `Bearer ${TOKEN}` } })
267
+ if (r.ok) {
268
+ const out = await r.json()
269
+ const lines = [`# ${out.identifier} (identifier — a join key, not a page)`]
270
+ if (out.status === 'unhomed') {
271
+ lines.push(`No authored home carries this stamp yet — data but no home. If you know what this identifies, author its page and stamp [[${out.identifier}]] on it (that page becomes the home).`)
272
+ } else if (out.status === 'healthy') {
273
+ const h = out.homes[0]
274
+ lines.push(`Home: "${h.title}" (${h.kind}, ${h.tier}) — \`read_page "${h.title}"\` for the full page.`)
275
+ } else {
276
+ lines.push(`⚠ ${out.homes.length} pages carry this stamp — possible duplicate homes, consider reconciling:`)
277
+ for (const h of out.homes) lines.push(` - "${h.title}" (${h.kind}, ${h.tier})`)
278
+ }
279
+ lines.push(`· ${out.events.visibleCount} tagged timeline event${out.events.visibleCount === 1 ? '' : 's'} visible to you${out.events.recent.length ? ':' : expand ? '.' : ' — pass expand: true to list recent ones.'}`)
280
+ for (const e of out.events.recent) lines.push(` - ${String(e.occurredAt).slice(0, 10)} · ${e.source} · ${e.summary}`)
281
+ return { content: [{ type: 'text', text: lines.join('\n') }] }
282
+ }
283
+ if (r.status === 400) {
284
+ const body = await r.json().catch(() => null)
285
+ return { content: [{ type: 'text', text: `"${name}" looks like an identifier but is not canonical: ${body?.error ?? 'expected repo:owner/name'}. Fix the stamp, or \`grep "${name}"\` to find where it appears.` }] }
286
+ }
287
+ // resolver endpoint unavailable (older server) → fall through to the normal page path below
288
+ } catch { /* network hiccup → fall through to the page path */ }
289
+ }
258
290
  let res
259
291
  try {
260
292
  res = await fetchCortex(`${BASE}/api/brain/page?kind=${k}&key=${encodeURIComponent(name)}`,
@@ -263,11 +295,6 @@ export async function runServer(version) {
263
295
  return { content: [{ type: 'text', text: `Could not read "${name}": ${e.message}` }] }
264
296
  }
265
297
  if (res.status === 404) {
266
- // Identifier links ([[repo:owner/name]]) are JOIN KEYS, not pages — a 404 here is expected.
267
- // The home/expand resolver arrives in a later slice; until then grep is the join.
268
- if (/^[a-z][a-z0-9_-]*:.+/i.test(name)) {
269
- return { content: [{ type: 'text', text: `"${name}" is an identifier link (a join key), not a page — there is nothing to read at it yet. \`grep "${name}"\` to find every page carrying this stamp; the timeline resolver for identifiers lands in a later slice.` }] }
270
- }
271
298
  return { content: [{ type: 'text', text: `No ${k} page named "${name}". If it's a person or team, pass kind (person/org). Otherwise \`grep "${name}"\` to locate it — it may be a red-link (a wanted page that isn't authored yet).` }] }
272
299
  }
273
300
  if (!res.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/cortex-mcp",
3
- "version": "0.9.26",
3
+ "version": "0.9.27",
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": {