Skip to main content
Glama

check_auth_status

Verify authentication status and retrieve active access token details for DhanHQ trading API access.

Instructions

Checks the current authentication status and returns details about the active access token if available.

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "required": [], "type": "object" }

Implementation Reference

  • The handler function for the 'check_auth_status' tool. It fetches the current authentication state, access token, and validity check, then constructs and returns a formatted status object as MCP tool response.
    case 'check_auth_status': { console.error('[Tool] Executing: check_auth_status'); const authState = getAuthState(); const accessToken = getAccessToken(); const tokenValid = isTokenValid(); const status = { authenticated: !!authState.authToken, hasValidToken: tokenValid, accessToken: accessToken ? '***REDACTED***' : null, authState: { consentAppId: authState.consentAppId || null, consentAppStatus: authState.consentAppStatus || null, tokenId: authState.tokenId ? '***REDACTED***' : null, clientInfo: authState.authToken ? { dhanClientId: authState.authToken.dhanClientId, dhanClientName: authState.authToken.dhanClientName, dhanClientUcc: authState.authToken.dhanClientUcc, expiryTime: authState.authToken.expiryTime, givenPowerOfAttorney: authState.authToken.givenPowerOfAttorney, generatedAt: authState.authToken.generatedAt, } : null, }, }; return { content: [ { type: 'text' as const, text: JSON.stringify(status, null, 2), }, ], }; }
  • The schema definition for the 'check_auth_status' tool, including name, description, and empty input schema (no parameters required). This is part of the tools array used for MCP listTools response.
    { name: 'check_auth_status', description: 'Checks the current authentication status and returns details about the active access token if available.', inputSchema: { type: 'object' as const, properties: {}, required: [], }, },
  • Helper function to retrieve the current in-memory authentication state object.
    export function getAuthState(): AuthState { return authState; }
  • Helper function that returns the current access token if it exists and is not expired.
    export function getAccessToken(): string | null { if (!authState.authToken) { return null; } const expiryTime = new Date(authState.authToken.expiryTime); if (new Date() > expiryTime) { log('Access token has expired'); return null; } return authState.authToken.accessToken; }
  • Helper function that checks if the stored auth token is still valid (not expired).
    export function isTokenValid(): boolean { if (!authState.authToken) { return false; } const expiryTime = new Date(authState.authToken.expiryTime); return new Date() < expiryTime; }

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/harshitdynamite/DhanMCP'

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