memory-journal-mcp 4.4.2 → 5.0.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.
Files changed (291) hide show
  1. package/.github/workflows/codeql.yml +1 -6
  2. package/.github/workflows/docker-publish.yml +15 -49
  3. package/.github/workflows/lint-and-test.yml +1 -1
  4. package/.github/workflows/secrets-scanning.yml +4 -3
  5. package/.github/workflows/security-update.yml +3 -3
  6. package/CHANGELOG.md +213 -0
  7. package/CONTRIBUTING.md +132 -97
  8. package/DOCKER_README.md +184 -235
  9. package/Dockerfile +27 -24
  10. package/README.md +218 -190
  11. package/SECURITY.md +27 -35
  12. package/dist/cli.js +16 -1
  13. package/dist/cli.js.map +1 -1
  14. package/dist/constants/ServerInstructions.d.ts +5 -1
  15. package/dist/constants/ServerInstructions.d.ts.map +1 -1
  16. package/dist/constants/ServerInstructions.js +133 -73
  17. package/dist/constants/ServerInstructions.js.map +1 -1
  18. package/dist/constants/icons.d.ts +2 -2
  19. package/dist/constants/icons.d.ts.map +1 -1
  20. package/dist/constants/icons.js +7 -6
  21. package/dist/constants/icons.js.map +1 -1
  22. package/dist/database/SqliteAdapter.d.ts +37 -24
  23. package/dist/database/SqliteAdapter.d.ts.map +1 -1
  24. package/dist/database/SqliteAdapter.js +319 -157
  25. package/dist/database/SqliteAdapter.js.map +1 -1
  26. package/dist/database/schema.d.ts +45 -0
  27. package/dist/database/schema.d.ts.map +1 -0
  28. package/dist/database/schema.js +92 -0
  29. package/dist/database/schema.js.map +1 -0
  30. package/dist/filtering/ToolFilter.d.ts +1 -1
  31. package/dist/filtering/ToolFilter.d.ts.map +1 -1
  32. package/dist/filtering/ToolFilter.js +13 -2
  33. package/dist/filtering/ToolFilter.js.map +1 -1
  34. package/dist/github/GitHubIntegration.d.ts.map +1 -1
  35. package/dist/github/GitHubIntegration.js +1 -3
  36. package/dist/github/GitHubIntegration.js.map +1 -1
  37. package/dist/handlers/prompts/github.d.ts +12 -0
  38. package/dist/handlers/prompts/github.d.ts.map +1 -0
  39. package/dist/handlers/prompts/github.js +178 -0
  40. package/dist/handlers/prompts/github.js.map +1 -0
  41. package/dist/handlers/prompts/index.d.ts +23 -2
  42. package/dist/handlers/prompts/index.d.ts.map +1 -1
  43. package/dist/handlers/prompts/index.js +7 -432
  44. package/dist/handlers/prompts/index.js.map +1 -1
  45. package/dist/handlers/prompts/workflow.d.ts +12 -0
  46. package/dist/handlers/prompts/workflow.d.ts.map +1 -0
  47. package/dist/handlers/prompts/workflow.js +277 -0
  48. package/dist/handlers/prompts/workflow.js.map +1 -0
  49. package/dist/handlers/resources/core.d.ts +11 -0
  50. package/dist/handlers/resources/core.d.ts.map +1 -0
  51. package/dist/handlers/resources/core.js +433 -0
  52. package/dist/handlers/resources/core.js.map +1 -0
  53. package/dist/handlers/resources/github.d.ts +11 -0
  54. package/dist/handlers/resources/github.d.ts.map +1 -0
  55. package/dist/handlers/resources/github.js +314 -0
  56. package/dist/handlers/resources/github.js.map +1 -0
  57. package/dist/handlers/resources/graph.d.ts +11 -0
  58. package/dist/handlers/resources/graph.d.ts.map +1 -0
  59. package/dist/handlers/resources/graph.js +204 -0
  60. package/dist/handlers/resources/graph.js.map +1 -0
  61. package/dist/handlers/resources/index.d.ts +5 -20
  62. package/dist/handlers/resources/index.d.ts.map +1 -1
  63. package/dist/handlers/resources/index.js +16 -1278
  64. package/dist/handlers/resources/index.js.map +1 -1
  65. package/dist/handlers/resources/shared.d.ts +60 -0
  66. package/dist/handlers/resources/shared.d.ts.map +1 -0
  67. package/dist/handlers/resources/shared.js +49 -0
  68. package/dist/handlers/resources/shared.js.map +1 -0
  69. package/dist/handlers/resources/team.d.ts +13 -0
  70. package/dist/handlers/resources/team.d.ts.map +1 -0
  71. package/dist/handlers/resources/team.js +119 -0
  72. package/dist/handlers/resources/team.js.map +1 -0
  73. package/dist/handlers/resources/templates.d.ts +13 -0
  74. package/dist/handlers/resources/templates.d.ts.map +1 -0
  75. package/dist/handlers/resources/templates.js +310 -0
  76. package/dist/handlers/resources/templates.js.map +1 -0
  77. package/dist/handlers/tools/admin.d.ts +8 -0
  78. package/dist/handlers/tools/admin.d.ts.map +1 -0
  79. package/dist/handlers/tools/admin.js +270 -0
  80. package/dist/handlers/tools/admin.js.map +1 -0
  81. package/dist/handlers/tools/analytics.d.ts +8 -0
  82. package/dist/handlers/tools/analytics.d.ts.map +1 -0
  83. package/dist/handlers/tools/analytics.js +256 -0
  84. package/dist/handlers/tools/analytics.js.map +1 -0
  85. package/dist/handlers/tools/backup.d.ts +8 -0
  86. package/dist/handlers/tools/backup.d.ts.map +1 -0
  87. package/dist/handlers/tools/backup.js +224 -0
  88. package/dist/handlers/tools/backup.js.map +1 -0
  89. package/dist/handlers/tools/core.d.ts +9 -0
  90. package/dist/handlers/tools/core.d.ts.map +1 -0
  91. package/dist/handlers/tools/core.js +326 -0
  92. package/dist/handlers/tools/core.js.map +1 -0
  93. package/dist/handlers/tools/export.d.ts +8 -0
  94. package/dist/handlers/tools/export.d.ts.map +1 -0
  95. package/dist/handlers/tools/export.js +89 -0
  96. package/dist/handlers/tools/export.js.map +1 -0
  97. package/dist/handlers/tools/github/helpers.d.ts +34 -0
  98. package/dist/handlers/tools/github/helpers.d.ts.map +1 -0
  99. package/dist/handlers/tools/github/helpers.js +52 -0
  100. package/dist/handlers/tools/github/helpers.js.map +1 -0
  101. package/dist/handlers/tools/github/insights-tools.d.ts +8 -0
  102. package/dist/handlers/tools/github/insights-tools.d.ts.map +1 -0
  103. package/dist/handlers/tools/github/insights-tools.js +104 -0
  104. package/dist/handlers/tools/github/insights-tools.js.map +1 -0
  105. package/dist/handlers/tools/github/issue-tools.d.ts +8 -0
  106. package/dist/handlers/tools/github/issue-tools.d.ts.map +1 -0
  107. package/dist/handlers/tools/github/issue-tools.js +359 -0
  108. package/dist/handlers/tools/github/issue-tools.js.map +1 -0
  109. package/dist/handlers/tools/github/kanban-tools.d.ts +8 -0
  110. package/dist/handlers/tools/github/kanban-tools.d.ts.map +1 -0
  111. package/dist/handlers/tools/github/kanban-tools.js +108 -0
  112. package/dist/handlers/tools/github/kanban-tools.js.map +1 -0
  113. package/dist/handlers/tools/github/milestone-tools.d.ts +9 -0
  114. package/dist/handlers/tools/github/milestone-tools.d.ts.map +1 -0
  115. package/dist/handlers/tools/github/milestone-tools.js +302 -0
  116. package/dist/handlers/tools/github/milestone-tools.js.map +1 -0
  117. package/dist/handlers/tools/github/mutation-tools.d.ts +12 -0
  118. package/dist/handlers/tools/github/mutation-tools.d.ts.map +1 -0
  119. package/dist/handlers/tools/github/mutation-tools.js +15 -0
  120. package/dist/handlers/tools/github/mutation-tools.js.map +1 -0
  121. package/dist/handlers/tools/github/read-tools.d.ts +8 -0
  122. package/dist/handlers/tools/github/read-tools.d.ts.map +1 -0
  123. package/dist/handlers/tools/github/read-tools.js +260 -0
  124. package/dist/handlers/tools/github/read-tools.js.map +1 -0
  125. package/dist/handlers/tools/github/schemas.d.ts +467 -0
  126. package/dist/handlers/tools/github/schemas.d.ts.map +1 -0
  127. package/dist/handlers/tools/github/schemas.js +335 -0
  128. package/dist/handlers/tools/github/schemas.js.map +1 -0
  129. package/dist/handlers/tools/github.d.ts +14 -0
  130. package/dist/handlers/tools/github.d.ts.map +1 -0
  131. package/dist/handlers/tools/github.js +28 -0
  132. package/dist/handlers/tools/github.js.map +1 -0
  133. package/dist/handlers/tools/index.d.ts +15 -20
  134. package/dist/handlers/tools/index.d.ts.map +1 -1
  135. package/dist/handlers/tools/index.js +117 -2909
  136. package/dist/handlers/tools/index.js.map +1 -1
  137. package/dist/handlers/tools/relationships.d.ts +8 -0
  138. package/dist/handlers/tools/relationships.d.ts.map +1 -0
  139. package/dist/handlers/tools/relationships.js +308 -0
  140. package/dist/handlers/tools/relationships.js.map +1 -0
  141. package/dist/handlers/tools/schemas.d.ts +108 -0
  142. package/dist/handlers/tools/schemas.d.ts.map +1 -0
  143. package/dist/handlers/tools/schemas.js +122 -0
  144. package/dist/handlers/tools/schemas.js.map +1 -0
  145. package/dist/handlers/tools/search.d.ts +8 -0
  146. package/dist/handlers/tools/search.d.ts.map +1 -0
  147. package/dist/handlers/tools/search.js +282 -0
  148. package/dist/handlers/tools/search.js.map +1 -0
  149. package/dist/handlers/tools/team.d.ts +11 -0
  150. package/dist/handlers/tools/team.d.ts.map +1 -0
  151. package/dist/handlers/tools/team.js +239 -0
  152. package/dist/handlers/tools/team.js.map +1 -0
  153. package/dist/server/McpServer.d.ts +4 -0
  154. package/dist/server/McpServer.d.ts.map +1 -1
  155. package/dist/server/McpServer.js +48 -297
  156. package/dist/server/McpServer.js.map +1 -1
  157. package/dist/server/Scheduler.d.ts +91 -0
  158. package/dist/server/Scheduler.d.ts.map +1 -0
  159. package/dist/server/Scheduler.js +201 -0
  160. package/dist/server/Scheduler.js.map +1 -0
  161. package/dist/transports/http.d.ts +66 -0
  162. package/dist/transports/http.d.ts.map +1 -0
  163. package/dist/transports/http.js +519 -0
  164. package/dist/transports/http.js.map +1 -0
  165. package/dist/types/entities.d.ts +101 -0
  166. package/dist/types/entities.d.ts.map +1 -0
  167. package/dist/types/entities.js +5 -0
  168. package/dist/types/entities.js.map +1 -0
  169. package/dist/types/filtering.d.ts +34 -0
  170. package/dist/types/filtering.d.ts.map +1 -0
  171. package/dist/types/filtering.js +5 -0
  172. package/dist/types/filtering.js.map +1 -0
  173. package/dist/types/github.d.ts +166 -0
  174. package/dist/types/github.d.ts.map +1 -0
  175. package/dist/types/github.js +5 -0
  176. package/dist/types/github.js.map +1 -0
  177. package/dist/types/index.d.ts +35 -292
  178. package/dist/types/index.d.ts.map +1 -1
  179. package/dist/types/index.js +2 -2
  180. package/dist/types/index.js.map +1 -1
  181. package/dist/utils/error-helpers.d.ts +37 -0
  182. package/dist/utils/error-helpers.d.ts.map +1 -0
  183. package/dist/utils/error-helpers.js +47 -0
  184. package/dist/utils/error-helpers.js.map +1 -0
  185. package/dist/utils/logger.d.ts.map +1 -1
  186. package/dist/utils/logger.js +6 -3
  187. package/dist/utils/logger.js.map +1 -1
  188. package/dist/utils/security-utils.d.ts +0 -21
  189. package/dist/utils/security-utils.d.ts.map +1 -1
  190. package/dist/utils/security-utils.js +0 -47
  191. package/dist/utils/security-utils.js.map +1 -1
  192. package/dist/vector/VectorSearchManager.d.ts.map +1 -1
  193. package/dist/vector/VectorSearchManager.js +9 -32
  194. package/dist/vector/VectorSearchManager.js.map +1 -1
  195. package/docker-compose.yml +11 -2
  196. package/hooks/README.md +107 -0
  197. package/hooks/cursor/hooks.json +10 -0
  198. package/hooks/cursor/memory-journal.mdc +22 -0
  199. package/hooks/cursor/session-end.sh +19 -0
  200. package/hooks/kilo-code/session-end-mode.json +11 -0
  201. package/hooks/kiro/session-end.md +13 -0
  202. package/mcp-config-example.json +1 -0
  203. package/package.json +11 -9
  204. package/playwright.config.ts +29 -0
  205. package/releases/v4.5.0.md +116 -0
  206. package/releases/v5.0.0.md +105 -0
  207. package/scripts/generate-server-instructions.ts +176 -0
  208. package/scripts/server-instructions-function-body.ts +77 -0
  209. package/server.json +3 -3
  210. package/src/cli.ts +45 -1
  211. package/src/constants/ServerInstructions.ts +133 -73
  212. package/src/constants/icons.ts +8 -7
  213. package/src/constants/server-instructions.md +268 -0
  214. package/src/database/SqliteAdapter.ts +358 -192
  215. package/src/database/schema.ts +125 -0
  216. package/src/filtering/ToolFilter.ts +13 -2
  217. package/src/github/GitHubIntegration.ts +1 -3
  218. package/src/handlers/prompts/github.ts +209 -0
  219. package/src/handlers/prompts/index.ts +10 -499
  220. package/src/handlers/prompts/workflow.ts +314 -0
  221. package/src/handlers/resources/core.ts +528 -0
  222. package/src/handlers/resources/github.ts +358 -0
  223. package/src/handlers/resources/graph.ts +254 -0
  224. package/src/handlers/resources/index.ts +23 -1570
  225. package/src/handlers/resources/shared.ts +103 -0
  226. package/src/handlers/resources/team.ts +133 -0
  227. package/src/handlers/resources/templates.ts +374 -0
  228. package/src/handlers/tools/admin.ts +285 -0
  229. package/src/handlers/tools/analytics.ts +301 -0
  230. package/src/handlers/tools/backup.ts +242 -0
  231. package/src/handlers/tools/core.ts +350 -0
  232. package/src/handlers/tools/export.ts +115 -0
  233. package/src/handlers/tools/github/helpers.ts +86 -0
  234. package/src/handlers/tools/github/insights-tools.ts +119 -0
  235. package/src/handlers/tools/github/issue-tools.ts +439 -0
  236. package/src/handlers/tools/github/kanban-tools.ts +134 -0
  237. package/src/handlers/tools/github/milestone-tools.ts +392 -0
  238. package/src/handlers/tools/github/mutation-tools.ts +17 -0
  239. package/src/handlers/tools/github/read-tools.ts +328 -0
  240. package/src/handlers/tools/github/schemas.ts +369 -0
  241. package/src/handlers/tools/github.ts +36 -0
  242. package/src/handlers/tools/index.ts +144 -3325
  243. package/src/handlers/tools/relationships.ts +358 -0
  244. package/src/handlers/tools/schemas.ts +132 -0
  245. package/src/handlers/tools/search.ts +343 -0
  246. package/src/handlers/tools/team.ts +273 -0
  247. package/src/server/McpServer.ts +63 -358
  248. package/src/server/Scheduler.ts +278 -0
  249. package/src/transports/http.ts +635 -0
  250. package/src/types/entities.ts +145 -0
  251. package/src/types/filtering.ts +54 -0
  252. package/src/types/github.ts +180 -0
  253. package/src/types/index.ts +67 -375
  254. package/src/utils/error-helpers.ts +52 -0
  255. package/src/utils/logger.ts +6 -3
  256. package/src/utils/security-utils.ts +0 -52
  257. package/src/vector/VectorSearchManager.ts +9 -33
  258. package/tests/constants/icons.test.ts +1 -2
  259. package/tests/constants/server-instructions.test.ts +30 -4
  260. package/tests/database/sqlite-adapter.test.ts +91 -7
  261. package/tests/e2e/auth.spec.ts +154 -0
  262. package/tests/e2e/health.spec.ts +63 -0
  263. package/tests/e2e/protocols.spec.ts +134 -0
  264. package/tests/e2e/resources.spec.ts +103 -0
  265. package/tests/e2e/scheduler.spec.ts +79 -0
  266. package/tests/e2e/security.spec.ts +91 -0
  267. package/tests/e2e/sessions.spec.ts +95 -0
  268. package/tests/e2e/stateless.spec.ts +121 -0
  269. package/tests/e2e/tools.spec.ts +111 -0
  270. package/tests/filtering/tool-filter.test.ts +46 -0
  271. package/tests/handlers/error-path-coverage.test.ts +324 -0
  272. package/tests/handlers/github-resource-handlers.test.ts +453 -0
  273. package/tests/handlers/github-tool-handlers.test.ts +899 -0
  274. package/tests/handlers/prompt-handler-coverage.test.ts +106 -0
  275. package/tests/handlers/prompt-handlers.test.ts +40 -0
  276. package/tests/handlers/resource-handler-coverage.test.ts +181 -0
  277. package/tests/handlers/resource-handlers.test.ts +33 -9
  278. package/tests/handlers/search-tool-handlers.test.ts +272 -0
  279. package/tests/handlers/targeted-gap-closure.test.ts +387 -0
  280. package/tests/handlers/team-resource-handlers.test.ts +156 -0
  281. package/tests/handlers/team-tool-handlers.test.ts +301 -0
  282. package/tests/handlers/tool-handler-coverage.test.ts +469 -0
  283. package/tests/handlers/tool-handlers.test.ts +2 -2
  284. package/tests/security/sql-injection.test.ts +3 -54
  285. package/tests/server/mcp-server.test.ts +503 -8
  286. package/tests/server/scheduler.test.ts +400 -0
  287. package/tests/transports/http-transport.test.ts +620 -0
  288. package/tests/vector/vector-search-manager.test.ts +60 -0
  289. package/vitest.config.ts +4 -1
  290. package/.memory-journal-team.db +0 -0
  291. package/.vscode/settings.json +0 -84
