Skip to main content
Glama

Exchange Alza OAuth code

auth_exchange

Exchange the OAuth 2.0 PKCE authorization code from the browser sign-in for Alza mobile API tokens, then load them into the server so account tools work.

Instructions

Complete the OAuth 2.0 PKCE sign-in: exchange the authorization code for mobile API tokens and load them into this server. Use immediately after the user finishes the auth_start flow in the browser. Pass the whole alza://identity?code=...&state=... redirect URL as code (state is then read from it), or the bare code plus state — never a password and never a refresh token here. Fails if the state does not match a pending auth_start session (start over from auth_start in that case). Side effect: replaces the token set currently loaded in this process; afterwards account tools such as cart, profile, and order are authenticated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesAuthorization code from the `alza://identity` redirect (the `code` query parameter), or the full redirect URL.
stateNoState value returned by `auth_start`; must match the pending PKCE session exactly. Optional when `code` is the full redirect URL.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errNo
msgNo
dataNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the annotations by disclosing a real side effect ('replaces the token set currently loaded in this process'), the failure condition ('fails if the state does not match a pending `auth_start` session'), and the downstream consequence that account tools like `cart`, `profile`, and `order` become authenticated. The annotations only cover the generic write/open-world/idempotency profile, so this added context is substantial.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the action, then sequencing, then parameter contract, then failure mode, then side effect. Every sentence carries distinct information with no filler despite the length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained; the description still covers the prerequisites, failure handling, and post-call state change. Nothing an agent needs to invoke this correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real semantics: `code` may be the full `alza://identity?...` redirect URL (in which case state is parsed from it) or the bare code, and it explicitly forbids passing a password or refresh token. This clarifies the dual-mode contract better than the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Complete the OAuth 2.0 PKCE sign-in: exchange the authorization code for mobile API tokens') and clearly distinguishes itself from the sibling `auth_start` by positioning itself as the step that follows it. An agent can tell this apart from `auth_discovery`/`auth_start` without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says when to use it ('immediately after the user finishes the `auth_start` flow in the browser') and gives exclusions ('never a password and never a refresh token here'). It also names the recovery path when it fails ('start over from `auth_start`'), which is exactly the alternative routing an agent needs.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.