Skip to content

feat(tools): add CoinbaseAgenticWalletTool with x402 payment support#5785

Open
youssefea wants to merge 4 commits into
crewAIInc:mainfrom
youssefea:feat/coinbase-agentic-wallet-tool
Open

feat(tools): add CoinbaseAgenticWalletTool with x402 payment support#5785
youssefea wants to merge 4 commits into
crewAIInc:mainfrom
youssefea:feat/coinbase-agentic-wallet-tool

Conversation

@youssefea
Copy link
Copy Markdown

@youssefea youssefea commented May 12, 2026

Summary

Adds CoinbaseAgenticWalletTool, a lifecycle wrapper around CrewAI's MCPServerAdapter for 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

  • Adds crewai_tools.tools.coinbase_agentic_wallet_tool and exports CoinbaseAgenticWalletTool.
  • Adds an automation docs page and navigation card for the tool.
  • Adds a unit test for defaults and lazy adapter startup.

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.py
  • uv run ruff check lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py
  • uv run pytest lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py
  • uv run python lib/crewai-tools/src/crewai_tools/generate_tool_specs.py

Note: tool spec generation completed with existing Pydantic JSON schema warnings and did not change tool.specs.json because this wrapper returns MCP-adapted tools rather than subclassing BaseTool directly.

Summary by CodeRabbit

  • New Features

    • Added Coinbase Agentic Wallet integration so agents can discover payment APIs, inspect requirements, and initiate USDC payments.
  • Documentation

    • Added full guide for installation, authentication (email/OTP), usage patterns, lifecycle management, and links to Coinbase MCP/x402 docs.
    • Added a tool card to the Available Tools overview.
  • Tests

    • Added tests for defaults, lazy startup/teardown, and missing-bundle error handling.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 401026a2-5a01-4377-ab5e-d59a9456b3b5

📥 Commits

Reviewing files that changed from the base of the PR and between 461ca58 and c4c6544.

📒 Files selected for processing (1)
  • lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py

📝 Walkthrough

Walkthrough

This PR adds CoinbaseAgenticWalletTool (implementation, exports, tests, README, and MDX docs) and updates docs.json to register the new tool page in site navigation.

Changes

Coinbase Agentic Wallet Tool

Layer / File(s) Summary
Tool implementation with lifecycle management
lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/coinbase_agentic_wallet_tool.py
CoinbaseAgenticWalletTool class with configuration for node and ~/.payments-mcp/bundle.js, server params builder, lazy MCPServerAdapter startup, bundle existence check (raises FileNotFoundError), tools property, start()/stop() lifecycle, and context manager methods.
Package exports and module wiring
lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/__init__.py, lib/crewai-tools/src/crewai_tools/tools/__init__.py, lib/crewai-tools/src/crewai_tools/__init__.py
Re-exports and adds CoinbaseAgenticWalletTool to __all__ at tool package, tools subpackage, and root package levels.
Unit tests for tool behavior
lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py
Tests for defaults, lazy adapter instantiation and constructor args, propagation of adapter.tools to tool.tools, stop() delegation, and missing-bundle FileNotFoundError with installation hint.
Tool package documentation
lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/README.md
README describes purpose, prerequisites (Python and Node MCP bundle), installation (npx @coinbase/payments-mcp install), context manager and manual lifecycle examples, auth behavior, and reference links.
User-facing documentation pages
docs/en/tools/automation/coinbase-agentic-wallet-tool.mdx, docs/en/tools/automation/overview.mdx
New MDX page with installation, usage, lifecycle, auth flow, agent actions, and resources; overview page adds a Coinbase Agentic Wallet Tool card to Available Tools.
Documentation site navigation
docs/docs.json
Inserted "en/tools/automation/coinbase-agentic-wallet-tool" into multiple pages arrays (13 locations) so the new page appears in site navigation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through docs and code with cheer,
A wallet bundle now draws near,
Context managers keep things neat,
Adapters spawn the node.js beat,
Docs, tests, and exports — all in gear!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding CoinbaseAgenticWalletTool with x402 payment support, which matches the primary additions across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Add 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

📥 Commits

Reviewing files that changed from the base of the PR and between 264da82 and c53c0da.

📒 Files selected for processing (9)
  • docs/docs.json
  • docs/en/tools/automation/coinbase-agentic-wallet-tool.mdx
  • docs/en/tools/automation/overview.mdx
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/coinbase_agentic_wallet_tool/__init__.py
  • 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.py

Comment thread docs/en/tools/automation/coinbase-agentic-wallet-tool.mdx Outdated
Comment thread docs/en/tools/automation/coinbase-agentic-wallet-tool.mdx
Comment thread lib/crewai-tools/tests/test_coinbase_agentic_wallet_tool.py
Co-authored-by: Codex <noreply@openai.com>
@youssefea
Copy link
Copy Markdown
Author

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>
@youssefea
Copy link
Copy Markdown
Author

Follow-up c4c6544 adds test docstrings to clear the CodeRabbit docstring-coverage warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant