Skip to content

Commit bc1667c

Browse files
Make custom connection scopes configurable (#136)
* Make custom connections scopes configurable * update README
1 parent 636ea26 commit bc1667c

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Custom connections require different scopes depending on when they were created.
5757
| After Apr 27, 2026 | [SCOPES_V2](src/clients/xero-client.ts#L93-L112) (granular permissions) |
5858

5959
> **Note:** The MCP server automatically tries V1 scopes first and falls back to V2 if needed.
60+
>
61+
> You can override these by setting the `XERO_SCOPES` environment variable to a space-separated list of scopes.
6062
6163
##### Integrating the MCP server with Claude Desktop
6264

@@ -70,13 +72,16 @@ To add the MCP server to Claude go to Settings > Developer > Edit config and add
7072
"args": ["-y", "@xeroapi/xero-mcp-server@latest"],
7173
"env": {
7274
"XERO_CLIENT_ID": "your_client_id_here",
73-
"XERO_CLIENT_SECRET": "your_client_secret_here"
75+
"XERO_CLIENT_SECRET": "your_client_secret_here",
76+
"XERO_SCOPES": "accounting.invoices accounting.contacts accounting.settings"
7477
}
7578
}
7679
}
7780
}
7881
```
7982

83+
The `XERO_SCOPES` variable is optional. If omitted, the default scopes listed above will be used.
84+
8085
NOTE: If you are using [Node Version Manager](https://github.com/nvm-sh/nvm) `"command": "npx"` section change it to be the full path to the executable, ie: `your_home_directory/.nvm/versions/node/v22.14.0/bin/npx` on Mac / Linux or `"your_home_directory\\.nvm\\versions\\node\\v22.14.0\\bin\\npx"` on Windows
8186

8287
#### 2. Bearer Token

src/clients/xero-client.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,16 @@ class CustomConnectionsXeroClient extends MCPXeroClient {
125125
}
126126

127127
public async getClientCredentialsToken(): Promise<TokenSet> {
128-
// Try V1 scopes first (for existing apps), fallback to V2 scopes (for new apps) only on invalid_scope error
128+
// If XERO_SCOPES is set, use that
129+
if (process.env.XERO_SCOPES) {
130+
try {
131+
return await this.requestToken(process.env.XERO_SCOPES);
132+
} catch (envError) {
133+
throw this.formatTokenError(envError, " with XERO_SCOPES");
134+
}
135+
}
136+
137+
// Else if XERO_SCOPES is not set, try V1 scopes first (for existing apps), fallback to V2 scopes (for new apps) only on invalid_scope error
129138
try {
130139
return await this.requestToken(this.XERO_DEFAULT_AUTH_SCOPES_V1);
131140
} catch (error) {

0 commit comments

Comments
 (0)