@gwdn/nexus-mcp 0.8.7 → 0.8.8
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/dist/server.js +0 -0
- package/package.json +8 -2
- package/.github/workflows/ci.yml +0 -38
- package/.github/workflows/release.yml +0 -57
- package/src/__tests__/auth.test.ts +0 -162
- package/src/__tests__/decision-comments.test.ts +0 -173
- package/src/__tests__/e2e-integration.test.ts +0 -443
- package/src/__tests__/helpers.ts +0 -58
- package/src/__tests__/layer1-knowledge.test.ts +0 -302
- package/src/__tests__/layer2-coordination.test.ts +0 -918
- package/src/__tests__/layer3-governance.test.ts +0 -205
- package/src/__tests__/machine-id.test.ts +0 -136
- package/src/__tests__/nexus-api.test.ts +0 -127
- package/src/__tests__/project-list-and-skill-assign.test.ts +0 -282
- package/src/__tests__/reviews.test.ts +0 -420
- package/src/__tests__/server.test.ts +0 -251
- package/src/__tests__/setup.ts +0 -15
- package/src/__tests__/task-list-and-doc-list.test.ts +0 -226
- package/src/auth.ts +0 -81
- package/src/machine-id.ts +0 -60
- package/src/nexus-api.ts +0 -149
- package/src/server.ts +0 -629
- package/src/tools/add-task-note.ts +0 -50
- package/src/tools/append-session-entry.ts +0 -113
- package/src/tools/classify-document.ts +0 -55
- package/src/tools/create-task.ts +0 -66
- package/src/tools/decision-comments.ts +0 -103
- package/src/tools/delete-document.ts +0 -43
- package/src/tools/directives.ts +0 -303
- package/src/tools/get-document.ts +0 -80
- package/src/tools/get-project-memory.ts +0 -65
- package/src/tools/get-related-entities.ts +0 -73
- package/src/tools/governance.ts +0 -165
- package/src/tools/ingest-document.ts +0 -65
- package/src/tools/letter-inbox.ts +0 -157
- package/src/tools/letters.ts +0 -144
- package/src/tools/list-documents.ts +0 -58
- package/src/tools/list-tasks.ts +0 -57
- package/src/tools/project-list.ts +0 -52
- package/src/tools/reviews.ts +0 -281
- package/src/tools/search-knowledge.ts +0 -68
- package/src/tools/sessions.ts +0 -157
- package/src/tools/skill-assign.ts +0 -142
- package/src/tools/skills.ts +0 -255
- package/src/tools/update-document.ts +0 -66
- package/src/tools/update-task-status.ts +0 -64
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -8
package/src/nexus-api.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nexus API client for MCP server context.
|
|
3
|
-
*
|
|
4
|
-
* Replaces direct Supabase access with HTTP calls to the Nexus API.
|
|
5
|
-
* All operations go through /api/mcp/* endpoints, authenticated
|
|
6
|
-
* via the NEXUS_PRIVATE_TOKEN (nxs_pat_*) Bearer token.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { hostname } from 'node:os'
|
|
10
|
-
import { getMachineId } from './machine-id.js'
|
|
11
|
-
|
|
12
|
-
let _baseUrl: string | null = null
|
|
13
|
-
let _token: string | null = null
|
|
14
|
-
let _machineId: string | null = null
|
|
15
|
-
let _machineName: string | null = null
|
|
16
|
-
|
|
17
|
-
// Eagerly resolve machine ID and hostname (sync, cached after first call)
|
|
18
|
-
try {
|
|
19
|
-
_machineId = getMachineId()
|
|
20
|
-
} catch {
|
|
21
|
-
// machine_id is optional enrichment — never block startup
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
_machineName = hostname()
|
|
25
|
-
} catch {
|
|
26
|
-
// hostname is optional enrichment
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Reset the cached API configuration. Used by E2E tests to switch
|
|
31
|
-
* from mocked env vars to real credentials.
|
|
32
|
-
*/
|
|
33
|
-
export function resetApiConfig(): void {
|
|
34
|
-
_baseUrl = null
|
|
35
|
-
_token = null
|
|
36
|
-
_machineId = getMachineId()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function getConfig(): { baseUrl: string; token: string } {
|
|
40
|
-
if (_baseUrl && _token) return { baseUrl: _baseUrl, token: _token }
|
|
41
|
-
|
|
42
|
-
const url = process.env.NEXUS_API_URL ?? process.env.NEXUS_URL
|
|
43
|
-
const token = process.env.NEXUS_PRIVATE_TOKEN
|
|
44
|
-
|
|
45
|
-
if (!url) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
'MCP: Missing NEXUS_API_URL. Set the base URL of the Nexus app (e.g. https://nexus.gatewarden.eu).',
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
if (!token) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
'MCP: Missing NEXUS_PRIVATE_TOKEN. The MCP server requires a valid nxs_pat_* token.',
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Normalize: strip trailing slash
|
|
57
|
-
_baseUrl = url.replace(/\/$/, '')
|
|
58
|
-
_token = token.trim()
|
|
59
|
-
|
|
60
|
-
return { baseUrl: _baseUrl!, token: _token! }
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface NexusApiResponse<T = unknown> {
|
|
64
|
-
ok: boolean
|
|
65
|
-
status: number
|
|
66
|
-
data: T | null
|
|
67
|
-
error: string | null
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Default HTTP timeout in milliseconds (30 seconds). */
|
|
71
|
-
const DEFAULT_TIMEOUT_MS = 30_000
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Make an authenticated request to the Nexus API.
|
|
75
|
-
*/
|
|
76
|
-
export async function nexusApi<T = unknown>(
|
|
77
|
-
path: string,
|
|
78
|
-
options: {
|
|
79
|
-
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE'
|
|
80
|
-
body?: unknown
|
|
81
|
-
headers?: Record<string, string>
|
|
82
|
-
timeoutMs?: number
|
|
83
|
-
} = {},
|
|
84
|
-
): Promise<NexusApiResponse<T>> {
|
|
85
|
-
const { baseUrl, token } = getConfig()
|
|
86
|
-
const method = options.method ?? 'GET'
|
|
87
|
-
const url = `${baseUrl}${path}`
|
|
88
|
-
|
|
89
|
-
const headers: Record<string, string> = {
|
|
90
|
-
Authorization: `Bearer ${token}`,
|
|
91
|
-
'Content-Type': 'application/json',
|
|
92
|
-
...(_machineId ? { 'X-Nexus-Machine-Id': _machineId } : {}),
|
|
93
|
-
...(_machineName ? { 'X-Nexus-Machine-Name': _machineName } : {}),
|
|
94
|
-
...(options.headers ?? {}),
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
const fetchOpts: RequestInit = {
|
|
99
|
-
method,
|
|
100
|
-
headers,
|
|
101
|
-
signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
102
|
-
}
|
|
103
|
-
if (options.body !== undefined) {
|
|
104
|
-
fetchOpts.body = JSON.stringify(options.body)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const response = await fetch(url, fetchOpts)
|
|
108
|
-
const data = (await response.json()) as T & { error?: string }
|
|
109
|
-
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
return {
|
|
112
|
-
ok: false,
|
|
113
|
-
status: response.status,
|
|
114
|
-
data: null,
|
|
115
|
-
error:
|
|
116
|
-
(data as Record<string, unknown>)?.error as string ??
|
|
117
|
-
`HTTP ${response.status}`,
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return { ok: true, status: response.status, data, error: null }
|
|
122
|
-
} catch (err) {
|
|
123
|
-
return {
|
|
124
|
-
ok: false,
|
|
125
|
-
status: 0,
|
|
126
|
-
data: null,
|
|
127
|
-
error: err instanceof Error ? err.message : 'Unknown fetch error',
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Convenience: POST to a Nexus MCP endpoint.
|
|
134
|
-
*/
|
|
135
|
-
export async function nexusPost<T = unknown>(
|
|
136
|
-
path: string,
|
|
137
|
-
body: unknown,
|
|
138
|
-
): Promise<NexusApiResponse<T>> {
|
|
139
|
-
return nexusApi<T>(path, { method: 'POST', body })
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Convenience: GET from a Nexus MCP endpoint.
|
|
144
|
-
*/
|
|
145
|
-
export async function nexusGet<T = unknown>(
|
|
146
|
-
path: string,
|
|
147
|
-
): Promise<NexusApiResponse<T>> {
|
|
148
|
-
return nexusApi<T>(path, { method: 'GET' })
|
|
149
|
-
}
|