We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mansanitizer/fabits-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
test-portfolio.jsโข2.68 kB
#!/usr/bin/env node
/**
* Test script for portfolio API integration
* Run this to test the getPortfolio function with real API calls
*
* Usage: npm run build && node scripts/test-portfolio.js
*/
import { TokenManager } from '../build/auth.js';
import { getPortfolio } from '../build/portfolio.js';
async function testPortfolio() {
console.log('๐งช Testing Portfolio API Integration\n');
try {
// Load token manager
console.log('๐ Loading authentication tokens...');
const tokenManager = new TokenManager();
// Check if user is authenticated
const tokens = await tokenManager.loadToken();
if (!tokens || !tokens.token) {
console.error('โ No authentication tokens found!');
console.log('\n๐ก Please authenticate first using the MCP server:');
console.log(' 1. Start the MCP server: npm run start');
console.log(' 2. Use fabits_request_otp to request OTP');
console.log(' 3. Use fabits_verify_otp to login\n');
process.exit(1);
}
console.log('โ Tokens loaded successfully!');
console.log(` Phone: ${tokens.phoneNumber}`);
console.log(` Client Code: ${tokens.clientCode || 'N/A'}`);
console.log(` Access Token: ${tokens.token.substring(0, 20)}...`);
console.log(` Refresh Token: ${tokens.refreshToken?.substring(0, 20)}...\n`);
// Test getPortfolio
console.log('๐ Fetching portfolio with real API call...\n');
console.log('='.repeat(60));
const result = await getPortfolio(tokenManager);
console.log('\n' + '='.repeat(60));
console.log('๐ PORTFOLIO RESULT');
console.log('='.repeat(60) + '\n');
console.log(result);
console.log('\n' + '='.repeat(60));
console.log('\nโ Portfolio API integration test PASSED!');
console.log('\nThe portfolio function successfully:');
console.log(' โ Authenticated with bearer token');
console.log(' โ Made real API call to holdings endpoint');
console.log(' โ Parsed and processed the response');
console.log(' โ Returned formatted portfolio data\n');
} catch (error) {
console.error('\nโ Error during portfolio test:');
if (error instanceof Error) {
console.error(` ${error.message}`);
if (error.stack) {
console.error('\n๐ Stack trace:');
console.error(error.stack);
}
} else {
console.error(error);
}
process.exit(1);
}
}
// Run the test
testPortfolio();