@theronap/cortex-mcp 0.1.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/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # cortex-mcp
2
+
3
+ Connect your AI assistant to **Cortex** — your org's projects, recent activity, gaps, and directives, scoped to exactly what you're permitted to see.
4
+
5
+ ## Setup
6
+
7
+ 1. Get your personal token from the Cortex console → **Connect your AI**.
8
+ 2. Add this to your Claude Code config (`~/.claude.json`, under `mcpServers`):
9
+
10
+ ```json
11
+ {
12
+ "mcpServers": {
13
+ "cortex": {
14
+ "command": "npx",
15
+ "args": ["-y", "@theronap/cortex-mcp"],
16
+ "env": { "CORTEX_TOKEN": "your-personal-token" }
17
+ }
18
+ }
19
+ }
20
+ ```
21
+
22
+ 3. Restart Claude Code. Your AI now sees your org context automatically.
23
+
24
+ No clone, no path, no build step — `npx` fetches and runs it.
25
+
26
+ ## Tools
27
+
28
+ - **my_context** — your projects, recent activity, gaps, and directives.
29
+ - **search_org** — search your visible activity and projects by keyword.
30
+ - **project_status** — status of a specific project by key.
31
+
32
+ ## Environment
33
+
34
+ | Var | Required | Default |
35
+ |-----|----------|---------|
36
+ | `CORTEX_TOKEN` | yes | — |
37
+ | `CORTEX_URL` | no | `https://cortex-console.vercel.app` |
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * cortex-mcp — connect your AI assistant to Cortex.
4
+ *
5
+ * Zero-install usage. Add to your Claude Code config (~/.claude.json mcpServers):
6
+ *
7
+ * "cortex": {
8
+ * "command": "npx",
9
+ * "args": ["-y", "cortex-mcp"],
10
+ * "env": { "CORTEX_TOKEN": "<your-personal-token>" }
11
+ * }
12
+ *
13
+ * Get your CORTEX_TOKEN from the Cortex console → Connect your AI.
14
+ *
15
+ * Env:
16
+ * CORTEX_TOKEN (required) your personal token — identifies you + your org
17
+ * CORTEX_URL (optional) defaults to https://cortex-console.vercel.app
18
+ */
19
+
20
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
21
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
22
+ import { z } from 'zod'
23
+
24
+ const VERSION = '0.1.0'
25
+ const arg = process.argv[2]
26
+ if (arg === '--version' || arg === '-v') { process.stdout.write(`cortex-mcp ${VERSION}\n`); process.exit(0) }
27
+ if (arg === '--help' || arg === '-h') {
28
+ process.stdout.write(
29
+ `cortex-mcp ${VERSION} — connect your AI assistant to Cortex\n\n` +
30
+ `Set CORTEX_TOKEN (from the Cortex console → Connect your AI) and run via your\n` +
31
+ `MCP client. Optional CORTEX_URL overrides the API base.\n\n` +
32
+ `Claude Code config:\n` +
33
+ ` "cortex": { "command": "npx", "args": ["-y", "cortex-mcp"],\n` +
34
+ ` "env": { "CORTEX_TOKEN": "..." } }\n`
35
+ )
36
+ process.exit(0)
37
+ }
38
+
39
+ const TOKEN = process.env.CORTEX_TOKEN
40
+ const BASE = (process.env.CORTEX_URL ?? 'https://cortex-console.vercel.app').replace(/\/$/, '')
41
+
42
+ if (!TOKEN) {
43
+ process.stderr.write('cortex-mcp: CORTEX_TOKEN is required. Get yours from the Cortex console → Connect your AI.\n')
44
+ process.exit(1)
45
+ }
46
+
47
+ // Cache context for 5 minutes so repeated tool calls don't re-fetch.
48
+ let cache = null
49
+ async function fetchContext() {
50
+ const now = Date.now()
51
+ if (cache && now - cache.ts < 5 * 60 * 1000) return cache.text
52
+ const res = await fetch(`${BASE}/api/mcp-context`, { headers: { Authorization: `Bearer ${TOKEN}` } })
53
+ if (!res.ok) {
54
+ let detail = 'unknown'
55
+ try { detail = (await res.json()).error ?? detail } catch { /* ignore */ }
56
+ throw new Error(`Cortex API ${res.status}: ${detail}`)
57
+ }
58
+ const { context } = await res.json()
59
+ cache = { text: context, ts: now }
60
+ return context
61
+ }
62
+
63
+ const server = new McpServer({ name: 'cortex', version: VERSION })
64
+
65
+ server.registerTool(
66
+ 'my_context',
67
+ {
68
+ title: 'My Cortex context',
69
+ description: 'Your current work context from the org — your projects, recent activity, gaps, and any directives from leadership. Scoped to what you are permitted to see.',
70
+ inputSchema: {},
71
+ },
72
+ async () => ({ content: [{ type: 'text', text: await fetchContext() }] }),
73
+ )
74
+
75
+ server.registerTool(
76
+ 'search_org',
77
+ {
78
+ title: 'Search the org',
79
+ description: 'Search your visible work activity and projects by keyword.',
80
+ inputSchema: { query: z.string().describe('keyword to search for') },
81
+ },
82
+ async ({ query }) => {
83
+ const text = await fetchContext()
84
+ const q = query.toLowerCase()
85
+ const lines = text.split('\n').filter((l) => l.toLowerCase().includes(q))
86
+ return { content: [{ type: 'text', text: lines.length ? `Matches for "${query}":\n${lines.join('\n')}` : `No visible results for "${query}".` }] }
87
+ },
88
+ )
89
+
90
+ server.registerTool(
91
+ 'project_status',
92
+ {
93
+ title: 'Project status',
94
+ description: 'Status of a specific project by key (e.g. checkout-v2). Returns only what you can see.',
95
+ inputSchema: { key: z.string().describe('project key, e.g. checkout-v2') },
96
+ },
97
+ async ({ key }) => {
98
+ const text = await fetchContext()
99
+ const line = text.split('\n').find((l) => l.includes(`**${key}**`) || l.includes(key))
100
+ return { content: [{ type: 'text', text: line ? `Project ${key}:\n${line.trim()}` : `No visible project "${key}".` }] }
101
+ },
102
+ )
103
+
104
+ await server.connect(new StdioServerTransport())
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@theronap/cortex-mcp",
3
+ "version": "0.1.0",
4
+ "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
+ "type": "module",
6
+ "bin": {
7
+ "cortex-mcp": "bin/cortex-mcp.mjs"
8
+ },
9
+ "files": [
10
+ "bin"
11
+ ],
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "dependencies": {
16
+ "@modelcontextprotocol/sdk": "^1.29.0",
17
+ "zod": "^3.23.8"
18
+ },
19
+ "keywords": ["mcp", "cortex", "claude", "ai", "org-intelligence"],
20
+ "license": "MIT"
21
+ }