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
package/bin/status.js ADDED
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { config } from 'dotenv';
4
+ import { TokenManager } from '../src/auth/token-manager.js';
5
+ import { FileStorageManager } from '../src/auth/file-storage.js';
6
+
7
+ // Load environment variables
8
+ config();
9
+
10
+ class StatusChecker {
11
+ constructor() {
12
+ this.fileStorage = new FileStorageManager();
13
+ }
14
+
15
+ async checkStatus() {
16
+ console.log('šŸ” MCP Salesforce Server Status Check');
17
+ console.log('=====================================\n');
18
+
19
+ // Check configuration
20
+ console.log('šŸ“‹ Configuration Status:');
21
+ const configStatus = await this.checkConfiguration();
22
+
23
+ if (!configStatus.valid) {
24
+ console.log('\nāŒ Configuration incomplete. Please run salesforce_setup tool first.');
25
+ return;
26
+ }
27
+
28
+ // Check authentication
29
+ console.log('\nšŸ” Authentication Status:');
30
+ await this.checkAuthentication(configStatus.credentials);
31
+
32
+ console.log('\nšŸ’” Next Steps:');
33
+ console.log('- If authentication failed, run: npm run setup');
34
+ console.log('- If successful, add to Claude Desktop configuration');
35
+ console.log('- Use npm run config-help for Connected App setup');
36
+ }
37
+
38
+ async checkConfiguration() {
39
+ try {
40
+ const credentials = await this.fileStorage.getCredentials();
41
+
42
+ if (!credentials) {
43
+ console.log('āŒ No credentials found in ~/.mcp-salesforce.json');
44
+ console.log(' Run the salesforce_setup tool to configure credentials');
45
+ return { valid: false };
46
+ }
47
+
48
+ const { clientId, clientSecret, instanceUrl } = credentials;
49
+
50
+ if (!clientId || !clientSecret || !instanceUrl) {
51
+ console.log('āŒ Incomplete credentials in ~/.mcp-salesforce.json');
52
+ console.log(' Run the salesforce_setup tool to reconfigure credentials');
53
+ return { valid: false };
54
+ }
55
+
56
+ console.log(`āœ… Client ID: ${this.maskSensitive('CLIENT_ID', clientId)}`);
57
+ console.log(`āœ… Client Secret: ${this.maskSensitive('CLIENT_SECRET', clientSecret)}`);
58
+ console.log(`āœ… Instance URL: ${instanceUrl}`);
59
+
60
+ // Check API config
61
+ const apiConfig = await this.fileStorage.getApiConfig();
62
+ console.log(`āœ… API Version: ${apiConfig.apiVersion}`);
63
+ console.log(`āœ… Callback Port: ${apiConfig.callbackPort}`);
64
+
65
+ return { valid: true, credentials };
66
+ } catch (error) {
67
+ console.log(`āŒ Configuration check failed: ${error.message}`);
68
+ return { valid: false };
69
+ }
70
+ }
71
+
72
+ async checkAuthentication(credentials) {
73
+ try {
74
+ const tokenManager = new TokenManager(
75
+ credentials.clientId,
76
+ credentials.clientSecret,
77
+ credentials.instanceUrl
78
+ );
79
+
80
+ const hasTokens = await tokenManager.initialize();
81
+
82
+ if (!hasTokens) {
83
+ console.log('āŒ No authentication tokens found');
84
+ console.log(' Run: npm run setup');
85
+ return false;
86
+ }
87
+
88
+ const tokenInfo = tokenManager.getTokenInfo();
89
+ console.log('āœ… Tokens found in ~/.mcp-salesforce.json');
90
+ console.log(` Instance: ${tokenInfo.instance_url}`);
91
+
92
+ if (tokenInfo.expires_at) {
93
+ const expiresIn = Math.round((tokenInfo.expires_at - Date.now()) / (1000 * 60));
94
+ console.log(` Expires: ${expiresIn} minutes`);
95
+ }
96
+
97
+ // Test the tokens
98
+ console.log('🧪 Testing token validity...');
99
+ const testResult = await tokenManager.testTokens();
100
+
101
+ if (testResult.valid) {
102
+ console.log('āœ… Authentication successful!');
103
+ console.log(` API versions available: ${testResult.apiVersions}`);
104
+ return true;
105
+ } else {
106
+ console.log(`āŒ Token validation failed: ${testResult.error}`);
107
+ console.log(' Run: npm run setup');
108
+ return false;
109
+ }
110
+ } catch (error) {
111
+ console.log(`āŒ Authentication check failed: ${error.message}`);
112
+ return false;
113
+ }
114
+ }
115
+
116
+ maskSensitive(key, value) {
117
+ if (key.includes('SECRET')) {
118
+ return value.substring(0, 8) + '***';
119
+ }
120
+ if (key.includes('CLIENT_ID')) {
121
+ return value.substring(0, 12) + '***';
122
+ }
123
+ return value;
124
+ }
125
+ }
126
+
127
+ // Run status check if called directly
128
+ if (import.meta.url === `file://${process.argv[1]}`) {
129
+ const checker = new StatusChecker();
130
+ checker.checkStatus().catch(error => {
131
+ console.error('āŒ Status check failed:', error.message);
132
+ process.exit(1);
133
+ });
134
+ }
package/docs/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Documentation
2
+
3
+ This directory contains all project documentation files.
4
+
5
+ ## Architecture & Design
6
+ - [`mcp-salesforce-architecture.md`](./mcp-salesforce-architecture.md) - Overall system architecture
7
+ - [`IMPLEMENTATION_SUMMARY.md`](./IMPLEMENTATION_SUMMARY.md) - Implementation overview
8
+
9
+ ## Setup & Installation
10
+ - [`INSTALL.md`](./INSTALL.md) - Installation instructions
11
+ - [`setup.md`](./setup.md) - Setup guide
12
+ - [`oauth-guide.md`](./oauth-guide.md) - OAuth setup guide
13
+
14
+ ## Features & Enhancements
15
+ - [`SALESFORCE_BACKUP_FEATURE_PLAN.md`](./SALESFORCE_BACKUP_FEATURE_PLAN.md) - Backup feature planning
16
+ - [`SALESFORCE_BACKUP_IMPLEMENTATION_COMPLETE.md`](./SALESFORCE_BACKUP_IMPLEMENTATION_COMPLETE.md) - Backup implementation
17
+ - [`SALESFORCE_TIME_MACHINE_COMPLETE.md`](./SALESFORCE_TIME_MACHINE_COMPLETE.md) - Time machine feature
18
+ - [`DYNAMIC_CONTEXT_LEARNING_COMPLETE.md`](./DYNAMIC_CONTEXT_LEARNING_COMPLETE.md) - Learning system
19
+ - [`learning-system-demo.md`](./learning-system-demo.md) - Learning system demo
20
+ - [`context-learning.md`](./context-learning.md) - Context learning details
21
+ - [`AHA_MOMENT_CAPTURE_ENHANCEMENT.md`](./AHA_MOMENT_CAPTURE_ENHANCEMENT.md) - Aha moment capture
22
+ - [`FIELD_WRITABILITY_ENHANCEMENT_COMPLETE.md`](./FIELD_WRITABILITY_ENHANCEMENT_COMPLETE.md) - Field writability
23
+ - [`INTERNATIONALIZATION_COMPLETE.md`](./INTERNATIONALIZATION_COMPLETE.md) - I18n support
24
+ - [`QUICK_SETUP_FEATURE_COMPLETE.md`](./QUICK_SETUP_FEATURE_COMPLETE.md) - Quick setup feature
25
+ - [`TRANSLATION_COMPLETE.md`](./TRANSLATION_COMPLETE.md) - Translation support
26
+
27
+ ## Development Progress
28
+ - [`NPX_IMPLEMENTATION_COMPLETE.md`](./NPX_IMPLEMENTATION_COMPLETE.md) - NPX implementation
29
+ - [`OAUTH_FIX_COMPLETE.md`](./OAUTH_FIX_COMPLETE.md) - OAuth fixes
30
+ - [`ASYNC_BACKUP_SYSTEM_COMPLETE.md`](./ASYNC_BACKUP_SYSTEM_COMPLETE.md) - Async backup system
31
+ - [`ASYNC_BACKUP_IMPLEMENTATION_COMPLETE.md`](./ASYNC_BACKUP_IMPLEMENTATION_COMPLETE.md) - Async backup implementation
32
+
33
+ ## Bug Fixes & Resolutions
34
+ - [`OAUTH_CSRF_FIXES_COMPLETE.md`](./OAUTH_CSRF_FIXES_COMPLETE.md) - CSRF fixes
35
+ - [`OAUTH_CSRF_RESOLUTION_COMPLETE.md`](./OAUTH_CSRF_RESOLUTION_COMPLETE.md) - CSRF resolution
36
+ - [`PATH_RESOLUTION_FIX_COMPLETE.md`](./PATH_RESOLUTION_FIX_COMPLETE.md) - Path resolution fixes
37
+ - [`PATH_RESOLUTION_BUGS_FIXED.md`](./PATH_RESOLUTION_BUGS_FIXED.md) - Path resolution bugs
38
+ - [`HANGING_ISSUE_RESOLVED.md`](./HANGING_ISSUE_RESOLVED.md) - Hanging issue resolution
39
+ - [`COMPLETED_INTERVIEW_ISSUE_RESOLVED.md`](./COMPLETED_INTERVIEW_ISSUE_RESOLVED.md) - Interview issue fix
40
+
41
+ ## Cleanup & Maintenance
42
+ - [`FINAL_CLEANUP_SUMMARY.md`](./FINAL_CLEANUP_SUMMARY.md) - Final cleanup summary
43
+ - [`FINAL_FILE_STRUCTURE_CLEANUP_COMPLETE.md`](./FINAL_FILE_STRUCTURE_CLEANUP_COMPLETE.md) - File structure cleanup
44
+ - [`API_CLEANUP_COMPLETE.md`](./API_CLEANUP_COMPLETE.md) - API cleanup
45
+ - [`CONSOLE_LOG_CLEANUP_COMPLETE.md`](./CONSOLE_LOG_CLEANUP_COMPLETE.md) - Console log cleanup
46
+
47
+ ## Examples & Usage
48
+ - [`examples.md`](./examples.md) - Usage examples
49
+ - See also: [`../examples/`](../examples/) directory for demo scripts
50
+
51
+ ## Setup Screenshots
52
+ - `step1.png`, `step2.png`, `step3.png`, `step4.png` - Installation and setup screenshots
package/docs/step1.png ADDED
Binary file
package/docs/step2.png ADDED
Binary file
package/docs/step3.png ADDED
Binary file
package/docs/step4.png ADDED
Binary file
@@ -0,0 +1,35 @@
1
+ # Examples & Demos
2
+
3
+ This directory contains example scripts and demos for the MCP Salesforce server.
4
+
5
+ ## Demo Scripts
6
+
7
+ ### Core Functionality
8
+ - [`demo-complete.js`](./demo-complete.js) - Complete functionality demonstration
9
+ - [`demo-salesforce-backup.js`](./demo-salesforce-backup.js) - Backup system demo
10
+
11
+ ### Learning System
12
+ - [`demo-dynamic-learning.js`](./demo-dynamic-learning.js) - Dynamic learning capabilities
13
+ - [`demo-aha-moment-capture.js`](./demo-aha-moment-capture.js) - Aha moment capture demo
14
+ - [`demo-additional-questions.js`](./demo-additional-questions.js) - Additional questions demo
15
+
16
+ ### Time Machine
17
+ - [`demo-time-machine.js`](./demo-time-machine.js) - Basic time machine demo
18
+ - [`demo-time-machine-advanced.js`](./demo-time-machine-advanced.js) - Advanced time machine features
19
+
20
+ ## Running Examples
21
+
22
+ To run any demo script:
23
+
24
+ ```bash
25
+ node examples/demo-script-name.js
26
+ ```
27
+
28
+ Make sure you have:
29
+ 1. Set up your environment variables in `.env`
30
+ 2. Authenticated with Salesforce using the setup tool
31
+ 3. Installed all dependencies with `npm install`
32
+
33
+ ## Related Documentation
34
+
35
+ See the [`../docs/`](../docs/) directory for detailed documentation on features demonstrated in these examples.
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "delegate-sf-mcp",
3
+ "version": "0.2.0",
4
+ "description": "Delegate Salesforce MCP Server",
5
+ "type": "module",
6
+ "scripts": {
7
+ "auth": "node auth.js",
8
+ "start": "node src/index.js"
9
+ },
10
+ "dependencies": {
11
+ "@modelcontextprotocol/sdk": "^1.0.0",
12
+ "jsforce": "^1.11.1",
13
+ "dotenv": "^16.4.5",
14
+ "zod": "^3.23.8"
15
+ }
16
+ }
@@ -0,0 +1,30 @@
1
+ # Development Scripts
2
+
3
+ This directory contains development, debugging, and testing scripts.
4
+
5
+ ## Debug Scripts
6
+ - [`debug-learning.js`](./debug-learning.js) - Debug learning system
7
+ - [`debug-oauth-csrf.js`](./debug-oauth-csrf.js) - Debug OAuth CSRF issues
8
+
9
+ ## Fix Scripts
10
+ - [`fix-oauth-csrf.js`](./fix-oauth-csrf.js) - OAuth CSRF fix script
11
+
12
+ ## Test Scripts
13
+ - [`test-*.js`](./test-async-backup.js) - Various test scripts for different components
14
+ - [`minimal-test.js`](./minimal-test.js) - Minimal functionality test
15
+ - [`explore-sf.js`](./explore-sf.js) - Salesforce exploration script
16
+
17
+ ## Usage
18
+
19
+ These scripts are primarily for development and debugging purposes. Most require:
20
+
21
+ 1. Environment variables set in `.env`
22
+ 2. Valid Salesforce authentication
23
+ 3. Node.js dependencies installed
24
+
25
+ Example:
26
+ ```bash
27
+ node scripts/minimal-test.js
28
+ ```
29
+
30
+ **Note:** These scripts are development tools and not part of the main package functionality. Use the examples in [`../examples/`](../examples/) for production usage patterns.