Skip to content

feat(agentpay): add native MCP payment layer for Dify agents (#33434)…#33455

Open
nourzakhama2003 wants to merge 2 commits intolanggenius:mainfrom
nourzakhama2003:feat/agentpay-mcp-integration
Open

feat(agentpay): add native MCP payment layer for Dify agents (#33434)…#33455
nourzakhama2003 wants to merge 2 commits intolanggenius:mainfrom
nourzakhama2003:feat/agentpay-mcp-integration

Conversation

@nourzakhama2003
Copy link
Contributor

@nourzakhama2003 nourzakhama2003 commented Mar 15, 2026

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

Capture d'écran 2026-03-15 024728 Capture d'écran 2026-03-15 001545 Capture d'écran 2026-03-15 025925 Capture d'écran 2026-03-15 024625

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]

… and add community AgentPay MCP plugin with provider, tools, client, manifest
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Mar 15, 2026
@github-actions github-actions bot added needs-revision for anti-slop web This relates to changes on the web. and removed needs-revision for anti-slop labels Mar 15, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • Native AgentPay MCP Payment Layer: Introduced a native AgentPay Metered Compute Protocol (MCP) payment layer, enabling Dify agents and workflows to discover, fund, and invoke metered tools.
  • New Community Plugin: Added a comprehensive AgentPay community plugin, complete with provider and tool wiring, to facilitate integration with AgentPay services.
  • Improved MCP Setup User Experience: Enhanced the MCP setup user experience by implementing auto-fill functionality for AgentPay URLs, addressing previous friction points related to runtime topology and repetitive form entries.
  • Integration Documentation: Provided detailed integration documentation, including a new guide and updates to the main README, to assist users in setting up and utilizing the AgentPay MCP integration.

🧠 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
  • .gitignore
    • Added entries to ignore local debug artifacts for the AgentPay MCP plugin.
  • README.md
    • Updated to include a link to the new AgentPay MCP Integration Guide.
  • docs/agentpay-mcp-integration.md
    • Added a new guide for integrating AgentPay MCP payments.
  • plugins/community/agentpay-mcp-payments/README.md
    • Added a new README for the AgentPay Payment Layer plugin.
  • plugins/community/agentpay-mcp-payments/_assets/icon.svg
    • Added an SVG icon for the AgentPay plugin.
  • plugins/community/agentpay-mcp-payments/agentpay_mcp_payments.py
    • Added the Python provider for AgentPay MCP payments, including credential validation.
  • plugins/community/agentpay-mcp-payments/main.py
    • Added the main entry point for the AgentPay MCP Payments plugin.
  • plugins/community/agentpay-mcp-payments/manifest.yaml
    • Added the manifest file defining the AgentPay MCP Payments plugin.
  • plugins/community/agentpay-mcp-payments/privacy.md
    • Added a privacy policy document for the AgentPay plugin.
  • plugins/community/agentpay-mcp-payments/provider/agentpay_mcp_payments.yaml
    • Added the YAML definition for the AgentPay MCP Payments provider, including credentials and tool definitions.
  • plugins/community/agentpay-mcp-payments/tests/test_agentpay_client.py
    • Added unit tests for the AgentPay MCP client.
  • plugins/community/agentpay-mcp-payments/tools/call_tool.py
    • Added Python logic for the call_tool functionality.
  • plugins/community/agentpay-mcp-payments/tools/call_tool.yaml
    • Added YAML definition for the call_tool.
  • plugins/community/agentpay-mcp-payments/tools/check_balance.py
    • Added Python logic for the check_balance functionality.
  • plugins/community/agentpay-mcp-payments/tools/check_balance.yaml
    • Added YAML definition for the check_balance tool.
  • plugins/community/agentpay-mcp-payments/tools/client.py
    • Added the core Python client for interacting with AgentPay MCP.
  • plugins/community/agentpay-mcp-payments/tools/common.py
    • Added common utility functions for JSON parsing and type conversion.
  • plugins/community/agentpay-mcp-payments/tools/discover_tools.py
    • Added Python logic for the discover_tools functionality.
  • plugins/community/agentpay-mcp-payments/tools/discover_tools.yaml
    • Added YAML definition for the discover_tools tool.
  • plugins/community/agentpay-mcp-payments/tools/fund_wallet_stripe.py
    • Added Python logic for the fund_wallet_stripe functionality.
  • plugins/community/agentpay-mcp-payments/tools/fund_wallet_stripe.yaml
    • Added YAML definition for the fund_wallet_stripe tool.
  • plugins/community/agentpay-mcp-payments/tools/get_usage.py
    • Added Python logic for the get_usage functionality.
  • plugins/community/agentpay-mcp-payments/tools/get_usage.yaml
    • Added YAML definition for the get_usage tool.
  • plugins/community/agentpay-mcp-payments/tools/list_tools.py
    • Added Python logic for the list_tools functionality.
  • plugins/community/agentpay-mcp-payments/tools/list_tools.yaml
    • Added YAML definition for the list_tools tool.
  • web/app/components/tools/mcp/hooks/tests/use-mcp-modal-form.spec.ts
    • Updated tests for the MCP modal form hook to include AgentPay auto-fill behavior.
  • web/app/components/tools/mcp/hooks/use-mcp-modal-form.ts
    • Modified the MCP modal form hook to implement AgentPay URL detection and auto-fill functionality.
Activity
  • Backend plugin tests passed with 2 successful tests.
  • Frontend MCP hook tests passed with 75 successful tests.
  • Type-check and linting completed without issues.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added the needs-revision for anti-slop label Mar 15, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +59 to +62
try:
return self._http_call(tool_name, arguments)
except Exception:
return self._stdio_call(tool_name, arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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)

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

Labels

needs-revision for anti-slop size:XXL This PR changes 1000+ lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant