@theronap/cortex-mcp 0.6.0 → 0.7.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/lib/server.mjs +24 -5
- package/package.json +1 -1
package/lib/server.mjs
CHANGED
|
@@ -52,13 +52,32 @@ export async function runServer(version) {
|
|
|
52
52
|
{
|
|
53
53
|
title: 'Search the org',
|
|
54
54
|
description: 'Search your visible work activity and projects by keyword.',
|
|
55
|
-
inputSchema: { query: z.string().describe('keyword to search for') },
|
|
55
|
+
inputSchema: { query: z.string().describe('keyword to search for — people or work activity') },
|
|
56
56
|
},
|
|
57
57
|
async ({ query }) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
58
|
+
// Real search via /api/search: records (RLS-scoped retrieve) + graph entities (people),
|
|
59
|
+
// instead of substring-grepping the cached context. People were previously invisible to search.
|
|
60
|
+
const res = await fetchCortex(`${BASE}/api/search?q=${encodeURIComponent(query)}`, { headers: { Authorization: `Bearer ${TOKEN}` } })
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
const body = await res.text()
|
|
63
|
+
throw new Error(classify(res.status, res.headers.get('content-type'), body, res.headers.get('x-vercel-id')).message)
|
|
64
|
+
}
|
|
65
|
+
const { people = [], records = [] } = await res.json()
|
|
66
|
+
if (!people.length && !records.length) return { content: [{ type: 'text', text: `No visible results for "${query}".` }] }
|
|
67
|
+
const lines = []
|
|
68
|
+
if (people.length) {
|
|
69
|
+
lines.push('People:')
|
|
70
|
+
for (const p of people) {
|
|
71
|
+
const meta = [p.title, p.company].filter(Boolean).join(', ')
|
|
72
|
+
lines.push(`- ${p.name}${meta ? ` (${meta})` : ''} — mentioned in ${p.mentions} record${p.mentions === 1 ? '' : 's'}`)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (records.length) {
|
|
76
|
+
if (lines.length) lines.push('')
|
|
77
|
+
lines.push('Activity:')
|
|
78
|
+
for (const r of records) lines.push(`- [${r.source}] ${r.title}${r.project ? ` (${r.project})` : ''}`)
|
|
79
|
+
}
|
|
80
|
+
return { content: [{ type: 'text', text: `Results for "${query}":\n${lines.join('\n')}` }] }
|
|
62
81
|
},
|
|
63
82
|
)
|
|
64
83
|
|