@crypto512/jicon-mcp 2.2.1 → 2.3.19
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/PROMPT.md +10 -28
- package/README.md +39 -6
- package/TOOL_LIST.md +542 -407
- package/dist/config/constants.d.ts +28 -0
- package/dist/config/constants.d.ts.map +1 -1
- package/dist/config/constants.js +34 -0
- package/dist/config/constants.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +12 -2
- package/dist/config/loader.js.map +1 -1
- package/dist/config/types.d.ts +49 -6
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +18 -0
- package/dist/config/types.js.map +1 -1
- package/dist/confluence/client.d.ts.map +1 -1
- package/dist/confluence/client.js +7 -2
- package/dist/confluence/client.js.map +1 -1
- package/dist/confluence/formatters.d.ts +20 -0
- package/dist/confluence/formatters.d.ts.map +1 -1
- package/dist/confluence/formatters.js +74 -8
- package/dist/confluence/formatters.js.map +1 -1
- package/dist/confluence/tools.d.ts +16 -20
- package/dist/confluence/tools.d.ts.map +1 -1
- package/dist/confluence/tools.js +71 -68
- package/dist/confluence/tools.js.map +1 -1
- package/dist/credentials/extractor.d.ts +15 -5
- package/dist/credentials/extractor.d.ts.map +1 -1
- package/dist/credentials/extractor.js +99 -12
- package/dist/credentials/extractor.js.map +1 -1
- package/dist/credentials/index.d.ts +4 -3
- package/dist/credentials/index.d.ts.map +1 -1
- package/dist/credentials/index.js +3 -2
- package/dist/credentials/index.js.map +1 -1
- package/dist/credentials/types.d.ts +22 -0
- package/dist/credentials/types.d.ts.map +1 -1
- package/dist/credentials/types.js.map +1 -1
- package/dist/index.js +211 -176
- package/dist/index.js.map +1 -1
- package/dist/jira/activity-tools.d.ts +8 -15
- package/dist/jira/activity-tools.d.ts.map +1 -1
- package/dist/jira/activity-tools.js +131 -90
- package/dist/jira/activity-tools.js.map +1 -1
- package/dist/jira/client.d.ts +24 -0
- package/dist/jira/client.d.ts.map +1 -1
- package/dist/jira/client.js +65 -6
- package/dist/jira/client.js.map +1 -1
- package/dist/jira/formatters.d.ts +61 -0
- package/dist/jira/formatters.d.ts.map +1 -1
- package/dist/jira/formatters.js +83 -11
- package/dist/jira/formatters.js.map +1 -1
- package/dist/jira/tools.d.ts +78 -26
- package/dist/jira/tools.d.ts.map +1 -1
- package/dist/jira/tools.js +293 -130
- package/dist/jira/tools.js.map +1 -1
- package/dist/permissions/filter.d.ts.map +1 -1
- package/dist/permissions/filter.js +8 -4
- package/dist/permissions/filter.js.map +1 -1
- package/dist/permissions/tool-registry.d.ts +15 -13
- package/dist/permissions/tool-registry.d.ts.map +1 -1
- package/dist/permissions/tool-registry.js +19 -10
- package/dist/permissions/tool-registry.js.map +1 -1
- package/dist/session/context.d.ts +81 -0
- package/dist/session/context.d.ts.map +1 -0
- package/dist/session/context.js +107 -0
- package/dist/session/context.js.map +1 -0
- package/dist/session/index.d.ts +12 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +22 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +186 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +383 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/tempo/client.d.ts +14 -0
- package/dist/tempo/client.d.ts.map +1 -1
- package/dist/tempo/client.js +57 -0
- package/dist/tempo/client.js.map +1 -1
- package/dist/tempo/formatters.d.ts +13 -0
- package/dist/tempo/formatters.d.ts.map +1 -1
- package/dist/tempo/formatters.js +106 -20
- package/dist/tempo/formatters.js.map +1 -1
- package/dist/tempo/tools.d.ts +14 -13
- package/dist/tempo/tools.d.ts.map +1 -1
- package/dist/tempo/tools.js +203 -33
- package/dist/tempo/tools.js.map +1 -1
- package/dist/tempo/types.d.ts +20 -6
- package/dist/tempo/types.d.ts.map +1 -1
- package/dist/transport/http.d.ts +21 -5
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/http.js +193 -22
- package/dist/transport/http.js.map +1 -1
- package/dist/transport/index.d.ts +7 -2
- package/dist/transport/index.d.ts.map +1 -1
- package/dist/transport/index.js +10 -4
- package/dist/transport/index.js.map +1 -1
- package/dist/utils/buffer-tools.d.ts +48 -724
- package/dist/utils/buffer-tools.d.ts.map +1 -1
- package/dist/utils/buffer-tools.js +337 -170
- package/dist/utils/buffer-tools.js.map +1 -1
- package/dist/utils/content-buffer.d.ts +10 -31
- package/dist/utils/content-buffer.d.ts.map +1 -1
- package/dist/utils/content-buffer.js +12 -86
- package/dist/utils/content-buffer.js.map +1 -1
- package/dist/utils/http-client.d.ts.map +1 -1
- package/dist/utils/http-client.js +99 -2
- package/dist/utils/http-client.js.map +1 -1
- package/dist/utils/jicon-help.d.ts +3 -3
- package/dist/utils/jicon-help.d.ts.map +1 -1
- package/dist/utils/jicon-help.js +164 -312
- package/dist/utils/jicon-help.js.map +1 -1
- package/dist/utils/logger.d.ts +43 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +102 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/plantuml/tools.d.ts.map +1 -1
- package/dist/utils/plantuml/tools.js +10 -9
- package/dist/utils/plantuml/tools.js.map +1 -1
- package/dist/utils/response-formatter.d.ts +20 -2
- package/dist/utils/response-formatter.d.ts.map +1 -1
- package/dist/utils/response-formatter.js +147 -17
- package/dist/utils/response-formatter.js.map +1 -1
- package/dist/utils/sandbox/formatters.d.ts +25 -0
- package/dist/utils/sandbox/formatters.d.ts.map +1 -0
- package/dist/utils/sandbox/formatters.js +690 -0
- package/dist/utils/sandbox/formatters.js.map +1 -0
- package/dist/utils/sandbox/helpers.d.ts +16 -0
- package/dist/utils/sandbox/helpers.d.ts.map +1 -0
- package/dist/utils/sandbox/helpers.js +252 -0
- package/dist/utils/sandbox/helpers.js.map +1 -0
- package/dist/utils/sandbox/index.d.ts +19 -0
- package/dist/utils/sandbox/index.d.ts.map +1 -0
- package/dist/utils/sandbox/index.js +269 -0
- package/dist/utils/sandbox/index.js.map +1 -0
- package/dist/utils/sandbox/schema.d.ts +55 -0
- package/dist/utils/sandbox/schema.d.ts.map +1 -0
- package/dist/utils/sandbox/schema.js +39 -0
- package/dist/utils/sandbox/schema.js.map +1 -0
- package/dist/utils/sandbox/types.d.ts +179 -0
- package/dist/utils/sandbox/types.d.ts.map +1 -0
- package/dist/utils/sandbox/types.js +8 -0
- package/dist/utils/sandbox/types.js.map +1 -0
- package/dist/utils/schemas/confluence.d.ts +41 -0
- package/dist/utils/schemas/confluence.d.ts.map +1 -0
- package/dist/utils/schemas/confluence.js +105 -0
- package/dist/utils/schemas/confluence.js.map +1 -0
- package/dist/utils/schemas/index.d.ts +77 -0
- package/dist/utils/schemas/index.d.ts.map +1 -0
- package/dist/utils/schemas/index.js +107 -0
- package/dist/utils/schemas/index.js.map +1 -0
- package/dist/utils/schemas/jira.d.ts +49 -0
- package/dist/utils/schemas/jira.d.ts.map +1 -0
- package/dist/utils/schemas/jira.js +153 -0
- package/dist/utils/schemas/jira.js.map +1 -0
- package/dist/utils/schemas/tempo.d.ts +29 -0
- package/dist/utils/schemas/tempo.d.ts.map +1 -0
- package/dist/utils/schemas/tempo.js +72 -0
- package/dist/utils/schemas/tempo.js.map +1 -0
- package/dist/utils/whoami-tools.d.ts +17 -0
- package/dist/utils/whoami-tools.d.ts.map +1 -0
- package/dist/utils/whoami-tools.js +90 -0
- package/dist/utils/whoami-tools.js.map +1 -0
- package/dist/utils/xhtml/error-locator.js +5 -5
- package/dist/utils/xhtml/error-locator.js.map +1 -1
- package/package.json +10 -9
- package/dist/credentials/client-factory.d.ts +0 -64
- package/dist/credentials/client-factory.d.ts.map +0 -1
- package/dist/credentials/client-factory.js +0 -110
- package/dist/credentials/client-factory.js.map +0 -1
- package/dist/credentials/context.d.ts +0 -25
- package/dist/credentials/context.d.ts.map +0 -1
- package/dist/credentials/context.js +0 -35
- package/dist/credentials/context.js.map +0 -1
- package/dist/utils/buffer-pipeline/index.d.ts +0 -30
- package/dist/utils/buffer-pipeline/index.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/index.js +0 -317
- package/dist/utils/buffer-pipeline/index.js.map +0 -1
- package/dist/utils/buffer-pipeline/output/csv.d.ts +0 -20
- package/dist/utils/buffer-pipeline/output/csv.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/output/csv.js +0 -117
- package/dist/utils/buffer-pipeline/output/csv.js.map +0 -1
- package/dist/utils/buffer-pipeline/output/json.d.ts +0 -16
- package/dist/utils/buffer-pipeline/output/json.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/output/json.js +0 -48
- package/dist/utils/buffer-pipeline/output/json.js.map +0 -1
- package/dist/utils/buffer-pipeline/output/markdown.d.ts +0 -15
- package/dist/utils/buffer-pipeline/output/markdown.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/output/markdown.js +0 -105
- package/dist/utils/buffer-pipeline/output/markdown.js.map +0 -1
- package/dist/utils/buffer-pipeline/output/xhtml-list.d.ts +0 -16
- package/dist/utils/buffer-pipeline/output/xhtml-list.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/output/xhtml-list.js +0 -81
- package/dist/utils/buffer-pipeline/output/xhtml-list.js.map +0 -1
- package/dist/utils/buffer-pipeline/output/xhtml-table.d.ts +0 -15
- package/dist/utils/buffer-pipeline/output/xhtml-table.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/output/xhtml-table.js +0 -176
- package/dist/utils/buffer-pipeline/output/xhtml-table.js.map +0 -1
- package/dist/utils/buffer-pipeline/schema.d.ts +0 -1878
- package/dist/utils/buffer-pipeline/schema.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/schema.js +0 -168
- package/dist/utils/buffer-pipeline/schema.js.map +0 -1
- package/dist/utils/buffer-pipeline/stages/filter.d.ts +0 -32
- package/dist/utils/buffer-pipeline/stages/filter.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/stages/filter.js +0 -208
- package/dist/utils/buffer-pipeline/stages/filter.js.map +0 -1
- package/dist/utils/buffer-pipeline/stages/format.d.ts +0 -45
- package/dist/utils/buffer-pipeline/stages/format.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/stages/format.js +0 -160
- package/dist/utils/buffer-pipeline/stages/format.js.map +0 -1
- package/dist/utils/buffer-pipeline/stages/group-by.d.ts +0 -25
- package/dist/utils/buffer-pipeline/stages/group-by.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/stages/group-by.js +0 -190
- package/dist/utils/buffer-pipeline/stages/group-by.js.map +0 -1
- package/dist/utils/buffer-pipeline/stages/select.d.ts +0 -54
- package/dist/utils/buffer-pipeline/stages/select.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/stages/select.js +0 -228
- package/dist/utils/buffer-pipeline/stages/select.js.map +0 -1
- package/dist/utils/buffer-pipeline/stages/sort.d.ts +0 -20
- package/dist/utils/buffer-pipeline/stages/sort.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/stages/sort.js +0 -96
- package/dist/utils/buffer-pipeline/stages/sort.js.map +0 -1
- package/dist/utils/buffer-pipeline/types.d.ts +0 -277
- package/dist/utils/buffer-pipeline/types.d.ts.map +0 -1
- package/dist/utils/buffer-pipeline/types.js +0 -8
- package/dist/utils/buffer-pipeline/types.js.map +0 -1
- package/dist/utils/plantuml/docker-manager.d.ts +0 -37
- package/dist/utils/plantuml/docker-manager.d.ts.map +0 -1
- package/dist/utils/plantuml/docker-manager.js +0 -284
- package/dist/utils/plantuml/docker-manager.js.map +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Context for per-request state access
|
|
3
|
+
*
|
|
4
|
+
* Uses AsyncLocalStorage to provide access to session-scoped resources
|
|
5
|
+
* (buffers, clients, credentials) within tool handlers without passing
|
|
6
|
+
* them explicitly through function parameters.
|
|
7
|
+
*/
|
|
8
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
/**
|
|
10
|
+
* AsyncLocalStorage instance for session context
|
|
11
|
+
*/
|
|
12
|
+
const sessionStorage = new AsyncLocalStorage();
|
|
13
|
+
/**
|
|
14
|
+
* Run a function with session context in scope
|
|
15
|
+
*
|
|
16
|
+
* @param context - Session context to make available
|
|
17
|
+
* @param fn - Function to run with context
|
|
18
|
+
*/
|
|
19
|
+
export function runWithSession(context, fn) {
|
|
20
|
+
return sessionStorage.run(context, fn);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the current session context
|
|
24
|
+
* Returns undefined if not running within a session
|
|
25
|
+
*/
|
|
26
|
+
export function getSessionContext() {
|
|
27
|
+
return sessionStorage.getStore();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if we're running within a session context
|
|
31
|
+
*/
|
|
32
|
+
export function hasSessionContext() {
|
|
33
|
+
return sessionStorage.getStore() !== undefined;
|
|
34
|
+
}
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Buffer Access
|
|
37
|
+
// ============================================================================
|
|
38
|
+
/**
|
|
39
|
+
* Get the ContentBuffer for the current session
|
|
40
|
+
* Throws if not running within a session context
|
|
41
|
+
*/
|
|
42
|
+
export function getSessionBuffer() {
|
|
43
|
+
const ctx = sessionStorage.getStore();
|
|
44
|
+
if (!ctx) {
|
|
45
|
+
throw new Error("No session context - buffer operations require an active session. " +
|
|
46
|
+
"Ensure the request is wrapped with runWithSession().");
|
|
47
|
+
}
|
|
48
|
+
return ctx.buffer;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Try to get the session buffer, returning undefined if no session
|
|
52
|
+
*/
|
|
53
|
+
export function tryGetSessionBuffer() {
|
|
54
|
+
return sessionStorage.getStore()?.buffer;
|
|
55
|
+
}
|
|
56
|
+
// ============================================================================
|
|
57
|
+
// Client Access
|
|
58
|
+
// ============================================================================
|
|
59
|
+
/**
|
|
60
|
+
* Get the Jira client for the current session
|
|
61
|
+
* Returns null if Jira is not configured for this session
|
|
62
|
+
*/
|
|
63
|
+
export function getSessionJiraClient() {
|
|
64
|
+
return sessionStorage.getStore()?.jiraClient ?? null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the Confluence client for the current session
|
|
68
|
+
* Returns null if Confluence is not configured for this session
|
|
69
|
+
*/
|
|
70
|
+
export function getSessionConfluenceClient() {
|
|
71
|
+
return sessionStorage.getStore()?.confluenceClient ?? null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the Tempo client for the current session
|
|
75
|
+
* Returns null if Tempo is not configured for this session
|
|
76
|
+
*/
|
|
77
|
+
export function getSessionTempoClient() {
|
|
78
|
+
return sessionStorage.getStore()?.tempoClient ?? null;
|
|
79
|
+
}
|
|
80
|
+
// ============================================================================
|
|
81
|
+
// Write-Home Validator Access
|
|
82
|
+
// ============================================================================
|
|
83
|
+
/**
|
|
84
|
+
* Get the WriteHomeValidator for the current session
|
|
85
|
+
* Returns null if write-home is not enabled or Confluence is not configured
|
|
86
|
+
*/
|
|
87
|
+
export function getSessionWriteHomeValidator() {
|
|
88
|
+
return sessionStorage.getStore()?.writeHomeValidator ?? null;
|
|
89
|
+
}
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// Credentials Access
|
|
92
|
+
// ============================================================================
|
|
93
|
+
/**
|
|
94
|
+
* Get credentials from the current session context
|
|
95
|
+
* Returns empty object if no session context
|
|
96
|
+
*/
|
|
97
|
+
export function getSessionCredentials() {
|
|
98
|
+
return sessionStorage.getStore()?.credentials ?? {};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the session ID for the current context
|
|
102
|
+
* Returns undefined if no session context
|
|
103
|
+
*/
|
|
104
|
+
export function getSessionId() {
|
|
105
|
+
return sessionStorage.getStore()?.sessionId;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/session/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBA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I,CAAC;AACxD,CAAC;AAED,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,4BAA4B;IAC1C,OAAO,cAAc,CAAC,QAAQ,EAAE,EAAE,kBAAkB,IAAI,IAAI,CAAC;AAC/D,CAAC;AAED,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,cAAc,CAAC,QAAQ,EAAE,EAAE,WAAW,IAAI,EAAE,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,cAAc,CAAC,QAAQ,EAAE,EAAE,SAAS,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session management module
|
|
3
|
+
*
|
|
4
|
+
* Provides session-scoped state for MCP requests:
|
|
5
|
+
* - Per-session content buffers (isolated from other sessions)
|
|
6
|
+
* - Per-session API clients with their caches
|
|
7
|
+
* - Per-session WriteHomeValidator
|
|
8
|
+
* - Automatic session cleanup after timeout
|
|
9
|
+
*/
|
|
10
|
+
export { SessionManager, initializeSessionManager, getSessionManager, shutdownSessionManager, type SessionData, type SessionClients, type SessionManagerConfig, } from "./manager.js";
|
|
11
|
+
export { runWithSession, getSessionContext, hasSessionContext, type SessionContext, getSessionBuffer, tryGetSessionBuffer, getSessionJiraClient, getSessionConfluenceClient, getSessionTempoClient, getSessionWriteHomeValidator, getSessionCredentials, getSessionId, } from "./context.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,cAAc,EAEnB,gBAAgB,EAChB,mBAAmB,EAEnB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EAErB,4BAA4B,EAE5B,qBAAqB,EACrB,YAAY,GACb,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session management module
|
|
3
|
+
*
|
|
4
|
+
* Provides session-scoped state for MCP requests:
|
|
5
|
+
* - Per-session content buffers (isolated from other sessions)
|
|
6
|
+
* - Per-session API clients with their caches
|
|
7
|
+
* - Per-session WriteHomeValidator
|
|
8
|
+
* - Automatic session cleanup after timeout
|
|
9
|
+
*/
|
|
10
|
+
// Session manager
|
|
11
|
+
export { SessionManager, initializeSessionManager, getSessionManager, shutdownSessionManager, } from "./manager.js";
|
|
12
|
+
// Session context (AsyncLocalStorage)
|
|
13
|
+
export { runWithSession, getSessionContext, hasSessionContext,
|
|
14
|
+
// Buffer access
|
|
15
|
+
getSessionBuffer, tryGetSessionBuffer,
|
|
16
|
+
// Client access
|
|
17
|
+
getSessionJiraClient, getSessionConfluenceClient, getSessionTempoClient,
|
|
18
|
+
// Write-home validator access
|
|
19
|
+
getSessionWriteHomeValidator,
|
|
20
|
+
// Credentials access
|
|
21
|
+
getSessionCredentials, getSessionId, } from "./context.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kBAAkB;AAClB,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,GAIvB,MAAM,cAAc,CAAC;AAEtB,sCAAsC;AACtC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB;AAEjB,gBAAgB;AAChB,gBAAgB,EAChB,mBAAmB;AACnB,gBAAgB;AAChB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB;AACrB,8BAA8B;AAC9B,4BAA4B;AAC5B,qBAAqB;AACrB,qBAAqB,EACrB,YAAY,GACb,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Manager for MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Manages session lifecycle with per-session:
|
|
5
|
+
* - Content buffers (isolated from other sessions)
|
|
6
|
+
* - API clients (with their caches)
|
|
7
|
+
* - Write-home validators
|
|
8
|
+
*
|
|
9
|
+
* Sessions are created on first request with credentials and automatically
|
|
10
|
+
* cleaned up after 1 hour of inactivity.
|
|
11
|
+
*/
|
|
12
|
+
import { ContentBuffer } from "../utils/content-buffer.js";
|
|
13
|
+
import type { PartialRequestCredentials } from "../credentials/types.js";
|
|
14
|
+
import { JiraClient } from "../jira/client.js";
|
|
15
|
+
import { ConfluenceClient } from "../confluence/client.js";
|
|
16
|
+
import { TempoClient } from "../tempo/client.js";
|
|
17
|
+
import { WriteHomeValidator } from "../permissions/write-home-validator.js";
|
|
18
|
+
import type { ApiConfig } from "../types.js";
|
|
19
|
+
/**
|
|
20
|
+
* Per-session API clients with their caches
|
|
21
|
+
*/
|
|
22
|
+
export interface SessionClients {
|
|
23
|
+
jira: JiraClient | null;
|
|
24
|
+
confluence: ConfluenceClient | null;
|
|
25
|
+
tempo: TempoClient | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Session data stored by the manager
|
|
29
|
+
*/
|
|
30
|
+
export interface SessionData {
|
|
31
|
+
sessionId: string;
|
|
32
|
+
credentials: PartialRequestCredentials;
|
|
33
|
+
buffer: ContentBuffer;
|
|
34
|
+
clients: SessionClients;
|
|
35
|
+
writeHomeValidator: WriteHomeValidator | null;
|
|
36
|
+
createdAt: number;
|
|
37
|
+
lastActivity: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for the session manager
|
|
41
|
+
*/
|
|
42
|
+
export interface SessionManagerConfig {
|
|
43
|
+
/** Default Jira configuration (from environment) */
|
|
44
|
+
defaultJiraConfig: ApiConfig | null;
|
|
45
|
+
/** Default Confluence configuration (from environment) */
|
|
46
|
+
defaultConfluenceConfig: ApiConfig | null;
|
|
47
|
+
/** Whether write-home restriction is enabled */
|
|
48
|
+
writeHomeEnabled: boolean;
|
|
49
|
+
/** Maximum buffers per session (default: 10) */
|
|
50
|
+
maxBuffersPerSession?: number;
|
|
51
|
+
/** Maximum concurrent sessions (default: 1000, DoS protection) */
|
|
52
|
+
maxSessions?: number;
|
|
53
|
+
/** Session timeout in milliseconds (default: 15 minutes) */
|
|
54
|
+
sessionTimeoutMs?: number;
|
|
55
|
+
/** Callback when a session is destroyed (for transport cleanup coordination) */
|
|
56
|
+
onSessionDestroyed?: (sessionId: string) => void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Session Manager
|
|
60
|
+
*
|
|
61
|
+
* Manages per-session state including:
|
|
62
|
+
* - ContentBuffer instances (isolated per session)
|
|
63
|
+
* - API clients with their caches
|
|
64
|
+
* - WriteHomeValidator instances
|
|
65
|
+
*
|
|
66
|
+
* Sessions are cleaned up after a configurable timeout of inactivity (default: 1 hour).
|
|
67
|
+
* The timeout is reset on actual tool calls.
|
|
68
|
+
*/
|
|
69
|
+
export declare class SessionManager {
|
|
70
|
+
private sessions;
|
|
71
|
+
private config;
|
|
72
|
+
private maxSessions;
|
|
73
|
+
private sessionTimeoutMs;
|
|
74
|
+
private cleanupInterval;
|
|
75
|
+
private onSessionDestroyed?;
|
|
76
|
+
constructor(config: SessionManagerConfig);
|
|
77
|
+
/**
|
|
78
|
+
* Start the session cleanup interval
|
|
79
|
+
* Checks every minute for sessions that have exceeded the timeout
|
|
80
|
+
*/
|
|
81
|
+
private startCleanupInterval;
|
|
82
|
+
/**
|
|
83
|
+
* Clean up sessions that have exceeded the inactivity timeout
|
|
84
|
+
*/
|
|
85
|
+
private cleanupTimedOutSessions;
|
|
86
|
+
/**
|
|
87
|
+
* Create a new session with the given credentials
|
|
88
|
+
* @throws Error if maximum sessions limit reached (DoS protection)
|
|
89
|
+
*/
|
|
90
|
+
createSession(sessionId: string, credentials: PartialRequestCredentials): SessionData;
|
|
91
|
+
/**
|
|
92
|
+
* Get an existing session by ID
|
|
93
|
+
* Updates the lastActivity timestamp on access
|
|
94
|
+
*/
|
|
95
|
+
getSession(sessionId: string): SessionData | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Get or create a session
|
|
98
|
+
* If session exists, returns it (and updates lastActivity)
|
|
99
|
+
* If session doesn't exist, creates it with the given credentials
|
|
100
|
+
*
|
|
101
|
+
* If existing session has different credentials than the request,
|
|
102
|
+
* recreates the affected clients to use the new credentials.
|
|
103
|
+
* This ensures per-request credential isolation in multi-user scenarios.
|
|
104
|
+
*/
|
|
105
|
+
getOrCreateSession(sessionId: string, credentials: PartialRequestCredentials): SessionData;
|
|
106
|
+
/**
|
|
107
|
+
* Update session clients in-place when credentials change
|
|
108
|
+
* This preserves the session and its transport connection while updating API clients
|
|
109
|
+
*
|
|
110
|
+
* @param session - The existing session to update
|
|
111
|
+
* @param credentials - New credentials from the request
|
|
112
|
+
* @param options - Flags indicating which credentials changed
|
|
113
|
+
*/
|
|
114
|
+
private updateSessionClients;
|
|
115
|
+
/**
|
|
116
|
+
* Destroy a session and clean up its resources
|
|
117
|
+
* Also triggers onSessionDestroyed callback for transport cleanup
|
|
118
|
+
*/
|
|
119
|
+
destroySession(sessionId: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Get the number of active sessions
|
|
122
|
+
*/
|
|
123
|
+
getSessionCount(): number;
|
|
124
|
+
/**
|
|
125
|
+
* Get the maximum sessions limit
|
|
126
|
+
*/
|
|
127
|
+
getMaxSessions(): number;
|
|
128
|
+
/**
|
|
129
|
+
* Check if a session exists without updating its activity timestamp
|
|
130
|
+
*/
|
|
131
|
+
hasSession(sessionId: string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Update session activity timestamp without returning full session data
|
|
134
|
+
* Used to extend session lifetime when real activity occurs (tool calls)
|
|
135
|
+
*
|
|
136
|
+
* @returns true if session was found, false otherwise
|
|
137
|
+
*/
|
|
138
|
+
touchSession(sessionId: string): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Set the callback for when a session is destroyed
|
|
141
|
+
* Used by HTTP transport for coordinated transport cleanup
|
|
142
|
+
*/
|
|
143
|
+
setSessionDestroyedCallback(callback: (sessionId: string) => void): void;
|
|
144
|
+
/**
|
|
145
|
+
* Shutdown the session manager
|
|
146
|
+
* Destroys all sessions and stops the cleanup interval
|
|
147
|
+
*/
|
|
148
|
+
shutdown(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Get the session timeout in milliseconds
|
|
151
|
+
*/
|
|
152
|
+
getSessionTimeoutMs(): number;
|
|
153
|
+
/**
|
|
154
|
+
* Resolve Jira configuration by merging partial per-request credentials with defaults
|
|
155
|
+
*
|
|
156
|
+
* Priority: per-request > environment defaults
|
|
157
|
+
* - URL from header OR URL from env
|
|
158
|
+
* - Token from header OR token from env
|
|
159
|
+
* - Both must be present for a valid config
|
|
160
|
+
*/
|
|
161
|
+
private resolveJiraConfig;
|
|
162
|
+
/**
|
|
163
|
+
* Resolve Confluence configuration by merging partial per-request credentials with defaults
|
|
164
|
+
*
|
|
165
|
+
* Priority: per-request > environment defaults
|
|
166
|
+
* - URL from header OR URL from env
|
|
167
|
+
* - Token from header OR token from env
|
|
168
|
+
* - Both must be present for a valid config
|
|
169
|
+
*/
|
|
170
|
+
private resolveConfluenceConfig;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Initialize the session manager singleton
|
|
174
|
+
* Must be called once during server startup
|
|
175
|
+
*/
|
|
176
|
+
export declare function initializeSessionManager(config: SessionManagerConfig): SessionManager;
|
|
177
|
+
/**
|
|
178
|
+
* Get the session manager singleton
|
|
179
|
+
* Throws if not initialized
|
|
180
|
+
*/
|
|
181
|
+
export declare function getSessionManager(): SessionManager;
|
|
182
|
+
/**
|
|
183
|
+
* Shutdown the session manager singleton
|
|
184
|
+
*/
|
|
185
|
+
export declare function shutdownSessionManager(): void;
|
|
186
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/session/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,yBAAyB,CAAC;IACvC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,iBAAiB,EAAE,SAAS,GAAG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