Skip to main content
Glama
PasinduGunarathne

wso2-bi-salesforce-mcp-server

Exchange Salesforce OAuth2 Authorization Code for Tokens

sf_exchange_oauth_code

Exchanges an OAuth2 authorization code for a refresh token and instance URL, enabling persistent Salesforce API access without handling short-lived access tokens directly.

Instructions

Exchanges an OAuth2 authorization code for tokens. Set sandbox=true if the code was obtained from test.salesforce.com.

Returns the refresh_token (save this — it's long-lived!) and instance_url. The short-lived access_token is intentionally masked in the output to keep it out of MCP transcripts; you don't need it directly — pass refresh_token to the other tools and they obtain fresh access tokens on demand.

Error Handling:

  • "invalid_grant": code expired or already used — re-run sf_get_oauth_auth_url

  • "invalid_client": wrong client_id / client_secret (or Connected App still activating; wait 2-10 min after creating it)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sf_client_idYesSalesforce Connected App Consumer Key (Client ID)
sf_client_secretYesSalesforce Connected App Consumer Secret (Client Secret)
codeYesAuthorization code from the OAuth redirect
redirect_uriNoSame redirect URI used when generating the auth URLhttps://login.salesforce.com/services/oauth2/success
sandboxNoExchange against test.salesforce.com (sandbox) instead of login.salesforce.com
Behavior5/5

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

Annotations provide readOnlyHint=false, destructiveHint=false, idempotentHint=false, openWorldHint=true. The description goes beyond annotations by disclosing that the access_token is masked in output (keeping it out of transcripts) and that refresh_token is long-lived. Error scenarios are detailed with actionable advice. No contradiction with annotations.

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 succinct with no superfluous text. Key sections are clearly separated: main action, parameter note, output details, error handling. Every sentence contributes essential information.

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?

Given the complexity of OAuth token exchange, the description adequately covers the purpose, all parameters, return values (refresh_token, instance_url), behavior (access_token masked), and error cases. No output schema exists, but the description compensates. The agent can confidently use this tool.

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%, but the description adds meaning: it clarifies the sandbox parameter's effect (test.salesforce.com vs login.salesforce.com), implies that redirect_uri must match the one used previously, and explains that the code comes from the OAuth redirect. This enriches the bare schema descriptions.

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 clearly states the tool exchanges an OAuth2 authorization code for tokens, distinguishing it from sibling tools like sf_get_oauth_auth_url and sf_get_token_password_flow. The verb 'exchange' and resource 'authorization code' are specific and 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 explains when to use it (after obtaining the code) and provides error-specific guidance (e.g., re-run sf_get_oauth_auth_url for invalid_grant). It also mentions the sandbox parameter. However, it does not explicitly contrast with the password flow or other authentication tools, leaving some implicit use-case differentiation.

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/PasinduGunarathne/wso2-bi-salesforce-mcp-server'

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