@itm-platform/mcp-server 1.0.2 → 1.0.3

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 (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -7
  3. package/dist/src/auth/api-key-auth.d.ts +3 -0
  4. package/dist/src/auth/api-key-auth.d.ts.map +1 -0
  5. package/dist/src/auth/api-key-auth.js +53 -0
  6. package/dist/src/auth/api-key-auth.js.map +1 -0
  7. package/dist/src/auth/effective-user-context.d.ts +16 -0
  8. package/dist/src/auth/effective-user-context.d.ts.map +1 -0
  9. package/dist/src/auth/effective-user-context.js +9 -0
  10. package/dist/src/auth/effective-user-context.js.map +1 -0
  11. package/dist/src/auth/license-resolver.d.ts +6 -0
  12. package/dist/src/auth/license-resolver.d.ts.map +1 -0
  13. package/dist/src/auth/license-resolver.js +12 -0
  14. package/dist/src/auth/license-resolver.js.map +1 -0
  15. package/dist/src/auth/oauth-auth.d.ts +22 -0
  16. package/dist/src/auth/oauth-auth.d.ts.map +1 -0
  17. package/dist/src/auth/oauth-auth.js +34 -0
  18. package/dist/src/auth/oauth-auth.js.map +1 -0
  19. package/dist/src/auth/oauth-metadata.d.ts +10 -0
  20. package/dist/src/auth/oauth-metadata.d.ts.map +1 -0
  21. package/dist/src/auth/oauth-metadata.js +8 -0
  22. package/dist/src/auth/oauth-metadata.js.map +1 -0
  23. package/dist/src/auth/token-extraction.d.ts +2 -0
  24. package/dist/src/auth/token-extraction.d.ts.map +1 -0
  25. package/dist/src/auth/token-extraction.js +7 -0
  26. package/dist/src/auth/token-extraction.js.map +1 -0
  27. package/dist/src/clients/audit-client.d.ts +25 -0
  28. package/dist/src/clients/audit-client.d.ts.map +1 -0
  29. package/dist/src/clients/audit-client.js +37 -0
  30. package/dist/src/clients/audit-client.js.map +1 -0
  31. package/dist/src/clients/datamart-client.d.ts +16 -0
  32. package/dist/src/clients/datamart-client.d.ts.map +1 -0
  33. package/dist/src/clients/datamart-client.js +32 -0
  34. package/dist/src/clients/datamart-client.js.map +1 -0
  35. package/dist/src/clients/index.d.ts +18 -0
  36. package/dist/src/clients/index.d.ts.map +1 -0
  37. package/dist/src/clients/index.js +11 -0
  38. package/dist/src/clients/index.js.map +1 -0
  39. package/dist/src/clients/rest-client.d.ts +14 -0
  40. package/dist/src/clients/rest-client.d.ts.map +1 -0
  41. package/dist/src/clients/rest-client.js +29 -0
  42. package/dist/src/clients/rest-client.js.map +1 -0
  43. package/dist/src/logger.d.ts +3 -0
  44. package/dist/src/logger.d.ts.map +1 -0
  45. package/dist/src/logger.js +37 -0
  46. package/dist/src/logger.js.map +1 -0
  47. package/dist/src/prompts/portfolio-overview.d.ts +3 -0
  48. package/dist/src/prompts/portfolio-overview.d.ts.map +1 -0
  49. package/dist/src/prompts/portfolio-overview.js +21 -0
  50. package/dist/src/prompts/portfolio-overview.js.map +1 -0
  51. package/dist/src/prompts/project-status.d.ts +3 -0
  52. package/dist/src/prompts/project-status.d.ts.map +1 -0
  53. package/dist/src/prompts/project-status.js +24 -0
  54. package/dist/src/prompts/project-status.js.map +1 -0
  55. package/dist/src/prompts/risk-analysis.d.ts +3 -0
  56. package/dist/src/prompts/risk-analysis.d.ts.map +1 -0
  57. package/dist/src/prompts/risk-analysis.js +23 -0
  58. package/dist/src/prompts/risk-analysis.js.map +1 -0
  59. package/dist/src/prompts/team-workload.d.ts +3 -0
  60. package/dist/src/prompts/team-workload.d.ts.map +1 -0
  61. package/dist/src/prompts/team-workload.js +29 -0
  62. package/dist/src/prompts/team-workload.js.map +1 -0
  63. package/dist/src/resources/calendars.d.ts +4 -0
  64. package/dist/src/resources/calendars.d.ts.map +1 -0
  65. package/dist/src/resources/calendars.js +18 -0
  66. package/dist/src/resources/calendars.js.map +1 -0
  67. package/dist/src/resources/schemas.d.ts +4 -0
  68. package/dist/src/resources/schemas.d.ts.map +1 -0
  69. package/dist/src/resources/schemas.js +34 -0
  70. package/dist/src/resources/schemas.js.map +1 -0
  71. package/dist/src/server.d.ts +2 -0
  72. package/dist/src/server.d.ts.map +1 -0
  73. package/dist/src/server.js +213 -0
  74. package/dist/src/server.js.map +1 -0
  75. package/dist/src/tools/datamart.d.ts +17 -0
  76. package/dist/src/tools/datamart.d.ts.map +1 -0
  77. package/dist/src/tools/datamart.js +68 -0
  78. package/dist/src/tools/datamart.js.map +1 -0
  79. package/dist/src/tools/financials.d.ts +4 -0
  80. package/dist/src/tools/financials.d.ts.map +1 -0
  81. package/dist/src/tools/financials.js +50 -0
  82. package/dist/src/tools/financials.js.map +1 -0
  83. package/dist/src/tools/graphql-queries.d.ts +22 -0
  84. package/dist/src/tools/graphql-queries.d.ts.map +1 -0
  85. package/dist/src/tools/graphql-queries.js +26 -0
  86. package/dist/src/tools/graphql-queries.js.map +1 -0
  87. package/dist/src/tools/portfolio.d.ts +10 -0
  88. package/dist/src/tools/portfolio.d.ts.map +1 -0
  89. package/dist/src/tools/portfolio.js +54 -0
  90. package/dist/src/tools/portfolio.js.map +1 -0
  91. package/dist/src/tools/projects.d.ts +42 -0
  92. package/dist/src/tools/projects.d.ts.map +1 -0
  93. package/dist/src/tools/projects.js +73 -0
  94. package/dist/src/tools/projects.js.map +1 -0
  95. package/dist/src/tools/reference-data.d.ts +4 -0
  96. package/dist/src/tools/reference-data.d.ts.map +1 -0
  97. package/dist/src/tools/reference-data.js +19 -0
  98. package/dist/src/tools/reference-data.js.map +1 -0
  99. package/dist/src/tools/risks-issues.d.ts +4 -0
  100. package/dist/src/tools/risks-issues.d.ts.map +1 -0
  101. package/dist/src/tools/risks-issues.js +33 -0
  102. package/dist/src/tools/risks-issues.js.map +1 -0
  103. package/dist/src/tools/services.d.ts +41 -0
  104. package/dist/src/tools/services.d.ts.map +1 -0
  105. package/dist/src/tools/services.js +67 -0
  106. package/dist/src/tools/services.js.map +1 -0
  107. package/dist/src/tools/tasks.d.ts +4 -0
  108. package/dist/src/tools/tasks.d.ts.map +1 -0
  109. package/dist/src/tools/tasks.js +17 -0
  110. package/dist/src/tools/tasks.js.map +1 -0
  111. package/dist/src/tools/users.d.ts +4 -0
  112. package/dist/src/tools/users.d.ts.map +1 -0
  113. package/dist/src/tools/users.js +30 -0
  114. package/dist/src/tools/users.js.map +1 -0
  115. package/dist/src/tools/write-tools.d.ts +75 -0
  116. package/dist/src/tools/write-tools.d.ts.map +1 -0
  117. package/dist/src/tools/write-tools.js +193 -0
  118. package/dist/src/tools/write-tools.js.map +1 -0
  119. package/dist/src/validation/query-validator.d.ts +15 -0
  120. package/dist/src/validation/query-validator.d.ts.map +1 -0
  121. package/dist/src/validation/query-validator.js +141 -0
  122. package/dist/src/validation/query-validator.js.map +1 -0
  123. package/package.json +11 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ITM Platform
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -26,6 +26,8 @@ https://api.itmplatform.com/v2/_/mcp/
26
26
 
27
27
  OAuth is the recommended setup for most users because your AI client never sees your ITM Platform password or API key.
28
28
 
29
+ After adding the server, open your AI client, type `/mcp` where slash commands are supported, select `itm-platform`, and complete the ITM Platform OAuth login when prompted.
30
+
29
31
  ### Local connection with an API key
30
32
 
31
33
  Use the npm package if you prefer to run the server locally, work behind a firewall, or need to connect to a self-hosted ITM Platform instance.
@@ -62,17 +64,27 @@ Example stdio configuration:
62
64
 
63
65
  To create an API key, log in to ITM Platform, open **My Profile**, and generate a key from the **API Key** section.
64
66
 
65
- ## What You Can Ask
67
+ After configuring the local server, restart your AI client and use `/mcp` or the client's MCP server list to confirm `itm-platform` is connected.
68
+
69
+ ## What Can an Agent Do?
70
+
71
+ From simple lookups to fully automated cross-system workflows, MCP unlocks progressively more powerful use cases.
72
+
73
+ **Quick lookup** -- Ask a question, get an answer:
66
74
 
67
- Once connected, your AI assistant can use ITM Platform data in normal conversation:
75
+ > "What risks are open across my portfolio?"
68
76
 
69
- > "Which projects are behind schedule?"
77
+ **Multi-step analysis** -- The agent chains multiple tools and synthesizes results:
70
78
 
71
- > "Give me a budget summary for the Digital Transformation program."
79
+ > "Review every project ending this quarter. Flag any with budget overruns, open high-impact risks, or task completion below 60%."
72
80
 
73
- > "Create a high-priority task in Project Alpha due next Friday."
81
+ **Automated bulk actions** -- The agent reads, decides, and writes across projects:
74
82
 
75
- > "What open risks exist across my portfolio?"
83
+ > "For every project still in Planning status with a start date in the past, update the status to Execution and create a kick-off checklist task assigned to the project manager."
84
+
85
+ **Scheduled intelligence** -- An agent runs on a schedule with no human prompt, pulling overdue tasks every Monday and posting a summary to Slack grouped by project manager.
86
+
87
+ **Cross-system orchestration** -- Combine ITM Platform's MCP with other MCP servers (GitHub, Slack, Google Calendar, email). When a developer merges a PR, an agent finds the matching ITM Platform task, marks it complete, and if the project hits 100%, drafts a closure summary and emails the program manager.
76
88
 
77
89
  The MCP server authenticates as you, calls ITM Platform APIs, and returns only the data your ITM Platform account is allowed to access.
78
90
 
@@ -168,6 +180,8 @@ For any MCP-compatible client, the two connection values are:
168
180
  | Remote URL | `https://api.itmplatform.com/v2/_/mcp/` |
169
181
  | Local command | `npx @itm-platform/mcp-server` |
170
182
 
183
+ After adding either connection, open the client's MCP command or server list. In clients that support slash commands, type `/mcp`, select `itm-platform`, and authenticate when prompted.
184
+
171
185
  ## Self-Hosting
172
186
 
173
187
  For a local stdio server, configure `ITM_API_URL`, `ITM_COMPANY`, and either `ITM_API_KEY` or `ITM_TOKEN`.
@@ -221,5 +235,5 @@ If a write succeeds but a later search shows old data, wait up to 60 seconds. Wr
221
235
  ## More Help
222
236
 
223
237
  - MCP docs: [modelcontextprotocol.io](https://modelcontextprotocol.io)
224
- - ITM Platform help: [help.itmplatform.com](https://help.itmplatform.com)
238
+ - ITM Platform help: [helpcenter.itmplatform.com](https://helpcenter.itmplatform.com)
225
239
  - ITM Platform developer docs: [developers.itmplatform.com/documentation](https://developers.itmplatform.com/documentation)
@@ -0,0 +1,3 @@
1
+ import { EffectiveUserContext } from './effective-user-context.js';
2
+ export declare function resolveIdentity(): Promise<EffectiveUserContext>;
3
+ //# sourceMappingURL=api-key-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key-auth.d.ts","sourceRoot":"","sources":["../../../src/auth/api-key-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AA0BnE,wBAAsB,eAAe,IAAI,OAAO,CAAC,oBAAoB,CAAC,CA6CrE"}
@@ -0,0 +1,53 @@
1
+ import { resolveLicenseAccess } from './license-resolver.js';
2
+ function resolveAuthHeaders() {
3
+ const apiKey = process.env.ITM_API_KEY;
4
+ const token = process.env.ITM_TOKEN;
5
+ if (apiKey) {
6
+ return { source: 'api-key', headers: { 'Authorization': `Bearer ${apiKey}` } };
7
+ }
8
+ if (token) {
9
+ return { source: 'token', headers: { 'Token': token } };
10
+ }
11
+ throw new Error('Missing required environment variable: ITM_API_KEY or ITM_TOKEN');
12
+ }
13
+ export async function resolveIdentity() {
14
+ const apiUrl = process.env.ITM_API_URL;
15
+ const company = process.env.ITM_COMPANY;
16
+ if (!apiUrl)
17
+ throw new Error('Missing required environment variable: ITM_API_URL');
18
+ if (!company)
19
+ throw new Error('Missing required environment variable: ITM_COMPANY');
20
+ const { source, headers: authHeaders } = resolveAuthHeaders();
21
+ const url = `${apiUrl}/v2/${company}/resolve/identity`;
22
+ const response = await fetch(url, {
23
+ method: 'POST',
24
+ headers: {
25
+ ...authHeaders,
26
+ 'Content-Type': 'application/json',
27
+ },
28
+ });
29
+ if (!response.ok) {
30
+ throw new Error(`Identity resolution failed: ${response.status} ${response.statusText}`);
31
+ }
32
+ const identity = await response.json();
33
+ const { dataMartAccess, pmScopeUserId } = resolveLicenseAccess(identity.licenseTypeIds, identity.userId);
34
+ if (dataMartAccess === 'pm-scoped') {
35
+ throw new Error('PM-only access is not yet available for MCP. It will arrive with hosted MCP (Phase 2) or gateway scope injection.');
36
+ }
37
+ if (dataMartAccess === 'none') {
38
+ throw new Error('Team Member access is not available for MCP.');
39
+ }
40
+ return {
41
+ source,
42
+ company,
43
+ accountId: identity.accountId,
44
+ userId: identity.userId,
45
+ languageId: identity.languageId,
46
+ email: identity.email,
47
+ licenseTypeIds: identity.licenseTypeIds,
48
+ dataMartAccess,
49
+ pmScopeUserId,
50
+ authHeaders,
51
+ };
52
+ }
53
+ //# sourceMappingURL=api-key-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key-auth.js","sourceRoot":"","sources":["../../../src/auth/api-key-auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAY7D,SAAS,kBAAkB;IACzB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAEpC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO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,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEzG,IAAI,cAAc,KAAK,WAAW,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,IAAI,cAAc,KAAK,MAAM,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,MAAM;QACN,OAAO;QACP,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,cAAc;QACd,aAAa;QACb,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface EffectiveUserContext {
2
+ source: 'api-key' | 'token';
3
+ company: string;
4
+ accountId: number;
5
+ userId: number;
6
+ languageId: number;
7
+ email: string;
8
+ licenseTypeIds: number[];
9
+ dataMartAccess: 'full' | 'pm-scoped' | 'none';
10
+ pmScopeUserId?: number;
11
+ authHeaders: Record<string, string>;
12
+ grantedScopes?: string[];
13
+ }
14
+ export declare const WRITE_TOOL_NAMES: Set<string>;
15
+ export declare function hasScope(ctx: EffectiveUserContext, scope: string): boolean;
16
+ //# sourceMappingURL=effective-user-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effective-user-context.d.ts","sourceRoot":"","sources":["../../../src/auth/effective-user-context.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,eAAO,MAAM,gBAAgB,aAE3B,CAAC;AAEH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAG1E"}
@@ -0,0 +1,9 @@
1
+ export const WRITE_TOOL_NAMES = new Set([
2
+ 'create_task', 'update_task', 'create_risk', 'create_issue', 'update_project',
3
+ ]);
4
+ export function hasScope(ctx, scope) {
5
+ if (!ctx.grantedScopes)
6
+ return true;
7
+ return ctx.grantedScopes.includes(scope);
8
+ }
9
+ //# sourceMappingURL=effective-user-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effective-user-context.js","sourceRoot":"","sources":["../../../src/auth/effective-user-context.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IACtC,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB;CAC9E,CAAC,CAAC;AAEH,MAAM,UAAU,QAAQ,CAAC,GAAyB,EAAE,KAAa;IAC/D,IAAI,CAAC,GAAG,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface LicenseAccessResult {
2
+ dataMartAccess: 'full' | 'pm-scoped' | 'none';
3
+ pmScopeUserId?: number;
4
+ }
5
+ export declare function resolveLicenseAccess(licenseTypeIds: number[], userId: number): LicenseAccessResult;
6
+ //# sourceMappingURL=license-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license-resolver.d.ts","sourceRoot":"","sources":["../../../src/auth/license-resolver.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAQlG"}
@@ -0,0 +1,12 @@
1
+ const FULL_ACCESS_TYPES = new Set([0, 1]);
2
+ const PM_TYPE = 2;
3
+ export function resolveLicenseAccess(licenseTypeIds, userId) {
4
+ if (licenseTypeIds.some(id => FULL_ACCESS_TYPES.has(id))) {
5
+ return { dataMartAccess: 'full' };
6
+ }
7
+ if (licenseTypeIds.includes(PM_TYPE)) {
8
+ return { dataMartAccess: 'pm-scoped', pmScopeUserId: userId };
9
+ }
10
+ return { dataMartAccess: 'none' };
11
+ }
12
+ //# sourceMappingURL=license-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license-resolver.js","sourceRoot":"","sources":["../../../src/auth/license-resolver.ts"],"names":[],"mappings":"AAKA,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1C,MAAM,OAAO,GAAG,CAAC,CAAC;AAElB,MAAM,UAAU,oBAAoB,CAAC,cAAwB,EAAE,MAAc;IAC3E,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QACzD,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;IACD,IAAI,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Logger } from 'pino';
2
+ import type { EffectiveUserContext } from './effective-user-context.js';
3
+ export interface TokenExchangeResult {
4
+ sessionToken: string;
5
+ userId: number;
6
+ accountId: number;
7
+ company: string;
8
+ email: string;
9
+ languageId: number;
10
+ licenseTypeIds: number[];
11
+ dataMartAccess: 'full' | 'pm-scoped' | 'none';
12
+ pmScopeUserId?: number;
13
+ expiresAt: string;
14
+ scope: string;
15
+ }
16
+ export interface OAuthConfig {
17
+ tokenExchangeUrl: string;
18
+ audience: string;
19
+ }
20
+ export declare function exchangeToken(oauthToken: string, config: OAuthConfig, log?: Logger): Promise<TokenExchangeResult>;
21
+ export declare function buildEffectiveUserContextFromExchange(result: TokenExchangeResult): EffectiveUserContext;
22
+ //# sourceMappingURL=oauth-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-auth.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,EACnB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,mBAAmB,CAAC,CAoB9B;AAED,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,mBAAmB,GAAG,oBAAoB,CAcvG"}
@@ -0,0 +1,34 @@
1
+ export async function exchangeToken(oauthToken, config, log) {
2
+ log?.debug({ url: config.tokenExchangeUrl }, 'Token exchange request');
3
+ const response = await fetch(config.tokenExchangeUrl, {
4
+ method: 'POST',
5
+ headers: {
6
+ 'Content-Type': 'application/json',
7
+ 'Authorization': `Bearer ${oauthToken}`,
8
+ },
9
+ body: JSON.stringify({ audience: config.audience }),
10
+ });
11
+ if (!response.ok) {
12
+ log?.error({ status: response.status }, 'Token exchange failed');
13
+ throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
14
+ }
15
+ const result = await response.json();
16
+ log?.info({ userId: result.userId, company: result.company }, 'Token exchange succeeded');
17
+ return result;
18
+ }
19
+ export function buildEffectiveUserContextFromExchange(result) {
20
+ return {
21
+ source: 'token',
22
+ company: result.company,
23
+ accountId: result.accountId,
24
+ userId: result.userId,
25
+ languageId: result.languageId,
26
+ email: result.email,
27
+ licenseTypeIds: result.licenseTypeIds,
28
+ dataMartAccess: result.dataMartAccess,
29
+ pmScopeUserId: result.pmScopeUserId,
30
+ grantedScopes: result.scope.split(' ').filter(Boolean),
31
+ authHeaders: { 'Token': result.sessionToken },
32
+ };
33
+ }
34
+ //# sourceMappingURL=oauth-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-auth.js","sourceRoot":"","sources":["../../../src/auth/oauth-auth.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAkB,EAClB,MAAmB,EACnB,GAAY;IAEZ,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QACtD,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface ProtectedResourceMetadata {
2
+ resource: string;
3
+ authorization_servers: string[];
4
+ scopes_supported: string[];
5
+ }
6
+ export declare function buildProtectedResourceMetadata(config: {
7
+ mcpServerUrl: string;
8
+ authorizationServerUrl: string;
9
+ }): ProtectedResourceMetadata;
10
+ //# sourceMappingURL=oauth-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-metadata.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth-metadata.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB,EAAE,MAAM,CAAC;CAChC,GAAG,yBAAyB,CAM5B"}
@@ -0,0 +1,8 @@
1
+ export function buildProtectedResourceMetadata(config) {
2
+ return {
3
+ resource: config.mcpServerUrl,
4
+ authorization_servers: [config.authorizationServerUrl],
5
+ scopes_supported: ['mcp:read', 'mcp:write'],
6
+ };
7
+ }
8
+ //# sourceMappingURL=oauth-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-metadata.js","sourceRoot":"","sources":["../../../src/auth/oauth-metadata.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,8BAA8B,CAAC,MAG9C;IACC,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,YAAY;QAC7B,qBAAqB,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC;QACtD,gBAAgB,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;KAC5C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function extractBearerToken(headers: Record<string, string | undefined>): string | undefined;
2
+ //# sourceMappingURL=token-extraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-extraction.d.ts","sourceRoot":"","sources":["../../../src/auth/token-extraction.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAIlG"}
@@ -0,0 +1,7 @@
1
+ export function extractBearerToken(headers) {
2
+ const auth = headers.authorization;
3
+ if (auth?.startsWith('Bearer '))
4
+ return auth.slice(7);
5
+ return undefined;
6
+ }
7
+ //# sourceMappingURL=token-extraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-extraction.js","sourceRoot":"","sources":["../../../src/auth/token-extraction.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,OAA2C;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IACnC,IAAI,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { Logger } from 'pino';
2
+ export interface AuditClientConfig {
3
+ apiUrl: string;
4
+ company: string;
5
+ authHeaders: Record<string, string>;
6
+ log?: Logger;
7
+ }
8
+ export interface AuditEntry {
9
+ timestamp: string;
10
+ userId: number;
11
+ accountId: number;
12
+ toolName: string;
13
+ parametersHash: string;
14
+ success: boolean;
15
+ error?: string;
16
+ aiClientId: string;
17
+ durationMs: number;
18
+ }
19
+ export interface AuditClient {
20
+ log(entry: AuditEntry): Promise<void>;
21
+ }
22
+ export declare function hashParameters(params: unknown): string;
23
+ export declare function createAuditClient(config: AuditClientConfig): AuditClient;
24
+ export declare function createNoOpAuditClient(): AuditClient;
25
+ //# sourceMappingURL=audit-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-client.d.ts","sourceRoot":"","sources":["../../../src/clients/audit-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAEtD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CA0BxE;AAED,wBAAgB,qBAAqB,IAAI,WAAW,CAInD"}
@@ -0,0 +1,37 @@
1
+ import { createHash } from 'node:crypto';
2
+ export function hashParameters(params) {
3
+ return createHash('sha256').update(JSON.stringify(params)).digest('hex');
4
+ }
5
+ export function createAuditClient(config) {
6
+ const url = `${config.apiUrl}/v2/${config.company}/mcp/audit`;
7
+ const headers = {
8
+ ...config.authHeaders,
9
+ 'Content-Type': 'application/json',
10
+ };
11
+ const log = config.log;
12
+ return {
13
+ async log(entry) {
14
+ try {
15
+ const response = await fetch(url, {
16
+ method: 'POST',
17
+ headers,
18
+ body: JSON.stringify(entry),
19
+ });
20
+ if (!response.ok) {
21
+ log?.warn({ status: response.status, toolName: entry.toolName }, 'Audit POST failed');
22
+ return;
23
+ }
24
+ log?.debug({ toolName: entry.toolName }, 'Audit entry logged');
25
+ }
26
+ catch (err) {
27
+ log?.warn({ err, toolName: entry.toolName }, 'Audit POST error');
28
+ }
29
+ },
30
+ };
31
+ }
32
+ export function createNoOpAuditClient() {
33
+ return {
34
+ async log() { },
35
+ };
36
+ }
37
+ //# sourceMappingURL=audit-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-client.js","sourceRoot":"","sources":["../../../src/clients/audit-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA0BzC,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAyB;IACzD,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,OAAO,YAAY,CAAC;IAC9D,MAAM,OAAO,GAA2B;QACtC,GAAG,MAAM,CAAC,WAAW;QACrB,cAAc,EAAE,kBAAkB;KACnC,CAAC;IACF,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;IAEvB,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,KAAiB;YACzB,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;oBAChC,MAAM,EAAE,MAAM;oBACd,OAAO;oBACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC5B,CAAC,CAAC;gBACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,mBAAmB,CAAC,CAAC;oBACtF,OAAO;gBACT,CAAC;gBACD,GAAG,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,oBAAoB,CAAC,CAAC;YACjE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,kBAAkB,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,KAAK,CAAC,GAAG,KAAmB,CAAC;KAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Logger } from 'pino';
2
+ export interface DataMartClientConfig {
3
+ apiUrl: string;
4
+ company: string;
5
+ authHeaders: Record<string, string>;
6
+ log?: Logger;
7
+ }
8
+ export interface DataMartQuery {
9
+ query: string;
10
+ variables: Record<string, unknown>;
11
+ }
12
+ export interface DataMartClient {
13
+ query(body: DataMartQuery): Promise<Record<string, unknown>>;
14
+ }
15
+ export declare function createDataMartClient(config: DataMartClientConfig): DataMartClient;
16
+ //# sourceMappingURL=datamart-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datamart-client.d.ts","sourceRoot":"","sources":["../../../src/clients/datamart-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9D;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,CAmCjF"}
@@ -0,0 +1,32 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ export function createDataMartClient(config) {
3
+ const baseUrl = `${config.apiUrl}/v2/${config.company}/datamart/graphql`;
4
+ const log = config.log;
5
+ return {
6
+ async query(body) {
7
+ const requestId = randomUUID();
8
+ const start = Date.now();
9
+ const response = await fetch(baseUrl, {
10
+ method: 'POST',
11
+ headers: {
12
+ ...config.authHeaders,
13
+ 'Content-Type': 'application/json',
14
+ 'X-Request-Id': requestId,
15
+ },
16
+ body: JSON.stringify(body),
17
+ });
18
+ if (!response.ok) {
19
+ log?.error({ requestId, status: response.status, ms: Date.now() - start }, 'DataMart request failed');
20
+ throw new Error(`DataMart request failed: ${response.status} ${response.statusText}`);
21
+ }
22
+ const json = await response.json();
23
+ if (json.errors?.length) {
24
+ log?.error({ requestId, graphqlError: json.errors[0].message, ms: Date.now() - start }, 'DataMart GraphQL error');
25
+ throw new Error(`DataMart GraphQL error: ${json.errors[0].message}`);
26
+ }
27
+ log?.debug({ requestId, ms: Date.now() - start }, 'DataMart request OK');
28
+ return json.data ?? {};
29
+ },
30
+ };
31
+ }
32
+ //# sourceMappingURL=datamart-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datamart-client.js","sourceRoot":"","sources":["../../../src/clients/datamart-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CA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CAAC;gBAClH,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACvE,CAAC;YAED,GAAG,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,CAAC,CAAC;YACzE,OAAO,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Logger } from 'pino';
2
+ import { type DataMartClient } from './datamart-client.js';
3
+ import { type RestClient } from './rest-client.js';
4
+ import { type AuditClient } from './audit-client.js';
5
+ export interface ClientConfig {
6
+ apiUrl: string;
7
+ company: string;
8
+ authHeaders: Record<string, string>;
9
+ log?: Logger;
10
+ }
11
+ export interface Clients {
12
+ datamart: DataMartClient;
13
+ rest: RestClient;
14
+ audit: AuditClient;
15
+ }
16
+ export declare function createClients(config: ClientConfig, audit?: AuditClient): Clients;
17
+ export type { DataMartClient, RestClient, AuditClient };
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,cAAc,CAAC;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CAMhF;AAED,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { createDataMartClient } from './datamart-client.js';
2
+ import { createRestClient } from './rest-client.js';
3
+ import { createNoOpAuditClient } from './audit-client.js';
4
+ export function createClients(config, audit) {
5
+ return {
6
+ datamart: createDataMartClient(config),
7
+ rest: createRestClient(config),
8
+ audit: audit ?? createNoOpAuditClient(),
9
+ };
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/clients/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAoB,MAAM,mBAAmB,CAAC;AAe5E,MAAM,UAAU,aAAa,CAAC,MAAoB,EAAE,KAAmB;IACrE,OAAO;QACL,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC;QACtC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC;QAC9B,KAAK,EAAE,KAAK,IAAI,qBAAqB,EAAE;KACxC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Logger } from 'pino';
2
+ export interface RestClientConfig {
3
+ apiUrl: string;
4
+ company: string;
5
+ authHeaders: Record<string, string>;
6
+ log?: Logger;
7
+ }
8
+ export interface RestClient {
9
+ get(path: string): Promise<unknown>;
10
+ post(path: string, body: unknown): Promise<unknown>;
11
+ patch(path: string, body: unknown): Promise<unknown>;
12
+ }
13
+ export declare function createRestClient(config: RestClientConfig): RestClient;
14
+ //# sourceMappingURL=rest-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-client.d.ts","sourceRoot":"","sources":["../../../src/clients/rest-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAgCrE"}
@@ -0,0 +1,29 @@
1
+ export function createRestClient(config) {
2
+ const baseUrl = `${config.apiUrl}/v2/${config.company}`;
3
+ const headers = {
4
+ ...config.authHeaders,
5
+ 'Content-Type': 'application/json',
6
+ };
7
+ const log = config.log;
8
+ async function request(method, path, body) {
9
+ const start = Date.now();
10
+ const response = await fetch(`${baseUrl}/${path}`, {
11
+ method,
12
+ headers,
13
+ ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
14
+ });
15
+ if (!response.ok) {
16
+ log?.error({ method, path, status: response.status, ms: Date.now() - start }, 'REST request failed');
17
+ throw new Error(`REST request failed: ${response.status} ${response.statusText}`);
18
+ }
19
+ const result = await response.json();
20
+ log?.debug({ method, path, ms: Date.now() - start }, 'REST request OK');
21
+ return result;
22
+ }
23
+ return {
24
+ get: (path) => request('GET', path),
25
+ post: (path, body) => request('POST', path, body),
26
+ patch: (path, body) => request('PATCH', path, body),
27
+ };
28
+ }
29
+ //# sourceMappingURL=rest-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-client.js","sourceRoot":"","sources":["../../../src/clients/rest-client.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;IACxD,MAAM,OAAO,GAA2B;QACtC,GAAG,MAAM,CAAC,WAAW;QACrB,cAAc,EAAE,kBAAkB;KACnC,CAAC;IACF,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;IAEvB,KAAK,UAAU,OAAO,CAAC,MAAc,EAAE,IAAY,EAAE,IAAc;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEzB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,IAAI,IAAI,EAAE,EAAE;YACjD,MAAM;YACN,OAAO;YACP,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9D,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,CAAC,CAAC;YACrG,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrC,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;QAC3C,IAAI,EAAE,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC;QAClE,KAAK,EAAE,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;KACrE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Logger } from 'pino';
2
+ export declare function createLogger(service: string): Logger;
3
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAOzC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAiCpD"}
@@ -0,0 +1,37 @@
1
+ import pino from 'pino';
2
+ import { mkdirSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ const LOG_DIR = join(process.cwd(), 'logs');
5
+ const LOG_FILE = join(LOG_DIR, 'mcp.log');
6
+ export function createLogger(service) {
7
+ const level = process.env.LOG_LEVEL || 'info';
8
+ const isTest = process.env.NODE_ENV === 'test';
9
+ const targets = [
10
+ {
11
+ target: 'pino-pretty',
12
+ options: {
13
+ singleLine: true,
14
+ translateTime: 'HH:MM:ss.l',
15
+ ignore: 'pid,hostname',
16
+ colorize: true,
17
+ destination: 2,
18
+ },
19
+ level,
20
+ },
21
+ ];
22
+ if (!isTest) {
23
+ mkdirSync(LOG_DIR, { recursive: true });
24
+ targets.push({
25
+ target: 'pino-roll',
26
+ options: { file: LOG_FILE, size: '10m', limit: { count: 5 } },
27
+ level,
28
+ });
29
+ }
30
+ return pino({
31
+ level,
32
+ base: { service, app: 'ITM.MCP' },
33
+ timestamp: pino.stdTimeFunctions.isoTime,
34
+ transport: { targets },
35
+ });
36
+ }
37
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAqB,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE1C,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAC;IAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;IAE/C,MAAM,OAAO,GAAkC;QAC7C;YACE,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE;gBACP,UAAU,EAAE,IAAI;gBAChB,aAAa,EAAE,YAAY;gBAC3B,MAAM,EAAE,cAAc;gBACtB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,CAAC;aACf;YACD,KAAK;SACN;KACF,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,WAAW;YACnB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC7D,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;QACV,KAAK;QACL,IAAI,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE;QACjC,SAAS,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO;QACxC,SAAS,EAAE,EAAE,OAAO,EAAE;KACvB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerPortfolioOverviewPrompt(server: McpServer): void;
3
+ //# sourceMappingURL=portfolio-overview.d.ts.map