delegate-sf-mcp 0.2.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 (44) hide show
  1. package/.eslintrc.json +20 -0
  2. package/LICENSE +24 -0
  3. package/README.md +76 -0
  4. package/auth.js +148 -0
  5. package/bin/config-helper.js +51 -0
  6. package/bin/mcp-salesforce.js +12 -0
  7. package/bin/setup.js +266 -0
  8. package/bin/status.js +134 -0
  9. package/docs/README.md +52 -0
  10. package/docs/step1.png +0 -0
  11. package/docs/step2.png +0 -0
  12. package/docs/step3.png +0 -0
  13. package/docs/step4.png +0 -0
  14. package/examples/README.md +35 -0
  15. package/package.json +16 -0
  16. package/scripts/README.md +30 -0
  17. package/src/auth/file-storage.js +447 -0
  18. package/src/auth/oauth.js +417 -0
  19. package/src/auth/token-manager.js +207 -0
  20. package/src/backup/manager.js +949 -0
  21. package/src/index.js +168 -0
  22. package/src/salesforce/client.js +388 -0
  23. package/src/sf-client.js +79 -0
  24. package/src/tools/auth.js +190 -0
  25. package/src/tools/backup.js +486 -0
  26. package/src/tools/create.js +109 -0
  27. package/src/tools/delegate-hygiene.js +268 -0
  28. package/src/tools/delegate-validate.js +212 -0
  29. package/src/tools/delegate-verify.js +143 -0
  30. package/src/tools/delete.js +72 -0
  31. package/src/tools/describe.js +132 -0
  32. package/src/tools/installation-info.js +656 -0
  33. package/src/tools/learn-context.js +1077 -0
  34. package/src/tools/learn.js +351 -0
  35. package/src/tools/query.js +82 -0
  36. package/src/tools/repair-credentials.js +77 -0
  37. package/src/tools/setup.js +120 -0
  38. package/src/tools/time_machine.js +347 -0
  39. package/src/tools/update.js +138 -0
  40. package/src/tools.js +214 -0
  41. package/src/utils/cache.js +120 -0
  42. package/src/utils/debug.js +52 -0
  43. package/src/utils/logger.js +19 -0
  44. package/tokens.json +8 -0
