Skip to main content
Glama
ssonthal

Zerodha Trading Bot - MCP Server

by ssonthal
test.js2.13 kB
import { ZerodhaClient } from '../src/zerodha-client.js'; import dotenv from 'dotenv'; dotenv.config(); async function testZerodhaClient() { console.log('Testing Zerodha Client...\n'); const client = new ZerodhaClient( process.env.ZERODHA_API_KEY, process.env.ZERODHA_API_SECRET, process.env.ZERODHA_REDIRECT_URI ); try { // Test 1: Get login URL console.log('1. Testing login URL generation...'); const loginURL = client.getLoginURL(); console.log('Login URL:', loginURL); console.log('✅ Login URL generated successfully\n'); // Test 2: If access token is provided, test API calls if (process.env.ZERODHA_ACCESS_TOKEN) { console.log('2. Testing with access token...'); client.setAccessToken(process.env.ZERODHA_ACCESS_TOKEN); // Test user profile console.log(' Getting user profile...'); const profile = await client.getUserProfile(); console.log(' User Profile:', JSON.stringify(profile, null, 2)); // Test holdings console.log('\n Getting holdings...'); const holdings = await client.getHoldings(); console.log(' Holdings:', JSON.stringify(holdings, null, 2)); // Test positions console.log('\n Getting positions...'); const positions = await client.getPositions(); console.log(' Positions:', JSON.stringify(positions, null, 2)); // Test margins console.log('\n Getting margins...'); const margins = await client.getMargins(); console.log(' Margins:', JSON.stringify(margins, null, 2)); // Test token validation console.log('\n Validating token...'); const isValid = await client.validateToken(); console.log(' Token valid:', isValid); console.log('\n✅ All API tests completed successfully!'); } else { console.log('2. No access token provided. Set ZERODHA_ACCESS_TOKEN in .env to test API calls.'); console.log(' Run the auth server first: node src/auth-server.js'); } } catch (error) { console.error('❌ Test failed:', error.message); } } // Run tests testZerodhaClient();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ssonthal/ZerodhaTradingBot-MCPServer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server