Disable wallet tools by default#267
Conversation
This PR adds a new way of dealing with wallet connection and makes the wallet disabled by default. Users can pass in a private key explicitly to unlock all the wallet connection functionality. - Added and adjusted tests
🦋 Changeset detectedLatest commit: cd73506 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #267 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 67 71 +4
Lines 763 827 +64
Branches 128 134 +6
=========================================
+ Hits 763 827 +64 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR “Disable wallet tools by default” introduces a new wallet configuration mechanism that conditionally registers wallet‐dependent tools only when a wallet is enabled, defaulting to disabled. Key changes include adding configuration functions (isWalletEnabled and getWalletMode), updating wallet provider usage throughout services and tools, and extensive updates to tests to reflect these modifications.
Reviewed Changes
Copilot reviewed 21 out of 24 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/mcp-server/src/core/config.ts | Introduces wallet configuration and new WALLET_API_KEY variable along with functions to check wallet mode. |
| packages/mcp-server/src/core/tools.ts | Updates tool registration to separate read-only from wallet-dependent tools and refactors error messaging. |
| packages/mcp-server/src/core/wallet/* | Updates wallet provider implementations and usage to align with new configuration and provider functions. |
| Various test files | Refactor tests to use new wallet provider API (getWalletClientFromProvider, getAddressFromProvider) and validate error responses under disabled wallet mode. |
Comments suppressed due to low confidence (2)
packages/mcp-server/src/core/config.ts:15
- The WALLET_API_KEY environment variable is introduced but not yet used. Please consider documenting its intended future use or removing it if it is not needed at this stage.
WALLET_API_KEY: z.string().optional() // Used for wallet providers
packages/mcp-server/src/core/tools.ts:1330
- [nitpick] The error message for an unavailable wallet provider is hard-coded here. Consider centralizing and documenting standard error messages for wallet-related failures to improve consistency and ease of future updates.
}
|
|
||
| # Wallet Configuration | ||
| # Wallet mode: private-key | dynamic | porto | disabled | ||
| # - disabled: Disable all wallet functionality (default - safest for production) |
There was a problem hiding this comment.
Curious, how will this work for dynamic and porto modes?
There was a problem hiding this comment.
It extends that same WalletProvider interface and adds a new wallet mode "dynamic"
| # Wallet mode: private-key | dynamic | porto | disabled | ||
| # - disabled: Disable all wallet functionality (default - safest for production) | ||
| # - private-key: Use PRIVATE_KEY environment variable | ||
| WALLET_MODE=disabled |
There was a problem hiding this comment.
Can we assume we are in readonly mode if no private key is set?
There was a problem hiding this comment.
It does default to disabled if no private key. We could make it not required for the wallet mode, but with dynamic added we will still need a wallet mode for that.
This PR adds a new way of adding wallet connection through a standardized interface as well as adds conditional availability of tools depending on if they have a wallet configured or not. It defaults to no wallet connection and thus no wallet based tools. Once the user changes the config they will get all the wallet based tools.
Follow up work will be done to add a couple wallet connection libraries to this.
Example (Read Only)
{ "mcpServers": { "sei": { "command": "npx", "args": ["-y", "@sei-js/mcp-server"] } } }Example (Private Key Wallet Connection)
{ "mcpServers": { "sei": { "command": "npx", "args": ["-y", "@sei-js/mcp-server"], "env": { "WALLET_MODE": "private-key", "PRIVATE_KEY": "0x123..." } } } }WALLET_API_KEY has been added for future use as a flag