@mcp-abap-adt/proxy 0.1.5 → 0.1.9

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 (39) hide show
  1. package/CHANGELOG.md +77 -2
  2. package/README.md +83 -66
  3. package/bin/mcp-abap-adt-proxy.js +15 -42
  4. package/dist/index.d.ts +3 -12
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +414 -277
  7. package/dist/lib/config.d.ts +13 -4
  8. package/dist/lib/config.d.ts.map +1 -1
  9. package/dist/lib/config.js +110 -93
  10. package/dist/lib/errorHandler.d.ts +3 -3
  11. package/dist/lib/errorHandler.d.ts.map +1 -1
  12. package/dist/lib/errorHandler.js +31 -28
  13. package/dist/lib/logger.d.ts.map +1 -1
  14. package/dist/lib/logger.js +12 -9
  15. package/dist/lib/stores.d.ts +7 -7
  16. package/dist/lib/stores.d.ts.map +1 -1
  17. package/dist/lib/stores.js +54 -80
  18. package/dist/lib/transportConfig.d.ts +1 -1
  19. package/dist/lib/transportConfig.d.ts.map +1 -1
  20. package/dist/lib/transportConfig.js +58 -38
  21. package/dist/proxy/btpProxy.d.ts +102 -0
  22. package/dist/proxy/btpProxy.d.ts.map +1 -0
  23. package/dist/proxy/btpProxy.js +833 -0
  24. package/dist/proxy/cloudLlmHubProxy.d.ts +1 -65
  25. package/dist/proxy/cloudLlmHubProxy.d.ts.map +1 -1
  26. package/dist/proxy/cloudLlmHubProxy.js +1 -441
  27. package/dist/router/headerAnalyzer.d.ts +9 -18
  28. package/dist/router/headerAnalyzer.d.ts.map +1 -1
  29. package/dist/router/headerAnalyzer.js +35 -63
  30. package/dist/router/requestInterceptor.d.ts +5 -11
  31. package/dist/router/requestInterceptor.d.ts.map +1 -1
  32. package/dist/router/requestInterceptor.js +33 -30
  33. package/package.json +38 -20
  34. package/dist/router/directCloudRouter.d.ts +0 -32
  35. package/dist/router/directCloudRouter.d.ts.map +0 -1
  36. package/dist/router/directCloudRouter.js +0 -146
  37. package/dist/router/localBasicRouter.d.ts +0 -23
  38. package/dist/router/localBasicRouter.d.ts.map +0 -1
  39. package/dist/router/localBasicRouter.js +0 -118
@@ -1,118 +0,0 @@
1
- "use strict";
2
- /**
3
- * Local Basic Router - Handles basic authentication requests locally
4
- *
5
- * For requests with x-sap-auth-type: "basic", handles locally without proxying
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.createLocalBasicConfig = createLocalBasicConfig;
9
- exports.getLocalBasicConnection = getLocalBasicConnection;
10
- const connection_1 = require("@mcp-abap-adt/connection");
11
- const logger_js_1 = require("../lib/logger.js");
12
- /**
13
- * Convert validated auth config to local basic config
14
- */
15
- function createLocalBasicConfig(routingDecision, headers) {
16
- // Proxy validates only x-btp-destination and x-mcp-destination headers
17
- // This function is not used in the current proxy implementation
18
- // as proxy passes all other headers directly to MCP server
19
- logger_js_1.logger.warn("Local basic routing is not supported in proxy mode", {
20
- type: "LOCAL_BASIC_CONFIG_ERROR",
21
- strategy: routingDecision.strategy,
22
- });
23
- return null;
24
- }
25
- /**
26
- * Connection cache for local basic connections
27
- */
28
- const connectionCache = new Map();
29
- /**
30
- * Generate cache key for connection
31
- */
32
- function generateConnectionCacheKey(sessionId, config) {
33
- const crypto = require("crypto");
34
- const hash = crypto.createHash("sha256");
35
- hash.update(sessionId);
36
- hash.update(config.sapUrl);
37
- hash.update(config.username);
38
- hash.update(config.sapClient || "");
39
- return hash.digest("hex");
40
- }
41
- /**
42
- * Clean up old connections from cache
43
- */
44
- function cleanupConnectionCache() {
45
- const now = new Date();
46
- const maxAge = 60 * 60 * 1000; // 1 hour
47
- for (const [key, entry] of connectionCache.entries()) {
48
- const age = now.getTime() - entry.lastUsed.getTime();
49
- if (age > maxAge) {
50
- logger_js_1.logger.debug("Cleaning up old local basic connection cache entry", {
51
- type: "LOCAL_BASIC_CACHE_CLEANUP",
52
- key: key.substring(0, 16),
53
- });
54
- connectionCache.delete(key);
55
- }
56
- }
57
- }
58
- /**
59
- * Get or create ABAP connection for local basic auth
60
- */
61
- async function getLocalBasicConnection(sessionId, config) {
62
- // Clean up old entries periodically
63
- if (connectionCache.size > 100) {
64
- cleanupConnectionCache();
65
- }
66
- const cacheKey = generateConnectionCacheKey(sessionId, config);
67
- let entry = connectionCache.get(cacheKey);
68
- if (!entry || entry.configSignature !== cacheKey) {
69
- logger_js_1.logger.debug("Creating new local basic connection", {
70
- type: "LOCAL_BASIC_CONNECTION_CREATE",
71
- sessionId: sessionId.substring(0, 8),
72
- sapUrl: config.sapUrl,
73
- });
74
- // Dispose old connection if exists
75
- if (entry) {
76
- // Connection disposal will be handled by connection package
77
- }
78
- // Create SAP config for connection
79
- const sapConfig = {
80
- url: config.sapUrl,
81
- authType: "basic",
82
- username: config.username,
83
- password: config.password,
84
- client: config.sapClient,
85
- };
86
- // Create connection
87
- const connectionSessionId = `mcp-proxy-basic-${sessionId}`;
88
- const sessionStorage = new connection_1.FileSessionStorage();
89
- const connection = (0, connection_1.createAbapConnection)(sapConfig, logger_js_1.logger, // Use our logger
90
- sessionStorage, connectionSessionId);
91
- // Connect
92
- try {
93
- await connection.connect();
94
- }
95
- catch (error) {
96
- logger_js_1.logger.error("Failed to connect to ABAP with basic auth", {
97
- type: "LOCAL_BASIC_CONNECTION_ERROR",
98
- error: error instanceof Error ? error.message : String(error),
99
- sapUrl: config.sapUrl,
100
- });
101
- throw error;
102
- }
103
- entry = {
104
- connection,
105
- configSignature: cacheKey,
106
- lastUsed: new Date(),
107
- };
108
- connectionCache.set(cacheKey, entry);
109
- }
110
- else {
111
- entry.lastUsed = new Date();
112
- logger_js_1.logger.debug("Reusing cached local basic connection", {
113
- type: "LOCAL_BASIC_CONNECTION_REUSE",
114
- sessionId: sessionId.substring(0, 8),
115
- });
116
- }
117
- return entry.connection;
118
- }