feat(tools): add CoinbaseAgenticWalletTool with x402 payment support#5785
feat(tools): add CoinbaseAgenticWalletTool with x402 payment support#5785youssefea wants to merge 4 commits into
Conversation
Co-authored-by: Codex <noreply@openai.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds CoinbaseAgenticWalletTool (implementation, exports, tests, README, and MDX docs) and updates docs.json to register the new tool page in site navigation. ChangesCoinbase Agentic Wallet Tool
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/coinbase_agentic_wallet_tool.py (1)
41-49: ⚡ Quick winAdd a preflight check for missing MCP bundle path.
A quick file-existence check before adapter creation gives a clear actionable error instead of surfacing a downstream startup failure.
Proposed fix
def start(self) -> ToolCollection[BaseTool]: """Start the MCP server and return the adapted CrewAI tools.""" if self._adapter is None: + if not self.bundle_path.is_file(): + raise FileNotFoundError( + f"Coinbase MCP bundle not found at {self.bundle_path}. " + "Run: npx `@coinbase/payments-mcp` install --client other" + ) self._adapter = MCPServerAdapter( self._server_params(), *self.tool_names, connect_timeout=self.connect_timeout, ) return self.tools🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/coinbase_agentic_wallet_tool.py` around lines 41 - 49, Add a preflight file-existence check in start() before creating the MCPServerAdapter: retrieve the bundle path (either from self.mcp_bundle_path or from the dict returned by self._server_params()), use os.path.exists to verify it exists and is a file, and if not raise a clear exception (e.g. ValueError) with an actionable message; only proceed to instantiate MCPServerAdapter(...) with self._server_params(), *self.tool_names, connect_timeout=self.connect_timeout when the bundle path check passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/en/tools/automation/coinbase-agentic-wallet-tool.mdx`:
- Line 10: The headline claim about "no manual onramp" in the
CoinbaseAgenticWalletTool documentation conflicts with the later instruction to
"Fund the wallet through the built-in Coinbase Onramp"; update the text for
CoinbaseAgenticWalletTool to either remove the phrase "no manual onramp" or
replace it with a clarifying sentence that distinguishes the automatic/embedded
Coinbase Onramp from a user-driven manual onramp (e.g., indicate that funding is
handled via an embedded, Coinbase-managed onramp that may still require user
interaction), and ensure the revised copy aligns with the funding step described
later so the description and the funding instructions are consistent.
- Line 46: The context manager example uses the context object coinbase_tools
directly for the tools parameter, but the manual lifecycle example uses
wallet.tools; update the context manager usage so it passes coinbase_tools.tools
(i.e., access the .tools property returned/held by the context manager) to be
consistent with wallet.tools and typical __enter__ behavior.
In
`@lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/coinbase_agentic_wallet_tool.py`:
- Around line 64-66: The instance keeps a stale adapter if self._adapter.stop()
raises; to fix, capture the current adapter into a local variable, set
self._adapter = None before attempting shutdown, then call the adapter's stop()
inside a try/except (or try/finally) and log or swallow errors; refer to the
self._adapter reference and the adapter.stop() call in the
coinbase_agentic_wallet_tool.py method to locate where to apply this change.
In `@lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py`:
- Around line 27-31: After constructing the CoinbaseAgenticWalletTool instance,
assert that the adapter has not been created yet by calling
adapter_class.assert_not_called() (and optionally assert that tool._adapter is
None) before the first access to tool.tools; then proceed to access tool.tools
and keep the existing adapter_class.assert_called_once_with("params", "pay",
connect_timeout=90).
---
Nitpick comments:
In
`@lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/coinbase_agentic_wallet_tool.py`:
- Around line 41-49: Add a preflight file-existence check in start() before
creating the MCPServerAdapter: retrieve the bundle path (either from
self.mcp_bundle_path or from the dict returned by self._server_params()), use
os.path.exists to verify it exists and is a file, and if not raise a clear
exception (e.g. ValueError) with an actionable message; only proceed to
instantiate MCPServerAdapter(...) with self._server_params(), *self.tool_names,
connect_timeout=self.connect_timeout when the bundle path check passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 990bb82e-b9c7-4357-8561-7bed0e594c17
📒 Files selected for processing (9)
docs/docs.jsondocs/en/tools/automation/coinbase-agentic-wallet-tool.mdxdocs/en/tools/automation/overview.mdxlib/crewai-tools/src/crewai_tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/__init__.pylib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/README.mdlib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/__init__.pylib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/coinbase_agentic_wallet_tool.pylib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py
Co-authored-by: Codex <noreply@openai.com>
|
Addressed the valid CodeRabbit feedback, including the missing-bundle preflight check, in 461ca58. Left the context-manager example unchanged because enter returns ToolCollection. |
Co-authored-by: Codex <noreply@openai.com>
|
Follow-up c4c6544 adds test docstrings to clear the CodeRabbit docstring-coverage warning. |
Summary
Adds
CoinbaseAgenticWalletTool, a lifecycle wrapper around CrewAI'sMCPServerAdapterfor the Coinbase Agentic Wallet MCP bundle. It keeps the adapter alive while CrewAI uses the MCP tools and exposes a context-manager API for cleanup.Lets agents discover and pay for HTTP APIs autonomously via the x402 protocol, using a Coinbase-managed embedded wallet -- no API keys, no manual onramp, no seed phrases.
Changes
crewai_tools.tools.coinbase_agentic_wallet_tooland exportsCoinbaseAgenticWalletTool.Testing
python3 -m py_compile lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/coinbase_agentic_wallet_tool.py lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.pyuv run ruff check lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.pyuv run pytest lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.pyuv run python lib/crewai-tools/src/crewai_tools/generate_tool_specs.pyNote: tool spec generation completed with existing Pydantic JSON schema warnings and did not change
tool.specs.jsonbecause this wrapper returns MCP-adapted tools rather than subclassingBaseTooldirectly.Summary by CodeRabbit
New Features
Documentation
Tests