Skip to main content
Glama

Generate-Session

Generate a new session token for automated stock trading on the Zerodha platform, enabling seamless integration with the Node.js-based trading bot for advanced operations like buy/sell actions and portfolio management.

Instructions

Generate a new session token using request token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • index.js:54-63 (handler)
    Handler function for the 'Generate-Session' MCP tool. It calls tokenManager.generateSession with the requestToken and returns a success or error message in the MCP response format.
    async ({ requestToken }) => { try { const response = await tokenManager.generateSession(requestToken); return { content: [{ type: "text", text: "Session generated successfully" }], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } }
  • index.js:50-64 (registration)
    Registration of the 'Generate-Session' tool on the MCP server, including name, description, input schema, and handler.
    server.tool( "Generate-Session", "Generate a new session token using request token", { requestToken: z.string() }, async ({ requestToken }) => { try { const response = await tokenManager.generateSession(requestToken); return { content: [{ type: "text", text: "Session generated successfully" }], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } );
  • Input schema for the Generate-Session tool using Zod: requires a string requestToken.
    { requestToken: z.string() },
  • Core implementation of session generation in TokenManager class using KiteConnect API, saves the access token to file, and handles errors.
    async generateSession(requestToken) { try { const response = await this.kc.generateSession( requestToken, this.apiSecret ); await this.saveToken(response); return response; } catch (error) { throw new Error(`Error generating session: ${error.message}`); } }

Other Tools

Related Tools

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/yogendhra9/ZerodhaMCP'

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