Skip to main content
Glama

auth_exchange_code

Exchange an OAuth authorization code for access and refresh tokens to finish connecting FreshBooks. Call once with the code and state from the redirect to store credentials and enable API access.

Instructions

Exchange an OAuth authorization code for access and refresh tokens, completing the FreshBooks connection.

WHEN TO USE:

  • Immediately after the user visits the auth_get_url link and is redirected with a code

  • Only call once per code — codes expire quickly (typically 60 seconds)

REQUIRED:

  • code (string): The authorization code from the FreshBooks redirect URL. Example: "eyJhbGci..."

  • state (string): The state value returned by auth_get_url — must match to prevent CSRF. Example: "abc123xyz"

RETURNS: { success: true, userId, accountId, businessId, email, expiresAt } Tokens are stored locally; all subsequent tool calls use them automatically.

ERRORS:

  • Expired or invalid code → restart with auth_get_url

  • State mismatch → CSRF protection triggered → restart with auth_get_url

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesAuthorization code from the FreshBooks OAuth redirect URL. Example: "eyJhbGci..."
stateYesCSRF state token returned by auth_get_url; must match the value from that call. Example: "abc123xyz"
Behavior5/5

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

With no annotations present, the description carries the full behavioral burden, and it handles this well. It discloses that tokens are stored locally, that subsequent tool calls use them automatically, that codes are single-use and time-limited, that state mismatches trigger CSRF protection, and that expired/invalid codes require restarting with auth_get_url.

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?

The description is organized into short, scannable sections — WHEN TO USE, REQUIRED, RETURNS, ERRORS — and every section contributes necessary information. The core purpose is front-loaded before details, and there is no filler or repetition beyond useful emphasis.

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?

For a two-parameter tool with no output schema and no annotations, the description is complete: it explains the trigger event, inputs, return shape, side effects, error cases, and recovery path. An agent has everything needed to decide when to call this tool and what to do afterward.

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

Parameters3/5

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

The input schema already provides strong descriptions for both parameters, including examples and the CSRF-matching requirement, so schema coverage is 100%. The description mostly restates this information rather than adding new parameter-level meaning, which matches the baseline of 3 for high schema coverage.

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?

The description opens with a specific verb and resource — "Exchange an OAuth authorization code for access and refresh tokens, completing the FreshBooks connection." This clearly distinguishes the tool from siblings like auth_get_url (which creates the auth URL) and auth_revoke (which revokes access). The purpose is unambiguous.

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

Usage Guidelines4/5

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

The description gives strong context: use it immediately after auth_get_url returns a redirect code, and call it only once because codes expire quickly. It does not explicitly name alternatives or state when NOT to use it, but the timing and sequencing guidance make the correct invocation context clear.

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

Install Server

Other 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/Good-Samaritan-Software-LLC/freshbooks-mcp'

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