@@ -0,0 +1,120 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import os from 'os';
4
+
5
+ /**
6
+ * Cross-platform cache directory management
7
+ * Works on Windows, macOS, and Linux
8
+ */
9
+
10
+ // Cache directory in home directory - cross-platform
11
+ const CACHE_DIR = path.join(os.homedir(), '.mcp-salesforce-cache');
12
+
13
+ /**
14
+ * Get the cache directory path
15
+ * @returns {string} Cache directory path
16
+ */
17
+ export function getCacheDir() {
18
+ return CACHE_DIR;
19
+ }
20
+
21
+ /**
22
+ * Get path to a file in the cache directory
23
+ * @param {string} filename - Name of the file
24
+ * @returns {string} Full path to the file
25
+ */
26
+ export function getCacheFilePath(filename) {
27
+ return path.join(CACHE_DIR, filename);
28
+ }
29
+
30
+ /**
31
+ * Ensure cache directory exists
32
+ * Creates the directory if it doesn't exist
33
+ */
34
+ export async function ensureCacheDirectory() {
35
+ try {
36
+ await fs.access(CACHE_DIR);
37
+ } catch (error) {
38
+ if (error.code === 'ENOENT') {
39
+ await fs.mkdir(CACHE_DIR, { recursive: true });
40
+ } else {
41
+ throw error;
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Check if cache directory exists
48
+ * @returns {boolean} True if directory exists
49
+ */
50
+ export async function cacheDirectoryExists() {
51
+ try {
52
+ await fs.access(CACHE_DIR);
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Clear all cache files
61
+ * Removes all files in the cache directory but keeps the directory
62
+ */
63
+ export async function clearCache() {
64
+ try {
65
+ const files = await fs.readdir(CACHE_DIR);
66
+ await Promise.all(files.map(file => fs.unlink(path.join(CACHE_DIR, file))));
67
+ } catch (error) {
68
+ if (error.code !== 'ENOENT') {
69
+ throw error;
70
+ }
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Get cache directory information
76
+ * @returns {Object} Information about the cache directory
77
+ */
78
+ export async function getCacheInfo() {
79
+ try {
80
+ const exists = await cacheDirectoryExists();
81
+ if (!exists) {
82
+ return {
83
+ exists: false,
84
+ path: CACHE_DIR,
85
+ platform: os.platform(),
86
+ homeDir: os.homedir()
87
+ };
88
+ }
89
+
90
+ const files = await fs.readdir(CACHE_DIR);
91
+ const fileStats = await Promise.all(
92
+ files.map(async (file) => {
93
+ const filePath = path.join(CACHE_DIR, file);
94
+ const stats = await fs.stat(filePath);
95
+ return {
96
+ name: file,
97
+ size: stats.size,
98
+ modified: stats.mtime.toISOString()
99
+ };
100
+ })
101
+ );
102
+
103
+ return {
104
+ exists: true,
105
+ path: CACHE_DIR,
106
+ platform: os.platform(),
107
+ homeDir: os.homedir(),
108
+ fileCount: files.length,
109
+ files: fileStats
110
+ };
111
+ } catch (error) {
112
+ return {
113
+ exists: false,
114
+ path: CACHE_DIR,
115
+ platform: os.platform(),
116
+ homeDir: os.homedir(),
117
+ error: error.message
118
+ };
119
+ }
120
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Debug Utility for MCP Server
3
+ *
4
+ * This module provides debug logging that only outputs when DEBUG mode is enabled.
5
+ * This prevents console.log from interfering with MCP STDIO communication.
6
+ */
7
+
8
+ const DEBUG_MODE = process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development';
9
+
10
+ /**
11
+ * Debug logger that only outputs in debug mode
12
+ */
13
+ export const debug = {
14
+ log: (...args) => {
15
+ if (DEBUG_MODE) {
16
+ console.error('[DEBUG]', ...args); // Use stderr for debug to avoid STDIO interference
17
+ }
18
+ },
19
+
20
+ warn: (...args) => {
21
+ if (DEBUG_MODE) {
22
+ console.error('[WARN]', ...args);
23
+ }
24
+ },
25
+
26
+ error: (...args) => {
27
+ if (DEBUG_MODE) {
28
+ console.error('[ERROR]', ...args);
29
+ }
30
+ },
31
+
32
+ info: (...args) => {
33
+ if (DEBUG_MODE) {
34
+ console.error('[INFO]', ...args);
35
+ }
36
+ }
37
+ };
38
+
39
+ /**
40
+ * Silent logger for production use
41
+ */
42
+ export const silent = {
43
+ log: () => {},
44
+ warn: () => {},
45
+ error: () => {},
46
+ info: () => {}
47
+ };
48
+
49
+ /**
50
+ * Get appropriate logger based on environment
51
+ */
52
+ export const logger = DEBUG_MODE ? debug : silent;
@@ -0,0 +1,19 @@
1
+ // Simple logger utility to avoid JSON parsing issues
2
+ class Logger {
3
+ static warn(message, ...args) {
4
+ // Silent logging to avoid JSON parsing issues in MCP
5
+ // In production, this could write to a log file
6
+ }
7
+
8
+ static log(message, ...args) {
9
+ // Silent logging to avoid JSON parsing issues in MCP
10
+ // In production, this could write to a log file
11
+ }
12
+
13
+ static error(message, ...args) {
14
+ // Silent logging to avoid JSON parsing issues in MCP
15
+ // In production, this could write to a log file
16
+ }
17
+ }
18
+
19
+ export { Logger };
package/tokens.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "instanceUrl": "https://delegate-master-dev.my.salesforce.com",
3
+ "accessToken": "00Df40000037WLr!AQEAQCfyQZrrWEqZ9egVbDkiuuJBtBb1HjYeRo5fvZBG4Yhy5rsFre4zOXheVrWx_.0VJDl_au0dE69qLSNZhTAPc7sCl1Pt",
4
+ "refreshToken": "5Aep861UTWIWNgl0kdq9cNekO9dtf7LtXIHmu8Tlzjx0XfIldfkBXcLPyzphco9E6Wn1KGVcGhycarhc78fQ3Bc",
5
+ "clientId": "3MVG9zlTNB8o8BA3McKrN0Q3hxR9WzJC9ZNsZsv1wok6_gcq2qrKJTZ3ZNlWLJZxJVNypk1G_x5gF5kKPooGi",
6
+ "clientSecret": "1F648DBE2AC12D6617A6707987E9FF42F5858184908B9082EE1F11B0E0B4005D",
7
+ "loginUrl": "https://delegate-master-dev.my.salesforce.com"
8
+ }