feat(agentpay): add native MCP payment layer for Dify agents (#33434)…#33455
feat(agentpay): add native MCP payment layer for Dify agents (#33434)…#33455nourzakhama2003 wants to merge 2 commits intolanggenius:mainfrom
Conversation
… and add community AgentPay MCP plugin with provider, tools, client, manifest
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates a native AgentPay MCP payment layer into Dify, allowing agents and workflows to seamlessly interact with metered tools. It addresses previous friction points in setup by providing a dedicated community plugin, comprehensive documentation, and user experience enhancements for configuring MCP servers. The changes aim to streamline the process of discovering, funding, and invoking paid tools within Dify's ecosystem. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a native AgentPay MCP payment layer for Dify agents, which is a significant feature addition. The changes include a new community plugin, comprehensive documentation, and UX improvements for MCP setup. The code is well-structured and includes tests. My review identifies a minor improvement opportunity in the client's error handling to make it more robust, especially concerning authentication failures.
| try: | ||
| return self._http_call(tool_name, arguments) | ||
| except Exception: | ||
| return self._stdio_call(tool_name, arguments) |
There was a problem hiding this comment.
The broad except Exception for the HTTP fallback logic can mask authentication errors (AgentPayAuthError). If an auth error occurs during the HTTP call, it's better to fail fast rather than attempting a fallback to stdio, which will also likely fail and may obscure the original error.
I suggest modifying the exception handling to explicitly catch and re-raise AgentPayAuthError while allowing other exceptions to trigger the fallback as intended. This will make debugging authentication issues more straightforward.
| try: | |
| return self._http_call(tool_name, arguments) | |
| except Exception: | |
| return self._stdio_call(tool_name, arguments) | |
| try: | |
| return self._http_call(tool_name, arguments) | |
| except AgentPayAuthError: | |
| # Do not fallback on auth errors, re-raise immediately. | |
| raise | |
| except Exception: | |
| # Fallback to stdio on any other error (e.g. connection, timeout, misconfiguration). | |
| return self._stdio_call(tool_name, arguments) |
Fixes#<33434>
Summary
This PR introduces a native AgentPay MCP payment layer for Dify agents/workflows, including a community plugin, provider/tool wiring, integration documentation, and MCP setup UX improvements.
The goal is to let Dify workflows discover, fund, and invoke metered MCP tools through AgentPay with clear setup guidance and reproducible local validation.
probleme
Users can connect MCP servers in Dify, but payment-enabled AgentPay flows were not available as a native community plugin with end-to-end workflow guidance.
During local integration, setup friction was observed in two areas:
runtime topology confusion (host/container URL mismatch),
repetitive MCP form entry for known AgentPay URLs.
Screenshots
Changes
New AgentPay community plugin with full provider + tool stack:
[main.py]
[manifest.yaml]
[agentpay_mcp_payments.py]
[agentpay_mcp_payments.yaml]
[client.py]
[common.py]
[check_balance.py]
[discover_tools.py]
[list_tools.py]
[call_tool.py]
[fund_wallet_stripe.py]
[get_usage.py]
Tool specs (.yaml) for all above tools
Plugin metadata assets/docs:
[icon.svg]
[privacy.md]
[README.md]
Integration documentation:
[agentpay-mcp-integration.md]
[README.md] (entry/link update to integration guide)
MCP setup UX improvement:
[use-mcp-modal-form.ts]
[use-mcp-modal-form.spec.ts]
Behavior:
When MCP URL matches AgentPay and fields are empty, defaults are auto-filled:
Name: AgentPay
Server Identifier: agentpay
Existing user-entered values are preserved and not overwritten.
Local artifact hygiene:
updated to ignore plugin local debug artifacts.
Validation Performed
Backend plugin tests:
[test_agentpay_client.py]
Result: 2 passed
Frontend MCP hook tests:
[use-mcp-modal-form.spec.ts]
[use-mcp-service-card.spec.ts]
Result: 75 passed
Type-check/lint notes:
type-check completed.
Compatibility
New functionality is additive under a new community plugin path.
MCP modal defaulting is guarded by URL detection + empty-field checks.
Operational caveat:
Correct MCP endpoint topology (host vs container) is required for stable tool execution, documented in plugin README.
Reviewer Checklist
Provider credential validation and error handling:
[agentpay_mcp_payments.py]
[client.py]
Tool contract consistency:
Tool python + yaml pairs under [tools]
UX defaulting behavior and non-overwrite safeguards:
[use-mcp-modal-form.ts]
[use-mcp-modal-form.spec.ts]
Docs clarity and reproducibility:
[README.md]
[agentpay-mcp-integration.md]