@@ -0,0 +1,519 @@
1
+ /* eslint-disable @typescript-eslint/no-deprecated -- Intentional: SSEServerTransport provides backward compatibility for MCP 2024-11-05 clients */
2
+ /**
3
+ * Memory Journal MCP Server - HTTP Transport
4
+ *
5
+ * Dual-protocol HTTP transport:
6
+ * - `/mcp` — Streamable HTTP transport (MCP 2025-03-26)
7
+ * - `/sse` + `/messages` — Legacy SSE transport (MCP 2024-11-05)
8
+ *
9
+ * Modes:
10
+ * - Stateful (default): Multi-session management with SSE streaming
11
+ * - Stateless (opt-in): Lightweight serverless-compatible mode
12
+ *
13
+ * Security: headers, CORS, rate limiting, body size enforcement.
14
+ */
15
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
16
+ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
17
+ import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
18
+ import { randomUUID, timingSafeEqual } from 'node:crypto';
19
+ import express from 'express';
20
+ import rateLimit from 'express-rate-limit';
21
+ import { logger } from '../utils/logger.js';
22
+ import pkg from '../../package.json' with { type: 'json' };
23
+ /** Session timeout for stateful HTTP mode (30 minutes) */
24
+ const SESSION_TIMEOUT_MS = 30 * 60 * 1000;
25
+ /** Session timeout sweep interval (5 minutes) */
26
+ const SESSION_SWEEP_INTERVAL_MS = 5 * 60 * 1000;
27
+ /**
28
+ * HTTP Transport for Memory Journal MCP Server
29
+ *
30
+ * Supports two transport protocols simultaneously:
31
+ * 1. Streamable HTTP (MCP 2025-03-26) via `/mcp` — preferred for modern clients
32
+ * 2. Legacy SSE (MCP 2024-11-05) via `/sse` + `/messages` — backward compatibility
33
+ */
34
+ export class HttpTransport {
35
+ app;
36
+ config;
37
+ transports = new Map();
38
+ sseTransports = new Map();
39
+ sessionLastActivity = new Map();
40
+ httpServer = null;
41
+ sessionSweepTimer = null;
42
+ constructor(config) {
43
+ this.config = config;
44
+ this.app = express();
45
+ }
46
+ /**
47
+ * Initialize and start the HTTP transport
48
+ */
49
+ async start(server, scheduler) {
50
+ const { port, host, corsOrigin, authToken } = this.config;
51
+ if (corsOrigin === '*') {
52
+ logger.warning('CORS origin is set to "*" (all origins). ' +
53
+ 'Set --cors-origin or MCP_CORS_ORIGIN for production deployments.', { module: 'HTTP' });
54
+ }
55
+ if (!authToken) {
56
+ logger.warning('No authentication configured for HTTP transport. ' +
57
+ 'Set --auth-token or MCP_AUTH_TOKEN for production deployments.', { module: 'HTTP' });
58
+ }
59
+ // Security headers middleware
60
+ this.app.use((req, res, next) => {
61
+ res.setHeader('X-Content-Type-Options', 'nosniff');
62
+ res.setHeader('X-Frame-Options', 'DENY');
63
+ res.setHeader('Content-Security-Policy', "default-src 'none'; frame-ancestors 'none'");
64
+ res.setHeader('Cache-Control', 'no-store');
65
+ res.setHeader('Referrer-Policy', 'no-referrer');
66
+ res.setHeader('Permissions-Policy', 'camera=(), microphone=(), geolocation=()');
67
+ // HSTS — only emit when behind a TLS-terminating reverse proxy
68
+ if (req.headers?.['x-forwarded-proto'] === 'https') {
69
+ res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
70
+ }
71
+ next();
72
+ });
73
+ // CORS middleware
74
+ this.app.use((req, res, next) => {
75
+ res.setHeader('Access-Control-Allow-Origin', corsOrigin);
76
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
77
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, mcp-session-id, Last-Event-ID, mcp-protocol-version');
78
+ res.setHeader('Access-Control-Expose-Headers', 'mcp-session-id');
79
+ if (req.method === 'OPTIONS') {
80
+ res.status(204).end();
81
+ return;
82
+ }
83
+ next();
84
+ });
85
+ // JSON body parser with size limit (DoS prevention)
86
+ this.app.use(express.json({ limit: '1mb' }));
87
+ // Rate limiting (100 requests/minute per IP)
88
+ const limiter = rateLimit({
89
+ windowMs: 60 * 1000,
90
+ limit: 100,
91
+ standardHeaders: 'draft-8',
92
+ legacyHeaders: false,
93
+ message: { error: 'Too many requests, please try again later' },
94
+ });
95
+ this.app.use(limiter);
96
+ logger.info('Rate limiting enabled: 100 requests/minute per IP', {
97
+ module: 'HTTP',
98
+ });
99
+ // Bearer token authentication (when configured)
100
+ if (authToken) {
101
+ this.app.use((req, res, next) => {
102
+ if (req.path === '/health') {
103
+ next();
104
+ return;
105
+ }
106
+ const header = req.headers.authorization;
107
+ const expected = Buffer.from(`Bearer ${authToken}`);
108
+ const received = Buffer.from(header ?? '');
109
+ if (expected.length !== received.length || !timingSafeEqual(expected, received)) {
110
+ res.status(401).json({ error: 'Unauthorized' });
111
+ return;
112
+ }
113
+ next();
114
+ });
115
+ logger.info('Bearer token authentication enabled', { module: 'HTTP' });
116
+ }
117
+ // Health check endpoint (before /mcp routes)
118
+ this.app.get('/health', (_req, res) => {
119
+ res.status(200).json({
120
+ status: 'healthy',
121
+ timestamp: new Date().toISOString(),
122
+ });
123
+ });
124
+ // Root info endpoint
125
+ this.app.get('/', (_req, res) => {
126
+ res.status(200).json({
127
+ name: 'memory-journal-mcp',
128
+ version: pkg.version,
129
+ description: 'Project context management for AI-assisted development',
130
+ endpoints: {
131
+ 'POST /mcp': 'JSON-RPC requests (Streamable HTTP, MCP 2025-03-26)',
132
+ 'GET /mcp': 'SSE stream for server-to-client notifications',
133
+ 'DELETE /mcp': 'Session termination',
134
+ 'GET /sse': 'Legacy SSE connection (MCP 2024-11-05)',
135
+ 'POST /messages': 'Legacy SSE message endpoint',
136
+ 'GET /health': 'Health check',
137
+ },
138
+ documentation: 'https://github.com/neverinfamous/memory-journal-mcp',
139
+ });
140
+ });
141
+ // OPTIONS handler for /mcp — MUST be before other /mcp routes
142
+ this.app.all('/mcp', (req, res, next) => {
143
+ if (req.method === 'OPTIONS') {
144
+ res.status(204).end();
145
+ return;
146
+ }
147
+ next();
148
+ });
149
+ if (this.config.stateless) {
150
+ await this.setupStateless(server);
151
+ }
152
+ else {
153
+ this.setupStateful(server);
154
+ this.setupLegacySSE(server);
155
+ }
156
+ // 404 handler — must be after all routes
157
+ this.app.use((_req, res) => {
158
+ res.status(404).json({ error: 'Not found' });
159
+ });
160
+ // Start HTTP server
161
+ this.httpServer = this.app.listen(port, host, () => {
162
+ logger.info(`MCP server started on HTTP (${this.config.stateless ? 'stateless' : 'stateful'})`, {
163
+ module: 'HTTP',
164
+ port,
165
+ host,
166
+ endpoint: `http://${host}:${port}/mcp`,
167
+ });
168
+ });
169
+ // Start scheduler after HTTP server is listening
170
+ scheduler?.start();
171
+ this.httpServer.on('close', () => {
172
+ logger.info('HTTP server closed', { module: 'HTTP' });
173
+ });
174
+ }
175
+ /**
176
+ * Graceful shutdown
177
+ */
178
+ async stop(scheduler) {
179
+ logger.info('Shutting down HTTP server...', { module: 'HTTP' });
180
+ scheduler?.stop();
181
+ // Close all Streamable HTTP transports
182
+ for (const [sessionId, transport] of this.transports) {
183
+ try {
184
+ logger.debug('Closing Streamable HTTP transport', {
185
+ module: 'HTTP',
186
+ sessionId,
187
+ });
188
+ await transport.close();
189
+ }
190
+ catch (error) {
191
+ logger.error('Error closing transport', {
192
+ module: 'HTTP',
193
+ sessionId,
194
+ error: error instanceof Error ? error.message : String(error),
195
+ });
196
+ }
197
+ }
198
+ this.transports.clear();
199
+ // Close all Legacy SSE transports
200
+ for (const [sessionId, transport] of this.sseTransports) {
201
+ try {
202
+ logger.debug('Closing Legacy SSE transport', {
203
+ module: 'HTTP',
204
+ sessionId,
205
+ });
206
+ await transport.close();
207
+ }
208
+ catch (error) {
209
+ logger.error('Error closing SSE transport', {
210
+ module: 'HTTP',
211
+ sessionId,
212
+ error: error instanceof Error ? error.message : String(error),
213
+ });
214
+ }
215
+ }
216
+ this.sseTransports.clear();
217
+ this.sessionLastActivity.clear();
218
+ if (this.sessionSweepTimer !== null) {
219
+ clearInterval(this.sessionSweepTimer);
220
+ }
221
+ if (this.httpServer !== null) {
222
+ this.httpServer.close();
223
+ }
224
+ logger.info('Shutdown complete', { module: 'HTTP' });
225
+ }
226
+ // =========================================================================
227
+ // Stateless Mode
228
+ // =========================================================================
229
+ /**
230
+ * Setup stateless transport (single transport, no session management)
231
+ */
232
+ async setupStateless(server) {
233
+ const statelessTransport = new StreamableHTTPServerTransport({
234
+ sessionIdGenerator: undefined,
235
+ enableJsonResponse: true,
236
+ });
237
+ await server.connect(statelessTransport);
238
+ logger.info('Stateless transport connected', { module: 'HTTP' });
239
+ // POST /mcp — all requests go to the same transport
240
+ this.app.post('/mcp', (req, res) => {
241
+ void statelessTransport.handleRequest(req, res, req.body);
242
+ });
243
+ // GET /mcp — SSE not available in stateless mode
244
+ this.app.get('/mcp', (_req, res) => {
245
+ res.status(405).json({
246
+ jsonrpc: '2.0',
247
+ error: {
248
+ code: -32000,
249
+ message: 'SSE streaming not available in stateless mode',
250
+ },
251
+ id: null,
252
+ });
253
+ });
254
+ // DELETE /mcp — no-op in stateless mode
255
+ this.app.delete('/mcp', (_req, res) => {
256
+ res.status(204).end();
257
+ });
258
+ }
259
+ // =========================================================================
260
+ // Stateful Mode
261
+ // =========================================================================
262
+ /** Update the last-activity timestamp for a session */
263
+ touchSession(sid) {
264
+ this.sessionLastActivity.set(sid, Date.now());
265
+ }
266
+ /**
267
+ * Setup stateful transport (multi-session, SSE streaming)
268
+ */
269
+ setupStateful(server) {
270
+ // Start session timeout sweep (runs every 5 minutes)
271
+ this.sessionSweepTimer = setInterval(() => {
272
+ const now = Date.now();
273
+ for (const [sid, lastActivity] of this.sessionLastActivity) {
274
+ const idleMs = now - lastActivity;
275
+ if (idleMs <= SESSION_TIMEOUT_MS)
276
+ continue;
277
+ // Expire idle Streamable HTTP sessions
278
+ if (this.transports.has(sid)) {
279
+ logger.info('Expiring idle HTTP session', {
280
+ module: 'HTTP',
281
+ sessionId: sid,
282
+ idleMinutes: Math.round(idleMs / 60_000),
283
+ });
284
+ const t = this.transports.get(sid);
285
+ if (t) {
286
+ void t.close();
287
+ }
288
+ this.transports.delete(sid);
289
+ this.sessionLastActivity.delete(sid);
290
+ }
291
+ // Expire idle Legacy SSE sessions
292
+ if (this.sseTransports.has(sid)) {
293
+ logger.info('Expiring idle SSE session', {
294
+ module: 'HTTP',
295
+ sessionId: sid,
296
+ idleMinutes: Math.round(idleMs / 60_000),
297
+ });
298
+ const t = this.sseTransports.get(sid);
299
+ if (t) {
300
+ void t.close();
301
+ }
302
+ this.sseTransports.delete(sid);
303
+ this.sessionLastActivity.delete(sid);
304
+ }
305
+ }
306
+ }, SESSION_SWEEP_INTERVAL_MS);
307
+ // POST /mcp — Handle JSON-RPC requests
308
+ this.app.post('/mcp', (req, res) => {
309
+ const sessionId = req.headers['mcp-session-id'];
310
+ void (async () => {
311
+ try {
312
+ let httpTransport;
313
+ if (sessionId !== undefined && this.transports.has(sessionId)) {
314
+ // Cross-protocol guard: reject SSE session IDs on /mcp
315
+ if (this.sseTransports.has(sessionId)) {
316
+ res.status(400).json({
317
+ jsonrpc: '2.0',
318
+ error: {
319
+ code: -32000,
320
+ message: 'Bad Request: Session uses Legacy SSE transport, not Streamable HTTP',
321
+ },
322
+ id: null,
323
+ });
324
+ return;
325
+ }
326
+ // Reuse existing transport and refresh session activity
327
+ this.touchSession(sessionId);
328
+ httpTransport = this.transports.get(sessionId);
329
+ }
330
+ else if (sessionId === undefined && isInitializeRequest(req.body)) {
331
+ // New initialization request — create transport
332
+ const newTransport = new StreamableHTTPServerTransport({
333
+ sessionIdGenerator: () => randomUUID(),
334
+ onsessioninitialized: (sid) => {
335
+ logger.info('HTTP session initialized', {
336
+ module: 'HTTP',
337
+ sessionId: sid,
338
+ });
339
+ this.transports.set(sid, newTransport);
340
+ this.touchSession(sid);
341
+ },
342
+ });
343
+ // Clean up on transport close
344
+ newTransport.onclose = () => {
345
+ const sid = newTransport.sessionId;
346
+ if (sid !== undefined && this.transports.has(sid)) {
347
+ logger.info('HTTP transport closed', {
348
+ module: 'HTTP',
349
+ sessionId: sid,
350
+ });
351
+ this.transports.delete(sid);
352
+ this.sessionLastActivity.delete(sid);
353
+ }
354
+ };
355
+ // Connect transport to server
356
+ // SDK McpServer only supports one active transport — close first
357
+ try {
358
+ await server.connect(newTransport);
359
+ }
360
+ catch {
361
+ await server.close();
362
+ await server.connect(newTransport);
363
+ }
364
+ await newTransport.handleRequest(req, res, req.body);
365
+ return;
366
+ }
367
+ else {
368
+ // Invalid request — no session ID or not initialization
369
+ res.status(400).json({
370
+ jsonrpc: '2.0',
371
+ error: {
372
+ code: -32000,
373
+ message: 'Bad Request: No valid session ID provided',
374
+ },
375
+ id: null,
376
+ });
377
+ return;
378
+ }
379
+ // Handle request with existing transport
380
+ if (httpTransport !== undefined) {
381
+ await httpTransport.handleRequest(req, res, req.body);
382
+ }
383
+ }
384
+ catch (error) {
385
+ logger.error('Error handling MCP request', {
386
+ module: 'HTTP',
387
+ error: error instanceof Error ? error.message : String(error),
388
+ });
389
+ if (!res.headersSent) {
390
+ res.status(500).json({
391
+ jsonrpc: '2.0',
392
+ error: { code: -32603, message: 'Internal server error' },
393
+ id: null,
394
+ });
395
+ }
396
+ }
397
+ })();
398
+ });
399
+ // GET /mcp — SSE stream for server-to-client notifications
400
+ this.app.get('/mcp', (req, res) => {
401
+ const sessionId = req.headers['mcp-session-id'];
402
+ if (sessionId === undefined || !this.transports.has(sessionId)) {
403
+ res.status(400).send('Invalid or missing session ID');
404
+ return;
405
+ }
406
+ // Refresh session activity on SSE reconnect
407
+ this.touchSession(sessionId);
408
+ const lastEventId = req.headers['last-event-id'];
409
+ if (lastEventId !== undefined) {
410
+ logger.debug('Client reconnecting with Last-Event-ID', {
411
+ module: 'HTTP',
412
+ sessionId,
413
+ lastEventId,
414
+ });
415
+ }
416
+ const httpTransport = this.transports.get(sessionId);
417
+ if (httpTransport !== undefined) {
418
+ void httpTransport.handleRequest(req, res);
419
+ }
420
+ });
421
+ // DELETE /mcp — Session termination
422
+ this.app.delete('/mcp', (req, res) => {
423
+ const sessionId = req.headers['mcp-session-id'];
424
+ if (sessionId === undefined || !this.transports.has(sessionId)) {
425
+ res.status(400).send('Invalid or missing session ID');
426
+ return;
427
+ }
428
+ logger.info('Session termination requested', {
429
+ module: 'HTTP',
430
+ sessionId,
431
+ });
432
+ const httpTransport = this.transports.get(sessionId);
433
+ if (httpTransport !== undefined) {
434
+ void httpTransport.handleRequest(req, res);
435
+ }
436
+ });
437
+ }
438
+ // =========================================================================
439
+ // Legacy SSE (MCP 2024-11-05)
440
+ // =========================================================================
441
+ /**
442
+ * Setup Legacy SSE endpoints for backward compatibility.
443
+ * Stateful mode only.
444
+ */
445
+ setupLegacySSE(server) {
446
+ // GET /sse — Open Legacy SSE connection
447
+ this.app.get('/sse', (req, res) => {
448
+ logger.info('Legacy SSE connection requested', { module: 'HTTP' });
449
+ const sseTransport = new SSEServerTransport('/messages', res);
450
+ // Store transport by session ID after start
451
+ sseTransport.onclose = () => {
452
+ logger.info('Legacy SSE transport closed', {
453
+ module: 'HTTP',
454
+ sessionId: sseTransport.sessionId,
455
+ });
456
+ this.sseTransports.delete(sseTransport.sessionId);
457
+ };
458
+ void (async () => {
459
+ try {
460
+ // Connect SSE transport to server
461
+ // SDK McpServer only supports one active transport — close first
462
+ try {
463
+ await server.connect(sseTransport);
464
+ }
465
+ catch {
466
+ await server.close();
467
+ await server.connect(sseTransport);
468
+ }
469
+ // Note: server.connect() auto-calls start() on SSEServerTransport
470
+ this.sseTransports.set(sseTransport.sessionId, sseTransport);
471
+ this.touchSession(sseTransport.sessionId);
472
+ logger.info('Legacy SSE connection established', {
473
+ module: 'HTTP',
474
+ sessionId: sseTransport.sessionId,
475
+ });
476
+ }
477
+ catch (error) {
478
+ logger.error('Error starting SSE transport', {
479
+ module: 'HTTP',
480
+ error: error instanceof Error ? error.message : String(error),
481
+ });
482
+ if (!res.headersSent) {
483
+ res.status(500).end();
484
+ }
485
+ }
486
+ })();
487
+ // Clean up when client disconnects
488
+ req.on('close', () => {
489
+ this.sseTransports.delete(sseTransport.sessionId);
490
+ this.sessionLastActivity.delete(sseTransport.sessionId);
491
+ });
492
+ });
493
+ // POST /messages?sessionId=<id> — Route messages to Legacy SSE transport
494
+ this.app.post('/messages', (req, res) => {
495
+ const sessionId = typeof req.query['sessionId'] === 'string' ? req.query['sessionId'] : undefined;
496
+ if (sessionId === undefined) {
497
+ res.status(400).json({
498
+ jsonrpc: '2.0',
499
+ error: { code: -32000, message: 'Missing sessionId parameter' },
500
+ id: null,
501
+ });
502
+ return;
503
+ }
504
+ const transport = this.sseTransports.get(sessionId);
505
+ if (transport === undefined) {
506
+ res.status(404).json({
507
+ jsonrpc: '2.0',
508
+ error: { code: -32000, message: 'Session not found' },
509
+ id: null,
510
+ });
511
+ return;
512
+ }
513
+ // Refresh session activity on message receipt
514
+ this.touchSession(sessionId);
515
+ void transport.handlePostMessage(req, res, req.body);
516
+ });
517
+ }
518
+ }
519
+ //# source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AI,CAAC;oBACjB,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE;oBACrD,EAAE,EAAE,IAAI;iBACX,CAAC,CAAA;gBACF,OAAM;YACV,CAAC;YAED,8CAA8C;YAC9C,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;YAE5B,KAAK,SAAS,CAAC,iBAAiB,CAC5B,GAAiC,EACjC,GAAgC,EAChC,GAAG,CAAC,IAAe,CACtB,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Memory Journal MCP Server - Database Entity Types
3
+ */
4
+ /**
5
+ * Entry types for journal entries
6
+ */
7
+ export type EntryType = 'personal_reflection' | 'project_decision' | 'technical_achievement' | 'bug_fix' | 'feature_implementation' | 'code_review' | 'meeting_notes' | 'learning' | 'research' | 'planning' | 'retrospective' | 'standup' | 'technical_note' | 'development_note' | 'enhancement' | 'milestone' | 'system_integration_test' | 'test_entry' | 'other';
8
+ /**
9
+ * Significance types for important entries
10
+ */
11
+ export type SignificanceType = 'milestone' | 'breakthrough' | 'technical_breakthrough' | 'decision' | 'lesson_learned' | 'blocker_resolved' | 'release' | null;
12
+ /**
13
+ * Relationship types between entries
14
+ *
15
+ * Standard types:
16
+ * - evolves_from: Entry builds upon previous work
17
+ * - references: Entry mentions or links to another
18
+ * - implements: Entry implements a spec/design
19
+ * - clarifies: Entry explains or clarifies another
20
+ * - response_to: Entry responds to a question/issue
21
+ *
22
+ * Causal types (for decision tracing):
23
+ * - blocked_by: Entry was blocked by another (e.g., blocker → resolution)
24
+ * - resolved: Entry resolved/fixed an issue from another
25
+ * - caused: Entry caused or led to another outcome
26
+ */
27
+ export type RelationshipType = 'evolves_from' | 'references' | 'implements' | 'clarifies' | 'response_to' | 'blocked_by' | 'resolved' | 'caused';
28
+ /**
29
+ * Journal entry entity
30
+ */
31
+ export interface JournalEntry {
32
+ id: number;
33
+ entryType: EntryType;
34
+ content: string;
35
+ timestamp: string;
36
+ isPersonal: boolean;
37
+ significanceType: SignificanceType;
38
+ autoContext: string | null;
39
+ deletedAt: string | null;
40
+ tags: string[];
41
+ projectNumber?: number | null;
42
+ projectOwner?: string | null;
43
+ issueNumber?: number | null;
44
+ issueUrl?: string | null;
45
+ prNumber?: number | null;
46
+ prUrl?: string | null;
47
+ prStatus?: string | null;
48
+ workflowRunId?: number | null;
49
+ workflowName?: string | null;
50
+ workflowStatus?: string | null;
51
+ }
52
+ /**
53
+ * Tag entity
54
+ */
55
+ export interface Tag {
56
+ id: number;
57
+ name: string;
58
+ usageCount: number;
59
+ }
60
+ /**
61
+ * Relationship entity
62
+ */
63
+ export interface Relationship {
64
+ id: number;
65
+ fromEntryId: number;
66
+ toEntryId: number;
67
+ relationshipType: RelationshipType;
68
+ description: string | null;
69
+ createdAt: string;
70
+ }
71
+ /**
72
+ * Embedding entity for vector search
73
+ */
74
+ export interface Embedding {
75
+ entryId: number;
76
+ embedding: Float32Array;
77
+ modelName: string;
78
+ }
79
+ /**
80
+ * Importance scoring breakdown showing weighted component contributions
81
+ */
82
+ export interface ImportanceBreakdown {
83
+ /** Significance type contribution (weight: 0.30) */
84
+ significance: number;
85
+ /** Relationship count contribution (weight: 0.35) */
86
+ relationships: number;
87
+ /** Causal relationship contribution (weight: 0.20) */
88
+ causal: number;
89
+ /** Recency decay contribution (weight: 0.15) */
90
+ recency: number;
91
+ }
92
+ /**
93
+ * Importance calculation result with total score and component breakdown
94
+ */
95
+ export interface ImportanceResult {
96
+ /** Total importance score (0.0-1.0) */
97
+ score: number;
98
+ /** Weighted component contributions */
99
+ breakdown: ImportanceBreakdown;
100
+ }
101
+ //# sourceMappingURL=entities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/types/entities.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,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xB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,GAAG;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,YAAY,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAA;IACpB,qDAAqD;IACrD,aAAa,EAAE,MAAM,CAAA;IACrB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,uCAAuC;IACvC,SAAS,EAAE,mBAAmB,CAAA;CACjC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Memory Journal MCP Server - Database Entity Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/types/entities.ts"],"names":[],"mappings":"AAAA;;GAEG"}