Skip to content

feat(partnerships): add create_account MCP tool for sub-merchant onboarding#102

Open
rzp-slash[bot] wants to merge 14 commits into
mainfrom
feat/partnerships-create-account-tool
Open

feat(partnerships): add create_account MCP tool for sub-merchant onboarding#102
rzp-slash[bot] wants to merge 14 commits into
mainfrom
feat/partnerships-create-account-tool

Conversation

@rzp-slash

@rzp-slash rzp-slash Bot commented May 7, 2026

Copy link
Copy Markdown

Summary

Adds the create_account MCP tool for Razorpay's Partnerships Onboarding API, enabling partner agents to onboard sub-merchants programmatically.

  • Adds pkg/razorpay/accounts.go with the CreateAccount tool (POST /v2/accounts)
  • Registers a new partnerships toolset in pkg/razorpay/tools.go
  • Uses the existing client.Account.Create from the razorpay-go SDK (already supports v2)

Tool: create_account

Required: phone

Optional: email, legal_business_name, business_type, contact_name, customer_facing_business_name, reference_id, type, profile (category + subcategory + addresses), legal_info (pan/gst/cin), brand (hex color without #), notes, contact_info (chargeback/refund/support/dispute), apps (websites/android/ios)

Field validations sourced directly from razorpay/partnerships validator:

  • phone is a string (not number), validated via IsPhoneNumber
  • business_type enum matches the partnerships service constants exactly
  • brand.color is 6-char hex WITHOUT # prefix (^[0-9a-fA-F]{6}$)
  • contact_info has 4 sub-fields: chargeback, refund, support, dispute
  • profile.addresses.registered is required when profile is provided

Test plan

  • create_account tool appears in the partnerships toolset
  • Calling with only phone succeeds (only required field)
  • Calling with full payload (profile + legal_info + brand + contact_info) succeeds
  • Invalid business_type returns API-level validation error from Razorpay
  • brand.color with # prefix returns error from Razorpay API

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 1.79910% with 655 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.62%. Comparing base (7950d51) to head (18f920c).

Files with missing lines Patch % Lines
...g/razorpay/partnerships/onboarding_apis/account.go 0.00% 410 Missing ⚠️
...g/razorpay/partnerships/onboarding_apis/helpers.go 0.00% 109 Missing ⚠️
pkg/razorpay/partnerships/auth/token.go 0.00% 84 Missing ⚠️
pkg/razorpay/partnerships/auth/helpers.go 0.00% 51 Missing ⚠️
cmd/razorpay-mcp-server/stdio.go 0.00% 0 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (1.79%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #102      +/-   ##
==========================================
- Coverage   97.35%   89.62%   -7.73%     
==========================================
  Files          35       39       +4     
  Lines        7567     8233     +666     
==========================================
+ Hits         7367     7379      +12     
- Misses        136      790     +654     
  Partials       64       64              
Flag Coverage Δ
unittests 89.62% <1.79%> (-7.73%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

rzp-slash Bot and others added 11 commits May 7, 2026 18:39
…dd auth token tool

- Move accounts.go → pkg/razorpay/partnerships/onboarding_apis/account.go
  (package onboardingapis) to support future partnerships sub-categories
- Add pkg/razorpay/partnerships/auth/token.go with generate_access_token tool
  (POST https://auth.razorpay.com/token, client_credentials grant)
- Add helpers.go in each sub-package (getClientFromContextOrDefault,
  formatErrorMessage, validator) to avoid circular imports with pkg/razorpay
- Register partnerships toolset with generate_access_token (write),
  create_account (write), fetch_account (read)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Switch from JSON to application/x-www-form-urlencoded (OAuth standard)
- Pick auth token URL based on APP_ENV: devstack/dev → auth.dev.razorpay.in,
  prod → auth.razorpay.com

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… as integer

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Flatten all create_account fields into individual params (no nested objects)
- Add preview_create_account: validates mandatory fields, assembles nested
  JSON, shows constructed payload before submission
- Mandatory fields: email, phone, legal_business_name, business_type,
  contact_name — validated in both preview and create
- Profile address fields validated conditionally when profile is provided
- create_account blocks on mandatory errors, preview surfaces as warnings

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… HTTP

- Drop razorpay-go SDK from create_account and fetch_account
- Add bearer_token as required param on both tools (obtained from generate_access_token)
- Use direct HTTP calls to Partnerships API with Bearer auth
- APP_ENV=devstack/dev → api-web.ext.dev.razorpay.in, else api.razorpay.com
- Devstack: auto-add X-Org-Id, kong-debug, rzpctx-dev-serve-user (DEVSTACK_LABEL) headers

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Fixes flaky TestRunStdioServer/handles_server_creation_error — when context
is cancelled, stdioSrv.Listen returns context.Canceled which raced with
ctx.Done(). Treat context.Canceled as a graceful shutdown (return nil).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- gocyclo: split buildAccountPayload into buildProfileBlock,
  buildLegalInfoBlock, buildContactInfoBlock, buildOperationAddress
- gosec G101: add nolint on URL constants (not credentials)
- lll: wrap long lines across auth/ and onboarding_apis/
- Add comment explaining context.Canceled handling in stdio.go

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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.

6 participants