@theronap/cortex-mcp 0.9.0 → 0.9.1
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/bin/cortex-mcp.mjs +1 -1
- package/lib/server.mjs +38 -3
- package/package.json +1 -1
package/bin/cortex-mcp.mjs
CHANGED
package/lib/server.mjs
CHANGED
|
@@ -41,10 +41,45 @@ export async function runServer(version) {
|
|
|
41
41
|
'my_context',
|
|
42
42
|
{
|
|
43
43
|
title: 'My Cortex context',
|
|
44
|
-
description: 'Your current work context from the org
|
|
45
|
-
inputSchema: {},
|
|
44
|
+
description: 'Your current work context from the org. Pass a question to get query-centered session context seeded from the most relevant node and its neighborhood; omit it for the baseline snapshot.',
|
|
45
|
+
inputSchema: { question: z.string().optional().describe('optional opening user question to center the context around') },
|
|
46
|
+
},
|
|
47
|
+
async ({ question }) => {
|
|
48
|
+
if (!question?.trim()) return { content: [{ type: 'text', text: await fetchContext() }] }
|
|
49
|
+
const res = await fetchCortex(`${BASE}/api/session-context`, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
52
|
+
body: JSON.stringify({ question }),
|
|
53
|
+
})
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
const body = await res.text()
|
|
56
|
+
throw new Error(classify(res.status, res.headers.get('content-type'), body, res.headers.get('x-vercel-id')).message)
|
|
57
|
+
}
|
|
58
|
+
const { context } = await res.json()
|
|
59
|
+
return { content: [{ type: 'text', text: context }] }
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
server.registerTool(
|
|
64
|
+
'session_context',
|
|
65
|
+
{
|
|
66
|
+
title: 'Query-centered session context',
|
|
67
|
+
description: 'Build a session-start context block around the user\'s opening question: pick the most relevant seed node, pull its neighborhood, and compress farther hops.',
|
|
68
|
+
inputSchema: { question: z.string().describe('the opening user question or request for this session') },
|
|
69
|
+
},
|
|
70
|
+
async ({ question }) => {
|
|
71
|
+
const res = await fetchCortex(`${BASE}/api/session-context`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
|
74
|
+
body: JSON.stringify({ question }),
|
|
75
|
+
})
|
|
76
|
+
if (!res.ok) {
|
|
77
|
+
const body = await res.text()
|
|
78
|
+
throw new Error(classify(res.status, res.headers.get('content-type'), body, res.headers.get('x-vercel-id')).message)
|
|
79
|
+
}
|
|
80
|
+
const { context } = await res.json()
|
|
81
|
+
return { content: [{ type: 'text', text: context }] }
|
|
46
82
|
},
|
|
47
|
-
async () => ({ content: [{ type: 'text', text: await fetchContext() }] }),
|
|
48
83
|
)
|
|
49
84
|
|
|
50
85
|
server.registerTool(
|