feat: scope-aware tool registration (extends #136)#143
Open
Jack-Lewis1 wants to merge 2 commits intoXeroAPI:mainfrom
Open
feat: scope-aware tool registration (extends #136)#143Jack-Lewis1 wants to merge 2 commits intoXeroAPI:mainfrom
Jack-Lewis1 wants to merge 2 commits intoXeroAPI:mainfrom
Conversation
…registration logic - Updated `.env.example` to include optional OAuth scopes and logging configurations. - Refactored scope handling in `xero-client.ts` to utilize a new helper for scope validation. - Introduced `scopes.ts` to manage default and valid scopes, improving clarity and maintainability. - Modified tool creation functions to enforce required scopes, ensuring tools are registered based on configured permissions. - Enhanced README with detailed instructions on scope usage and tool registration behavior. This commit improves the flexibility and robustness of custom connections with the Xero API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to: #136 — configurable
XERO_SCOPESfor custom connections.This branch extends that idea so reduced scopes don’t leave payroll (or other) tools registered while the token would 403 them.
What changed
src/helpers/scopes.tsVALID_SCOPES(warn on unknown, still sent to Xero),getConfiguredScopes()/getConfiguredScopeString(),ToolScopesgroups for tools.CreateXeroTool(...)passesrequiredScopes(viaToolScopes.*).tool-factory.tsrequiredScopeswhen using client id/secret. Bearer token mode: no filtering (token scopes aren’t known here).xero-client.tsgetConfiguredScopeString()(same source as gating).src/index.tsimport "dotenv/config"first soXERO_SCOPESis loaded before tool registration.scopes.ts, scope↔tool table, granular-vs-broad scope caveat,XERO_MCP_LOG_SCOPE_FILTERING..env.exampleXERO_SCOPES,XERO_CLIENT_BEARER_TOKEN, optional logging var.New / notable env vars
XERO_SCOPES— optional; space-separated (same as Make custom connection scopes configurable #136).XERO_MCP_LOG_SCOPE_FILTERING=1— stderr summary of registered vs omitted tools (custom connections only).Reviewer checklist
payroll.settings+payroll.employeesorpayroll.settings+payroll.timesheets— matches how you expect custom connections to be configured.ToolScopesuntil we add an alias map (documented in README).console.warn/ optionalconsole.erroronly to stderr (stdio MCP safe).