#!/usr/bin/env node
const axios = require('axios');
const https = require('https');
const crypto = require('crypto');
// Create axios instance with SSL bypass for development
const axiosInstance = axios.create({
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
timeout: 30000
});
const USERNAME = "david+saola@umbrellacost.com";
const PASSWORD = "Dsamsung1!";
const MCP_BASE = "https://ace-block-concrete-fighting.trycloudflare.com";
async function listAvailableTools() {
try {
// 1. Get OAuth metadata
console.log('Authenticating...');
const metadataResponse = await axiosInstance.get(`${MCP_BASE}/.well-known/oauth-authorization-server`);
// 2. Register client
const registerResponse = await axiosInstance.post(`${MCP_BASE}/register`, {
client_name: "List Tools Client",
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;
// 3. Login to get session
const loginResponse = await axiosInstance.post(`${MCP_BASE}/login`,
`username=${encodeURIComponent(USERNAME)}&password=${encodeURIComponent(PASSWORD)}&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];
// 4. Get authorization code with PKCE
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;
// 5. Exchange code for access token
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;
console.log('✅ Authenticated\n');
// 6. Initialize MCP session and get tools
console.log('Initializing MCP session...');
const initResponse = await axiosInstance.post(`${MCP_BASE}/mcp`, {
method: "initialize",
params: {
protocolVersion: "2025-06-18",
capabilities: {},
clientInfo: { name: "list-tools", version: "1.0.0" }
},
jsonrpc: "2.0",
id: 0
}, {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream'
}
});
// Parse response
let result;
if (typeof initResponse.data === 'string' && initResponse.data.includes('event: message')) {
const dataMatch = initResponse.data.match(/data: ({.*})/);
if (dataMatch) result = JSON.parse(dataMatch[1]);
} else {
result = initResponse.data;
}
if (result?.result?.tools) {
console.log('\n📦 AVAILABLE MCP TOOLS:\n');
console.log('========================\n');
result.result.tools.forEach((tool, index) => {
console.log(`${index + 1}. ${tool.name}`);
console.log(` Description: ${tool.description || 'N/A'}`);
if (tool.inputSchema?.properties) {
console.log(` Parameters: ${Object.keys(tool.inputSchema.properties).join(', ')}`);
}
console.log();
});
console.log(`\nTotal tools: ${result.result.tools.length}`);
} else {
console.log('No tools found in response');
console.log('Full response:', JSON.stringify(result, null, 2));
}
} catch (error) {
console.error(`\n❌ Error: ${error.message}`);
if (error.response) {
console.error('Response:', error.response.data);
}
}
}
listAvailableTools().catch(console.error);