Get Google Health OAuth URL
google_health_get_auth_urlGenerate a Google OAuth authorization URL to obtain user consent for accessing Google Health API data when no local token exists.
Instructions
Generate a Google OAuth authorization URL for Google Health API. Use this first when no local token exists.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| state | No | Optional OAuth state value generated by the caller. | |
| scopes | No | Optional scope override. Defaults to read-only Google Health scopes used by this server. | |
| response_format | No | markdown |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| auth_url | Yes | ||
| redirect_uri | Yes | ||
| scopes | Yes | ||
| next_step | Yes |
Implementation Reference
- src/tools/google-health-tools.ts:89-109 (handler)The tool handler registered as 'google_health_get_auth_url'. It calls GoogleHealthClient.authUrl() with optional state and scopes, then returns the OAuth URL, redirect URI, scopes, and next_step instructions.
server.registerTool("google_health_get_auth_url", { title: "Get Google Health OAuth URL", description: "Generate a Google OAuth authorization URL for Google Health API. Use this first when no local token exists.", inputSchema: AuthUrlInputSchema.shape, outputSchema: AuthUrlOutputSchema.shape, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false } }, async (params) => { try { const config = getConfig(); const url = new GoogleHealthClient(config).authUrl(params.state, params.scopes); const output = { auth_url: url, redirect_uri: config.redirectUri, scopes: params.scopes?.length ? params.scopes : config.scopes, next_step: "Open auth_url, approve access, then pass the returned code or full redirect URL to google_health_exchange_code." }; return makeResponse(output, params.response_format, bulletList("Google Health OAuth URL", output)); } catch (error) { return makeError((error as Error).message); } }); - src/schemas/common.ts:37-41 (schema)AuthUrlInputSchema defines the input: optional state (string max 500), optional scopes (array of strings), and response_format.
export const AuthUrlInputSchema = z.object({ state: z.string().max(500).optional().describe("Optional OAuth state value generated by the caller."), scopes: z.array(z.string()).optional().describe("Optional scope override. Defaults to read-only Google Health scopes used by this server."), response_format: ResponseFormatSchema }).strict(); - src/schemas/common.ts:122-127 (schema)AuthUrlOutputSchema defines the output: auth_url (string), redirect_uri (string), scopes (string array), and next_step (string).
export const AuthUrlOutputSchema = z.object({ auth_url: z.string(), redirect_uri: z.string(), scopes: z.array(z.string()), next_step: z.string() }).strict(); - GoogleHealthClient.authUrl() builds the OAuth authorization URL using GOOGLE_HEALTH_AUTH_URL constant, config client_id/redirect_uri, optional state, and scopes.
authUrl(state?: string, scopes?: string[]): string { const params = new URLSearchParams({ client_id: this.config.clientId, redirect_uri: this.config.redirectUri, response_type: "code", scope: (scopes?.length ? scopes : this.config.scopes).join(" "), access_type: "offline", include_granted_scopes: "true", prompt: "consent" }); if (state) params.set("state", state); return `${GOOGLE_HEALTH_AUTH_URL}?${params.toString()}`; } - src/services/agent-manifest.ts:24-24 (registration)The tool name is listed in STANDARD_TOOLS array used for agent manifest generation.
"google_health_get_auth_url",