snow-flow 8.37.26 → 8.38.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.
- package/.snow-code/agent/deployment-specialist.md +346 -0
- package/.snow-code/agent/orchestrator.md +286 -0
- package/.snow-code/agent/risk-assessor.md +454 -0
- package/.snow-code/agent/solution-architect.md +582 -0
- package/.snow-code/agent/validator.md +503 -0
- package/.snow-code/opencode.json +49 -0
- package/README.md +141 -904
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +93 -256
- package/dist/cli.js.map +1 -1
- package/dist/utils/sync-mcp-configs.d.ts +7 -5
- package/dist/utils/sync-mcp-configs.d.ts.map +1 -1
- package/dist/utils/sync-mcp-configs.js +19 -74
- package/dist/utils/sync-mcp-configs.js.map +1 -1
- package/package.json +2 -3
- package/scripts/check-binary-updates.js +0 -169
- package/scripts/check-npm-version.js +0 -92
- package/scripts/classify-all-tools.ts +0 -446
- package/scripts/classify-edge-cases.ts +0 -275
- package/scripts/classify-operations-tools.sh +0 -96
- package/scripts/cleanup-mcp-servers.js +0 -115
- package/scripts/diagnose-mcp.js +0 -299
- package/scripts/generate-mcp-config.js +0 -45
- package/scripts/mcp-server-manager.sh +0 -320
- package/scripts/postinstall.js +0 -75
- package/scripts/reset-mcp-servers.js +0 -266
- package/scripts/safe-mcp-cleanup.js +0 -151
- package/scripts/setup-mcp.js +0 -106
- package/scripts/start-mcp-proper.js +0 -76
- package/scripts/start-snowcode.sh +0 -123
- package/scripts/start-sysprops-mcp.js +0 -43
- package/scripts/sync-snow-code-version.js +0 -74
- package/scripts/test-auth-flow.js +0 -172
- package/scripts/test-auth-location-fix.js +0 -84
- package/scripts/test-mcp-manual.js +0 -140
- package/scripts/test-todowrite-timeout.js +0 -108
- package/scripts/update-dependencies.js +0 -90
- package/scripts/update-mcp-config.js +0 -96
- package/scripts/update-snow-code.js +0 -146
- package/scripts/verify-snowcode-fork.sh +0 -141
- package/templates/snow-code-package.json +0 -3
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# SnowCode Launcher with MCP Server Pre-flight Checks
|
|
4
|
-
# Ensures MCP servers are running before starting SnowCode
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
set -e
|
|
8
|
-
|
|
9
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
-
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
11
|
-
MCP_MANAGER="$SCRIPT_DIR/mcp-server-manager.sh"
|
|
12
|
-
|
|
13
|
-
# Colors
|
|
14
|
-
RED='\033[0;31m'
|
|
15
|
-
GREEN='\033[0;32m'
|
|
16
|
-
YELLOW='\033[1;33m'
|
|
17
|
-
BLUE='\033[0;34m'
|
|
18
|
-
NC='\033[0m'
|
|
19
|
-
|
|
20
|
-
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
|
|
21
|
-
echo -e "${BLUE} Snow-Flow SnowCode Launcher${NC}"
|
|
22
|
-
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
|
|
23
|
-
echo ""
|
|
24
|
-
|
|
25
|
-
# Check if snowcode is installed
|
|
26
|
-
if ! command -v snowcode &> /dev/null; then
|
|
27
|
-
echo -e "${RED}✗ SnowCode not found!${NC}"
|
|
28
|
-
echo ""
|
|
29
|
-
echo "Install SnowCode:"
|
|
30
|
-
echo " npm install -g @snowcode-ai/cli"
|
|
31
|
-
echo ""
|
|
32
|
-
echo "Or visit: https://snowcode.ai"
|
|
33
|
-
exit 1
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
echo -e "${GREEN}✓ SnowCode found${NC}"
|
|
37
|
-
|
|
38
|
-
# Check if .env exists
|
|
39
|
-
if [ ! -f "$PROJECT_ROOT/.env" ]; then
|
|
40
|
-
echo -e "${RED}✗ .env file not found!${NC}"
|
|
41
|
-
echo ""
|
|
42
|
-
echo "Create .env from template:"
|
|
43
|
-
echo " cp .env.example .env"
|
|
44
|
-
echo " # Then edit .env with your ServiceNow credentials"
|
|
45
|
-
exit 1
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
echo -e "${GREEN}✓ .env file found${NC}"
|
|
49
|
-
|
|
50
|
-
# Check if dist/ exists (built)
|
|
51
|
-
if [ ! -d "$PROJECT_ROOT/dist" ]; then
|
|
52
|
-
echo -e "${YELLOW}Building Snow-Flow...${NC}"
|
|
53
|
-
cd "$PROJECT_ROOT"
|
|
54
|
-
npm run build
|
|
55
|
-
fi
|
|
56
|
-
|
|
57
|
-
echo -e "${GREEN}✓ Snow-Flow built${NC}"
|
|
58
|
-
|
|
59
|
-
# Check if MCP servers are running
|
|
60
|
-
echo -e "\n${BLUE}Checking MCP servers...${NC}"
|
|
61
|
-
|
|
62
|
-
if "$MCP_MANAGER" status > /dev/null 2>&1; then
|
|
63
|
-
echo -e "${GREEN}✓ MCP servers already running${NC}"
|
|
64
|
-
else
|
|
65
|
-
echo -e "${YELLOW}Starting MCP servers...${NC}"
|
|
66
|
-
"$MCP_MANAGER" start
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
# Run health check
|
|
70
|
-
echo -e "\n${BLUE}Running health check...${NC}"
|
|
71
|
-
if "$MCP_MANAGER" health; then
|
|
72
|
-
echo -e "${GREEN}✓ All systems operational${NC}"
|
|
73
|
-
else
|
|
74
|
-
echo -e "${RED}✗ Health check failed${NC}"
|
|
75
|
-
echo ""
|
|
76
|
-
echo "Troubleshooting:"
|
|
77
|
-
echo " 1. Check logs: $MCP_MANAGER logs"
|
|
78
|
-
echo " 2. Verify .env credentials"
|
|
79
|
-
echo " 3. Test manually: $MCP_MANAGER health"
|
|
80
|
-
exit 1
|
|
81
|
-
fi
|
|
82
|
-
|
|
83
|
-
# Check if snow-code-config.json exists
|
|
84
|
-
if [ ! -f "$PROJECT_ROOT/snow-code-config.json" ]; then
|
|
85
|
-
echo -e "${YELLOW}Creating snow-code-config.json...${NC}"
|
|
86
|
-
|
|
87
|
-
if [ -f "$PROJECT_ROOT/snow-code-config.example.json" ]; then
|
|
88
|
-
cp "$PROJECT_ROOT/snow-code-config.example.json" "$PROJECT_ROOT/snow-code-config.json"
|
|
89
|
-
|
|
90
|
-
# Replace variables in config
|
|
91
|
-
source "$PROJECT_ROOT/.env"
|
|
92
|
-
|
|
93
|
-
sed -i.bak "s|\${SNOW_INSTANCE}|${SNOW_INSTANCE}|g" "$PROJECT_ROOT/snow-code-config.json"
|
|
94
|
-
sed -i.bak "s|\${SNOW_CLIENT_ID}|${SNOW_CLIENT_ID}|g" "$PROJECT_ROOT/snow-code-config.json"
|
|
95
|
-
sed -i.bak "s|\${SNOW_CLIENT_SECRET}|${SNOW_CLIENT_SECRET}|g" "$PROJECT_ROOT/snow-code-config.json"
|
|
96
|
-
sed -i.bak "s|\${SNOW_USERNAME}|${SNOW_USERNAME}|g" "$PROJECT_ROOT/snow-code-config.json"
|
|
97
|
-
sed -i.bak "s|\${SNOW_PASSWORD}|${SNOW_PASSWORD}|g" "$PROJECT_ROOT/snow-code-config.json"
|
|
98
|
-
sed -i.bak "s|/path/to/your/snow-flow/installation|${PROJECT_ROOT}|g" "$PROJECT_ROOT/snow-code-config.json"
|
|
99
|
-
|
|
100
|
-
rm -f "$PROJECT_ROOT/snow-code-config.json.bak"
|
|
101
|
-
|
|
102
|
-
echo -e "${GREEN}✓ snow-code-config.json created${NC}"
|
|
103
|
-
else
|
|
104
|
-
echo -e "${RED}✗ snow-code-config.example.json not found${NC}"
|
|
105
|
-
exit 1
|
|
106
|
-
fi
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo -e "${GREEN}✓ SnowCode configuration ready${NC}"
|
|
110
|
-
|
|
111
|
-
# Start SnowCode
|
|
112
|
-
echo -e "\n${BLUE}════════════════════════════════════════════════${NC}"
|
|
113
|
-
echo -e "${GREEN}Starting SnowCode...${NC}"
|
|
114
|
-
echo -e "${BLUE}════════════════════════════════════════════════${NC}"
|
|
115
|
-
echo ""
|
|
116
|
-
echo -e "${YELLOW}Tips:${NC}"
|
|
117
|
-
echo -e " • MCP tools are loaded: snow_update_set_manage, snow_deploy, etc."
|
|
118
|
-
echo -e " • Start with: ${GREEN}Create an Update Set${NC}"
|
|
119
|
-
echo -e " • Check tools: Type ${GREEN}list available tools${NC}"
|
|
120
|
-
echo ""
|
|
121
|
-
|
|
122
|
-
cd "$PROJECT_ROOT"
|
|
123
|
-
exec snowcode "$@"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Start ServiceNow System Properties MCP Server
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { spawn } = require('child_process');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
|
-
const serverPath = path.join(__dirname, '..', 'dist', 'mcp', 'servicenow-system-properties-mcp.js');
|
|
11
|
-
|
|
12
|
-
console.log('🚀 Starting ServiceNow System Properties MCP Server...');
|
|
13
|
-
console.log(`📁 Server path: ${serverPath}`);
|
|
14
|
-
|
|
15
|
-
const child = spawn('node', [serverPath], {
|
|
16
|
-
stdio: 'inherit',
|
|
17
|
-
env: {
|
|
18
|
-
...process.env,
|
|
19
|
-
NODE_ENV: 'production'
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
child.on('error', (error) => {
|
|
24
|
-
console.error('❌ Failed to start MCP server:', error);
|
|
25
|
-
process.exit(1);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
child.on('exit', (code) => {
|
|
29
|
-
if (code !== 0) {
|
|
30
|
-
console.error(`❌ MCP server exited with code ${code}`);
|
|
31
|
-
process.exit(code);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
process.on('SIGINT', () => {
|
|
36
|
-
console.log('\n⏹️ Stopping MCP server...');
|
|
37
|
-
child.kill('SIGINT');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
process.on('SIGTERM', () => {
|
|
41
|
-
console.log('\n⏹️ Stopping MCP server...');
|
|
42
|
-
child.kill('SIGTERM');
|
|
43
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Automatically sync peerDependencies to latest @groeimetai/snow-code version
|
|
5
|
-
* Runs before publish to ensure users always get the latest snow-code
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { execSync } = require('child_process');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
async function syncSnowCodeVersion() {
|
|
13
|
-
try {
|
|
14
|
-
console.log('🔍 Syncing @groeimetai/snow-code peerDependency to wildcard...');
|
|
15
|
-
|
|
16
|
-
// Read current package.json
|
|
17
|
-
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
18
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
19
|
-
|
|
20
|
-
// Ensure peerDependencies exists
|
|
21
|
-
if (!packageJson.peerDependencies) {
|
|
22
|
-
packageJson.peerDependencies = {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Get current peer dependency version
|
|
26
|
-
const currentVersion = packageJson.peerDependencies['@groeimetai/snow-code'];
|
|
27
|
-
|
|
28
|
-
if (currentVersion === '*') {
|
|
29
|
-
console.log(`✓ Already up to date: *`);
|
|
30
|
-
return { updated: false };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Update peerDependency to wildcard (matches dependencies field)
|
|
34
|
-
packageJson.peerDependencies['@groeimetai/snow-code'] = '*';
|
|
35
|
-
|
|
36
|
-
// Write back to package.json
|
|
37
|
-
fs.writeFileSync(
|
|
38
|
-
packageJsonPath,
|
|
39
|
-
JSON.stringify(packageJson, null, 2) + '\n',
|
|
40
|
-
'utf-8'
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
console.log(`✅ Updated peerDependency: ${currentVersion} → *`);
|
|
44
|
-
|
|
45
|
-
// Stage the change for git
|
|
46
|
-
try {
|
|
47
|
-
execSync('git add package.json', { cwd: path.join(__dirname, '..') });
|
|
48
|
-
console.log('✅ Staged package.json for commit');
|
|
49
|
-
} catch (err) {
|
|
50
|
-
// Git add might fail if not in a git repo, that's ok
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return { updated: true };
|
|
54
|
-
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.error('❌ Failed to sync @groeimetai/snow-code peerDependency:', error.message);
|
|
57
|
-
console.error(' Continuing with current version...');
|
|
58
|
-
return { updated: false, error: error.message };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Run if called directly
|
|
63
|
-
if (require.main === module) {
|
|
64
|
-
syncSnowCodeVersion().then(result => {
|
|
65
|
-
if (result.updated) {
|
|
66
|
-
console.log('\n🎉 Ready to publish with wildcard @groeimetai/snow-code dependency!');
|
|
67
|
-
} else if (result.error) {
|
|
68
|
-
console.log('\n⚠️ Could not auto-sync, but continuing...');
|
|
69
|
-
}
|
|
70
|
-
process.exit(0);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = { syncSnowCodeVersion };
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Test Authentication Flow
|
|
5
|
-
*
|
|
6
|
-
* This script verifies that the MCP server can properly load credentials
|
|
7
|
-
* from either environment variables or snow-code auth.json.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const os = require('os');
|
|
13
|
-
|
|
14
|
-
console.log('🔐 Testing Snow-Flow Authentication Flow\n');
|
|
15
|
-
|
|
16
|
-
// Test 1: Check for auth.json
|
|
17
|
-
console.log('Test 1: Checking snow-code auth.json...');
|
|
18
|
-
const authPath = path.join(os.homedir(), '.local', 'share', 'snow-code', 'auth.json');
|
|
19
|
-
|
|
20
|
-
if (fs.existsSync(authPath)) {
|
|
21
|
-
console.log('✅ auth.json exists at:', authPath);
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const authData = JSON.parse(fs.readFileSync(authPath, 'utf-8'));
|
|
25
|
-
const servicenowCreds = authData['servicenow'];
|
|
26
|
-
|
|
27
|
-
if (servicenowCreds && servicenowCreds.type === 'servicenow-oauth') {
|
|
28
|
-
console.log('✅ ServiceNow OAuth credentials found');
|
|
29
|
-
console.log(' Instance:', servicenowCreds.instance);
|
|
30
|
-
console.log(' Client ID:', servicenowCreds.clientId ? '***' + servicenowCreds.clientId.slice(-4) : 'NOT SET');
|
|
31
|
-
console.log(' Client Secret:', servicenowCreds.clientSecret ? '***' + servicenowCreds.clientSecret.slice(-4) : 'NOT SET');
|
|
32
|
-
console.log(' Has Refresh Token:', !!servicenowCreds.refreshToken);
|
|
33
|
-
} else {
|
|
34
|
-
console.log('❌ No ServiceNow OAuth credentials in auth.json');
|
|
35
|
-
console.log(' Run: snow-flow auth login');
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.log('❌ Failed to parse auth.json:', error.message);
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
console.log('❌ auth.json not found');
|
|
42
|
-
console.log(' Expected location:', authPath);
|
|
43
|
-
console.log(' Run: snow-flow auth login');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
console.log('');
|
|
47
|
-
|
|
48
|
-
// Test 2: Check environment variables
|
|
49
|
-
console.log('Test 2: Checking environment variables...');
|
|
50
|
-
const envVars = [
|
|
51
|
-
'SERVICENOW_INSTANCE_URL',
|
|
52
|
-
'SERVICENOW_CLIENT_ID',
|
|
53
|
-
'SERVICENOW_CLIENT_SECRET',
|
|
54
|
-
'SERVICENOW_REFRESH_TOKEN',
|
|
55
|
-
'SNOW_INSTANCE',
|
|
56
|
-
'SNOW_CLIENT_ID',
|
|
57
|
-
'SNOW_CLIENT_SECRET',
|
|
58
|
-
'SNOW_REFRESH_TOKEN'
|
|
59
|
-
];
|
|
60
|
-
|
|
61
|
-
let hasEnvVars = false;
|
|
62
|
-
envVars.forEach(varName => {
|
|
63
|
-
const value = process.env[varName];
|
|
64
|
-
if (value && value.trim() !== '' && !value.includes('your-')) {
|
|
65
|
-
console.log(`✅ ${varName}: SET`);
|
|
66
|
-
hasEnvVars = true;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (!hasEnvVars) {
|
|
71
|
-
console.log('ℹ️ No environment variables set (this is OK if using auth.json)');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
console.log('');
|
|
75
|
-
|
|
76
|
-
// Test 3: Check .mcp.json
|
|
77
|
-
console.log('Test 3: Checking project .mcp.json...');
|
|
78
|
-
const mcpPath = path.join(process.cwd(), '.mcp.json');
|
|
79
|
-
|
|
80
|
-
if (fs.existsSync(mcpPath)) {
|
|
81
|
-
console.log('✅ .mcp.json exists');
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const mcpData = JSON.parse(fs.readFileSync(mcpPath, 'utf-8'));
|
|
85
|
-
const serversKey = mcpData.mcpServers ? 'mcpServers' : 'servers';
|
|
86
|
-
const server = mcpData[serversKey]?.['servicenow-unified'];
|
|
87
|
-
|
|
88
|
-
if (server) {
|
|
89
|
-
const envKey = server.environment !== undefined ? 'environment' : 'env';
|
|
90
|
-
const env = server[envKey];
|
|
91
|
-
|
|
92
|
-
if (env && env.SERVICENOW_INSTANCE_URL) {
|
|
93
|
-
console.log('✅ servicenow-unified server configured with credentials');
|
|
94
|
-
console.log(' Instance:', env.SERVICENOW_INSTANCE_URL);
|
|
95
|
-
} else {
|
|
96
|
-
console.log('⚠️ servicenow-unified server found but no credentials in env');
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
console.log('⚠️ No servicenow-unified server in .mcp.json');
|
|
100
|
-
}
|
|
101
|
-
} catch (error) {
|
|
102
|
-
console.log('❌ Failed to parse .mcp.json:', error.message);
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
console.log('ℹ️ .mcp.json not found (this is OK)');
|
|
106
|
-
console.log(' Run: snow-flow init (to create project config)');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
console.log('');
|
|
110
|
-
|
|
111
|
-
// Test 4: Check token cache
|
|
112
|
-
console.log('Test 4: Checking token cache...');
|
|
113
|
-
const tokenCachePath = path.join(os.homedir(), '.snow-flow', 'token-cache.json');
|
|
114
|
-
|
|
115
|
-
if (fs.existsSync(tokenCachePath)) {
|
|
116
|
-
console.log('✅ Token cache exists');
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const cacheData = JSON.parse(fs.readFileSync(tokenCachePath, 'utf-8'));
|
|
120
|
-
const instances = Object.keys(cacheData);
|
|
121
|
-
|
|
122
|
-
if (instances.length > 0) {
|
|
123
|
-
console.log(`✅ ${instances.length} instance(s) cached`);
|
|
124
|
-
instances.forEach(instance => {
|
|
125
|
-
const token = cacheData[instance];
|
|
126
|
-
const expiresIn = token.expiresAt - Date.now();
|
|
127
|
-
const isExpired = expiresIn <= 0;
|
|
128
|
-
|
|
129
|
-
console.log(` - ${instance}: ${isExpired ? '❌ EXPIRED' : '✅ Valid'} (expires in ${Math.round(expiresIn / 1000 / 60)} min)`);
|
|
130
|
-
});
|
|
131
|
-
} else {
|
|
132
|
-
console.log('ℹ️ Token cache empty (tokens will be fetched on first use)');
|
|
133
|
-
}
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.log('⚠️ Failed to parse token cache:', error.message);
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
console.log('ℹ️ No token cache yet (will be created on first API call)');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
console.log('');
|
|
142
|
-
|
|
143
|
-
// Summary
|
|
144
|
-
console.log('📊 Summary:');
|
|
145
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
146
|
-
|
|
147
|
-
const authJsonExists = fs.existsSync(authPath);
|
|
148
|
-
const hasMcpJson = fs.existsSync(mcpPath);
|
|
149
|
-
|
|
150
|
-
if (authJsonExists) {
|
|
151
|
-
console.log('✅ Authentication configured via auth.json');
|
|
152
|
-
console.log(' The MCP server will automatically use these credentials');
|
|
153
|
-
} else if (hasEnvVars) {
|
|
154
|
-
console.log('✅ Authentication configured via environment variables');
|
|
155
|
-
console.log(' The MCP server will use these credentials');
|
|
156
|
-
} else {
|
|
157
|
-
console.log('❌ No authentication configured');
|
|
158
|
-
console.log('');
|
|
159
|
-
console.log('To fix:');
|
|
160
|
-
console.log(' 1. Run: snow-flow auth login');
|
|
161
|
-
console.log(' 2. Or set environment variables manually');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
console.log('');
|
|
165
|
-
console.log('Authentication Priority:');
|
|
166
|
-
console.log(' 1. Environment variables (SERVICENOW_* or SNOW_*)');
|
|
167
|
-
console.log(' 2. snow-code auth.json (~/.local/share/snow-code/auth.json)');
|
|
168
|
-
console.log(' 3. Unauthenticated mode (tools will fail with auth errors)');
|
|
169
|
-
|
|
170
|
-
console.log('');
|
|
171
|
-
console.log('For detailed documentation, see: AUTH-FLOW.md');
|
|
172
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Test the ensureCorrectAuthLocation function
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require('fs').promises;
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const os = require('os');
|
|
10
|
-
|
|
11
|
-
async function ensureCorrectAuthLocation() {
|
|
12
|
-
try {
|
|
13
|
-
const correctPath = path.join(os.homedir(), '.local', 'share', 'snow-code', 'auth.json');
|
|
14
|
-
const incorrectPath = path.join(os.homedir(), '.local', 'share', 'snowcode', 'auth.json');
|
|
15
|
-
|
|
16
|
-
console.log('🔍 Checking auth.json location...');
|
|
17
|
-
console.log(' Correct path:', correctPath);
|
|
18
|
-
console.log(' Incorrect path:', incorrectPath);
|
|
19
|
-
console.log('');
|
|
20
|
-
|
|
21
|
-
// Check if file exists at incorrect location
|
|
22
|
-
try {
|
|
23
|
-
await fs.access(incorrectPath);
|
|
24
|
-
|
|
25
|
-
// File exists at wrong location - move it
|
|
26
|
-
console.log('❌ Found auth.json at incorrect location (snowcode/ without dash)');
|
|
27
|
-
console.log('📦 Moving to correct location (snow-code/ with dash)...');
|
|
28
|
-
|
|
29
|
-
// Ensure correct directory exists
|
|
30
|
-
const correctDir = path.dirname(correctPath);
|
|
31
|
-
await fs.mkdir(correctDir, { recursive: true });
|
|
32
|
-
|
|
33
|
-
// Copy file to correct location
|
|
34
|
-
await fs.copyFile(incorrectPath, correctPath);
|
|
35
|
-
console.log('✅ Copied auth.json to:', correctPath);
|
|
36
|
-
|
|
37
|
-
// Create symlink at old location for backwards compatibility
|
|
38
|
-
try {
|
|
39
|
-
const incorrectDir = path.dirname(incorrectPath);
|
|
40
|
-
await fs.mkdir(incorrectDir, { recursive: true });
|
|
41
|
-
|
|
42
|
-
// Remove old file after successful copy
|
|
43
|
-
await fs.unlink(incorrectPath);
|
|
44
|
-
console.log('🗑️ Removed old file from incorrect location');
|
|
45
|
-
|
|
46
|
-
// Create symlink
|
|
47
|
-
await fs.symlink(correctPath, incorrectPath);
|
|
48
|
-
console.log('🔗 Created symlink for backwards compatibility');
|
|
49
|
-
} catch (symlinkError) {
|
|
50
|
-
console.warn('⚠️ Could not create symlink:', symlinkError.message);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
console.log('');
|
|
54
|
-
console.log('✅ Auth credentials stored at correct location!');
|
|
55
|
-
return true;
|
|
56
|
-
} catch (err) {
|
|
57
|
-
if (err.code === 'ENOENT') {
|
|
58
|
-
// File doesn't exist at incorrect location - check if it's already at correct location
|
|
59
|
-
try {
|
|
60
|
-
await fs.access(correctPath);
|
|
61
|
-
console.log('✅ Auth.json already at correct location');
|
|
62
|
-
return true;
|
|
63
|
-
} catch {
|
|
64
|
-
console.log('ℹ️ Auth.json not found at either location');
|
|
65
|
-
console.log(' (It will be created on next auth)');
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
throw err;
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error('❌ Failed:', error.message);
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Run the test
|
|
78
|
-
ensureCorrectAuthLocation().then(success => {
|
|
79
|
-
console.log('');
|
|
80
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
81
|
-
console.log('Test result:', success ? '✅ PASSED' : '❌ FAILED');
|
|
82
|
-
console.log('═══════════════════════════════════════════════════════════');
|
|
83
|
-
process.exit(success ? 0 : 1);
|
|
84
|
-
});
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Manual MCP Server Test - Start server and test basic communication
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
var { spawn } = require('child_process');
|
|
8
|
-
var path = require('path');
|
|
9
|
-
var os = require('os');
|
|
10
|
-
var fs = require('fs');
|
|
11
|
-
|
|
12
|
-
console.log('\n🧪 Manual MCP Server Test\n');
|
|
13
|
-
console.log('='.repeat(80));
|
|
14
|
-
|
|
15
|
-
// Load config
|
|
16
|
-
var configPath = path.join(os.homedir(), '.snowcode', 'snowcode.json');
|
|
17
|
-
var config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
18
|
-
|
|
19
|
-
var serverConfig = config.mcp['servicenow-unified'];
|
|
20
|
-
|
|
21
|
-
console.log('📋 Server Configuration:');
|
|
22
|
-
console.log(' Type: ' + serverConfig.type);
|
|
23
|
-
console.log(' Command: ' + serverConfig.command.join(' '));
|
|
24
|
-
console.log(' Environment variables: ' + Object.keys(serverConfig.environment || {}).length);
|
|
25
|
-
console.log('');
|
|
26
|
-
|
|
27
|
-
// Prepare environment
|
|
28
|
-
var env = Object.assign({}, process.env, serverConfig.environment || {});
|
|
29
|
-
|
|
30
|
-
// Check if credentials are set
|
|
31
|
-
console.log('🔐 Checking credentials:');
|
|
32
|
-
console.log(' SERVICENOW_INSTANCE_URL: ' + (env.SERVICENOW_INSTANCE_URL ? '✅ SET' : '❌ NOT SET'));
|
|
33
|
-
console.log(' SERVICENOW_CLIENT_ID: ' + (env.SERVICENOW_CLIENT_ID ? '✅ SET' : '❌ NOT SET'));
|
|
34
|
-
console.log(' SERVICENOW_CLIENT_SECRET: ' + (env.SERVICENOW_CLIENT_SECRET ? '✅ SET (' + env.SERVICENOW_CLIENT_SECRET.length + ' chars)' : '❌ NOT SET'));
|
|
35
|
-
console.log('');
|
|
36
|
-
|
|
37
|
-
if (!env.SERVICENOW_INSTANCE_URL || !env.SERVICENOW_CLIENT_ID || !env.SERVICENOW_CLIENT_SECRET) {
|
|
38
|
-
console.log('❌ Missing credentials! Run: snow-flow auth login');
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
console.log('🚀 Starting MCP server...');
|
|
43
|
-
console.log(' Command: ' + serverConfig.command[0] + ' ' + serverConfig.command.slice(1).join(' '));
|
|
44
|
-
console.log('');
|
|
45
|
-
|
|
46
|
-
// Start server
|
|
47
|
-
var serverProcess = spawn(serverConfig.command[0], serverConfig.command.slice(1), {
|
|
48
|
-
env: env,
|
|
49
|
-
stdio: ['pipe', 'pipe', 'pipe']
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
var output = '';
|
|
53
|
-
var errorOutput = '';
|
|
54
|
-
var serverStarted = false;
|
|
55
|
-
|
|
56
|
-
serverProcess.stdout.on('data', function(data) {
|
|
57
|
-
var text = data.toString();
|
|
58
|
-
output += text;
|
|
59
|
-
|
|
60
|
-
// Check for successful startup messages
|
|
61
|
-
if (text.includes('MCP server running') || text.includes('Server started') || text.includes('Listening')) {
|
|
62
|
-
serverStarted = true;
|
|
63
|
-
console.log('✅ Server started successfully!');
|
|
64
|
-
console.log('');
|
|
65
|
-
console.log('📊 Server Output:');
|
|
66
|
-
console.log(output);
|
|
67
|
-
|
|
68
|
-
// Kill server after success
|
|
69
|
-
setTimeout(function() {
|
|
70
|
-
console.log('\n✅ Test passed - MCP server can start successfully');
|
|
71
|
-
console.log('');
|
|
72
|
-
console.log('🔍 DIAGNOSIS:');
|
|
73
|
-
console.log(' The MCP server works correctly when started manually.');
|
|
74
|
-
console.log(' The issue is that SnowCode is NOT starting it automatically.');
|
|
75
|
-
console.log('');
|
|
76
|
-
console.log('💡 SOLUTION NEEDED:');
|
|
77
|
-
console.log(' 1. Check if SnowCode (OpenCode v0.15.14) supports MCP auto-start');
|
|
78
|
-
console.log(' 2. Verify SnowCode is reading ~/.snowcode/snowcode.json on startup');
|
|
79
|
-
console.log(' 3. Check SnowCode logs for MCP startup errors');
|
|
80
|
-
console.log(' 4. Possible SnowCode bug - MCP servers may need manual start');
|
|
81
|
-
console.log('');
|
|
82
|
-
console.log('📝 Temporary workaround:');
|
|
83
|
-
console.log(' Start MCP server manually in background:');
|
|
84
|
-
console.log(' ' + serverConfig.command.join(' ') + ' &');
|
|
85
|
-
console.log('');
|
|
86
|
-
|
|
87
|
-
serverProcess.kill();
|
|
88
|
-
process.exit(0);
|
|
89
|
-
}, 2000);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
serverProcess.stderr.on('data', function(data) {
|
|
94
|
-
errorOutput += data.toString();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
serverProcess.on('error', function(error) {
|
|
98
|
-
console.log('❌ Failed to start server:');
|
|
99
|
-
console.log(error);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
serverProcess.on('close', function(code) {
|
|
104
|
-
if (!serverStarted) {
|
|
105
|
-
console.log('❌ Server exited prematurely (code: ' + code + ')');
|
|
106
|
-
console.log('');
|
|
107
|
-
if (output) {
|
|
108
|
-
console.log('📤 STDOUT:');
|
|
109
|
-
console.log(output);
|
|
110
|
-
}
|
|
111
|
-
if (errorOutput) {
|
|
112
|
-
console.log('📥 STDERR:');
|
|
113
|
-
console.log(errorOutput);
|
|
114
|
-
}
|
|
115
|
-
console.log('');
|
|
116
|
-
console.log('💡 Check if:');
|
|
117
|
-
console.log(' 1. Node.js version is compatible (requires Node 18+)');
|
|
118
|
-
console.log(' 2. All npm dependencies are installed');
|
|
119
|
-
console.log(' 3. ServiceNow credentials are valid');
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// Timeout after 5 seconds
|
|
125
|
-
setTimeout(function() {
|
|
126
|
-
if (!serverStarted) {
|
|
127
|
-
console.log('⏱️ Server did not start within 5 seconds');
|
|
128
|
-
console.log('');
|
|
129
|
-
if (output) {
|
|
130
|
-
console.log('📤 STDOUT so far:');
|
|
131
|
-
console.log(output);
|
|
132
|
-
}
|
|
133
|
-
if (errorOutput) {
|
|
134
|
-
console.log('📥 STDERR:');
|
|
135
|
-
console.log(errorOutput);
|
|
136
|
-
}
|
|
137
|
-
serverProcess.kill();
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
}, 5000);
|