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