auth_status
Check current authentication status for FreshBooks integration to verify OAuth2 connection before using accounting, invoicing, and financial tools.
Instructions
Check current FreshBooks authentication status
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:183-194 (handler)MCP tool handler for 'auth_status' that calls oauth.getStatus() and formats response as MCP content.private async handleAuthStatus() { const status = await this.oauth.getStatus(); return { content: [ { type: 'text', text: JSON.stringify(status, null, 2), }, ], }; }
- src/server.ts:82-89 (registration)Tool registration in ListTools handler, defining name, description, and empty input schema.{ name: 'auth_status', description: 'Check current FreshBooks authentication status', inputSchema: { type: 'object', properties: {}, }, },
- src/auth/types.ts:50-68 (schema)Output schema/type definition for auth_status response.export interface AuthStatus { /** Whether currently authenticated with valid token */ authenticated: boolean; /** Seconds until token expires (if authenticated) */ expiresIn?: number; /** Active account ID (if authenticated) */ accountId?: string; /** Active business ID (if authenticated) */ businessId?: number; /** Reason for not being authenticated (if not authenticated) */ reason?: 'no_token' | 'token_expired' | 'invalid_token'; /** Whether a refresh token is available to restore session */ canRefresh?: boolean; }
- src/auth/oauth.ts:279-314 (helper)Core logic for computing authentication status from token store, used by the tool handler.async getStatus(): Promise<AuthStatus> { const token = await this.tokenStore.get(); if (!token) { return { authenticated: false, reason: 'no_token', }; } const now = Math.floor(Date.now() / 1000); const expiresIn = token.expiresAt - now; if (expiresIn <= 0) { return { authenticated: false, reason: 'token_expired', canRefresh: !!token.refreshToken, }; } const status: AuthStatus = { authenticated: true, expiresIn, }; if (token.accountId) { status.accountId = token.accountId; } if (token.businessId !== undefined) { status.businessId = token.businessId; } return status; }