#!/usr/bin/env node
const axios = require('axios');
const https = require('https');
const axiosInstance = axios.create({
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
timeout: 30000
});
const MCP_BASE = 'https://portland-writes-pale-colours.trycloudflare.com';
async function checkAccountsData() {
console.log('\n════════════════════════════════════════════════════════════');
console.log(' 🔍 CHECKING ACCOUNTS DATA STRUCTURE');
console.log('════════════════════════════════════════════════════════════\n');
try {
// OAuth Authentication to get token
console.log('1️⃣ Getting OAuth token...');
const metadataResponse = await axiosInstance.get(`${MCP_BASE}/.well-known/oauth-authorization-server`);
const registerResponse = await axiosInstance.post(`${MCP_BASE}/register`, {
client_name: "Claude Desktop",
grant_types: ["authorization_code", "refresh_token"],
response_types: ["code"],
token_endpoint_auth_method: "client_secret_post",
scope: "claudeai",
redirect_uris: ["https://claude.ai/api/mcp/auth_callback"]
});
const clientId = registerResponse.data.client_id;
const loginResponse = await axiosInstance.post(`${MCP_BASE}/login`,
'username=david%2Ballcloud%40umbrellacost.com&password=Dsamsung1%21123&state=test&client_id=' + clientId,
{
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
maxRedirects: 0,
validateStatus: (status) => status === 302
}
);
const cookies = loginResponse.headers['set-cookie'];
const sidCookie = cookies?.find(c => c.startsWith('sid='));
const sid = sidCookie?.split(';')[0].split('=')[1];
const crypto = require('crypto');
const codeVerifier = crypto.randomBytes(32).toString('base64url');
const codeChallenge = crypto.createHash('sha256').update(codeVerifier).digest('base64url');
const authResponse = await axiosInstance.get(`${MCP_BASE}/authorize`, {
params: {
response_type: 'code',
client_id: clientId,
redirect_uri: 'https://claude.ai/api/mcp/auth_callback',
state: 'test-state',
code_challenge: codeChallenge,
code_challenge_method: 'S256'
},
headers: { 'Cookie': `sid=${sid}` }
});
const codeMatch = authResponse.data.match(/code=([^&\"]+)/);
const authCode = codeMatch ? codeMatch[1] : null;
const tokenResponse = await axiosInstance.post(`${MCP_BASE}/oauth/token`,
new URLSearchParams({
grant_type: 'authorization_code',
code: authCode,
redirect_uri: 'https://claude.ai/api/mcp/auth_callback',
client_id: clientId,
code_verifier: codeVerifier
}).toString(),
{
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}
);
const accessToken = tokenResponse.data.access_token;
const apikey = tokenResponse.data.apikey;
console.log('✅ Got OAuth token and apikey\n');
// Now fetch accounts data directly
console.log('2️⃣ Fetching accounts data...');
const accountsResponse = await axiosInstance.get('https://api.umbrellacost.io/api/v1/accounts', {
headers: {
'Authorization': accessToken,
'apikey': apikey
}
});
console.log('✅ Accounts data fetched\n');
console.log('3️⃣ Looking for Bank Leumi account (22676)...\n');
const accounts = accountsResponse.data;
// Find Bank Leumi account
const bankLeumiAccount = accounts.find(acc => {
const accountKey = acc.accountKey || acc.account_key || acc.accountId || acc.account_id;
return String(accountKey) === '22676';
});
if (bankLeumiAccount) {
console.log('✅ Found Bank Leumi account:');
console.log('─────────────────────────────────────────────────────');
console.log(JSON.stringify(bankLeumiAccount, null, 2));
console.log('─────────────────────────────────────────────────────\n');
// Check what division info is available
console.log('📊 Division Information:');
console.log(` divisionId field: ${bankLeumiAccount.divisionId || 'NOT FOUND'}`);
console.log(` division_id field: ${bankLeumiAccount.division_id || 'NOT FOUND'}`);
console.log(` customerDivisionId field: ${bankLeumiAccount.customerDivisionId || 'NOT FOUND'}`);
console.log(` customer_division_id field: ${bankLeumiAccount.customer_division_id || 'NOT FOUND'}`);
// Check for any field containing "139"
const fieldsWithDivision = Object.keys(bankLeumiAccount).filter(key => {
const value = bankLeumiAccount[key];
return value && String(value).includes('139');
});
if (fieldsWithDivision.length > 0) {
console.log(`\n ✅ Fields containing "139": ${fieldsWithDivision.join(', ')}`);
} else {
console.log('\n ⚠️ No fields containing "139" found in account data');
}
} else {
console.log('❌ Bank Leumi account (22676) not found in accounts data');
}
// Also show all account keys for reference
console.log('\n4️⃣ All available accounts:');
console.log('─────────────────────────────────────────────────────');
accounts.forEach(acc => {
const accountKey = acc.accountKey || acc.account_key || acc.accountId || acc.account_id;
const accountName = acc.accountName || acc.account_name || acc.name || '';
console.log(` ${accountKey}: ${accountName}`);
});
} catch (error) {
console.error('\n❌ Error:', error.message);
if (error.response) {
console.error('Status:', error.response.status);
console.error('Response:', JSON.stringify(error.response.data, null, 2));
}
}
}
checkAccountsData().catch(console.error);