Skip to main content

MCP server that scrapes PhonePe Payment Gateway developer documentation and answers API integration questions

Project description

phonepe-pg-docs-mcp

PhonePe Payment Gateway — Documentation & Knowledge Base MCP

PyPI version Python License: Apache 2.0

An MCP (Model Context Protocol) server published by PhonePe that gives any AI agent — Claude, GPT, Cursor, Copilot, Windsurf — instant access to PhonePe Payment Gateway developer documentation and a curated knowledge base.

Integrate PhonePe PG faster by letting your AI coding assistant answer questions directly from the official docs, without leaving your IDE.

No PhonePe credentials required. This MCP is entirely read-only.


Why use this?

When integrating PhonePe PG, developers commonly need to:

  • Look up which API to call for a specific action
  • Understand the request/response schema for an endpoint
  • Check what order states exist and what each means
  • Debug error codes like AUTHORIZATION_FAILED
  • Find out if PhonePe supports a feature (recurring payments, international, EMI, etc.)
  • Compare Standard Checkout vs Custom Checkout vs Payment Links

This MCP lets your AI agent answer all of these questions instantly — from a pre-indexed, always-up-to-date snapshot of the official developer docs — so you can stay in your editor and keep coding.


How it works

Your question to the AI agent
          │
          ▼
┌──────────────────────────────────┐
│  Tier 1 · knowledge_base.yml     │  ~0 ms   Curated answers: products,
│  30 KB YAML, loaded at startup   │ ───────▶  features, FAQs, error codes
└──────────────────────────────────┘
          │ not found
          ▼
┌──────────────────────────────────┐
│  Tier 2 · SQLite FTS5 index      │  ~2 ms   Full-text search across
│  doc_index.db, 2.4 MB on disk    │ ───────▶  241 developer doc sections
└──────────────────────────────────┘
          │ section not yet indexed
          ▼
┌──────────────────────────────────┐
│  Tier 3 · Live web scraping      │  ~1–2 s  Fetches from
│  developer.phonepe.com           │ ───────▶  developer.phonepe.com
└──────────────────────────────────┘

The SQLite index is pre-built and shipped inside the PyPI wheel. Every pip install or uvx run gives you the latest indexed docs at sub-millisecond search speed — no network calls needed for search.


Available tools (10 total)

🧠 Knowledge base tools — instant, no network

Tool What it answers
ask_knowledge_base Any product / feature / API / error question in natural language
list_products All live PhonePe PG products and which ones require special permission
get_feature_support "Does PhonePe support X?" — refunds, recurring, international, EMI, etc.
get_error_code_info HTTP status, cause, and resolution for any PhonePe error code

📚 Documentation tools — SQLite FTS5 backed

Tool Description
search_docs Keyword search across all 241 doc sections (~2 ms)
list_doc_sections Browse the full list of available documentation sections
get_section_content Fetch the full content of any specific doc section
get_api_endpoints Complete API endpoint reference table
get_prerequisites Setup checklist per integration type
get_environments Sandbox and production base URLs

Set up in your AI client

Pick your client and add the following config. Restart the client after saving.

Claude Desktop

Config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "phonepe-pg-docs": {
      "command": "uvx",
      "args": ["--from", "phonepe-pg-docs-mcp", "phonepe-pg-docs"]
    }
  }
}

Cursor

Config file: ~/.cursor/mcp.json (global) or .cursor/mcp.json in your project

{
  "mcpServers": {
    "phonepe-pg-docs": {
      "command": "uvx",
      "args": ["--from", "phonepe-pg-docs-mcp", "phonepe-pg-docs"]
    }
  }
}

GitHub Copilot (VS Code)

Config file (workspace): .vscode/mcp.json
Config file (user-level): ~/.copilot/mcp-config.json

{
  "servers": {
    "phonepe-pg-docs": {
      "type": "stdio",
      "command": "uvx",
      "args": ["--from", "phonepe-pg-docs-mcp", "phonepe-pg-docs"]
    }
  }
}

Windsurf

Config file: ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "phonepe-pg-docs": {
      "command": "uvx",
      "args": ["--from", "phonepe-pg-docs-mcp", "phonepe-pg-docs"]
    }
  }
}

Using pip instead of uvx

Replace the command/args block in any config above with:

"command": "phonepe-pg-docs",
"args": []

Installation

Requirements: Python 3.10 or higher. No API keys needed.

Using uvx

uvx --from phonepe-pg-docs-mcp phonepe-pg-docs

Using pip

pip install phonepe-pg-docs-mcp
phonepe-pg-docs

Example conversations

Once configured, talk to your AI agent naturally:

You: "Does PhonePe support recurring payments?"
MCP: ask_knowledge_base → Yes. UPI AutoPay and eNACH are supported.
     Requires the AutoPay permission to be enabled by PhonePe...

You: "What API do I call to generate a UPI QR for payment?"
MCP: ask_knowledge_base → POST /payments/v2/pay with paymentFlow.type = UPI_QR
     Doc: get_section_content('custom-checkout-v2/pay/upi-qr')

You: "Show me the full Custom Checkout UPI Intent integration steps"
MCP: get_section_content('custom-checkout-v2/pay/upi-intent') → full guide

You: "Find everything about webhook verification"
MCP: search_docs('webhook') → 10 matching sections in 2 ms

You: "What does AUTHORIZATION_FAILED mean?"
MCP: get_error_code_info → HTTP 401, expired token, re-fetch via /v1/oauth/token

You: "What are all the states a PhonePe payment order can be in?"
MCP: ask_knowledge_base → PENDING, COMPLETED, FAILED, CANCELLED + descriptions

You: "Which PhonePe products need special permission to use?"
MCP: list_products → Custom Checkout, AutoPay, Payment Links (each individually gated)

Configuration reference

Environment variable Default Description
PHONEPE_DOCS_CACHE_TTL_SECONDS 3600 Cache TTL for live-fetched pages (Tier 3 fallback only)

Set via a .env file in your working directory or export the variable. Not required for standard use.


Contributing

Contributions to PhonePe PG Docs MCP are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code follows the project's coding standards and includes appropriate tests.

Adding or fixing documentation sections

The full list of indexed pages is in docs_registry.yml. To add a new page:

  1. Add an entry under sections.public or sections.additional:
    my-new-section: /payment-gateway/path/to/page
    
  2. Rebuild the local index:
    pip install httpx pyyaml beautifulsoup4
    python scripts/build_index.py
    
  3. Verify with a search: search_docs("your new topic")
  4. Open a pull request

Updating the curated knowledge base

Product descriptions, feature flags, FAQs, and error code explanations live in
src/phonepe_docs_mcp/knowledge/knowledge_base.yml. Edit that file directly — no code changes needed.

Running locally (development)

git clone https://github.com/PhonePe/phonepe-pg-docs-mcp.git
cd phonepe-pg-docs-mcp
pip install -e ".[test]"

# Build the doc index (required once before first run)
python scripts/build_index.py

# Run tests
pytest

# Start the MCP server
phonepe-pg-docs

Releasing a new version (maintainers)

  1. Bump version in pyproject.toml
  2. Add a changelog entry in CHANGELOG.md
  3. Merge to main
  4. Trigger the Manual Release to PyPI GitHub Actions workflow

The CI pipeline automatically:

  1. Runs python scripts/build_index.py — re-indexes all 241 doc sections with the latest content
  2. Bundles the fresh doc_index.db inside the wheel
  3. Publishes to PyPI via twine

Every pip install phonepe-pg-docs-mcp always delivers the latest pre-indexed documentation snapshot.


Official documentation

Resource Link
PhonePe PG Developer Portal https://developer.phonepe.com
Standard Checkout https://developer.phonepe.com/phonepe-payment-gateway/pg-v2-standard-checkout-integration
AutoPay / Recurring https://developer.phonepe.com/payment-gateway/autopay/api-integration/introduction
Payment Links https://developer.phonepe.com/payment-gateway/payment-links/introduction
Chargeback APIs https://developer.phonepe.com/chargeback

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Copyright 2025 PhonePe Private Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Support

  • Bug reports / feature requests: Open an issue on GitHub
  • PhonePe PG account or enablement questions: Contact your PhonePe account manager or write to pg-developer@phonepe.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phonepe_pg_docs_mcp-1.0.2.tar.gz (560.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phonepe_pg_docs_mcp-1.0.2-py3-none-any.whl (564.2 kB view details)

Uploaded Python 3

File details

Details for the file phonepe_pg_docs_mcp-1.0.2.tar.gz.

File metadata

  • Download URL: phonepe_pg_docs_mcp-1.0.2.tar.gz
  • Upload date:
  • Size: 560.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for phonepe_pg_docs_mcp-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bdf986babdd6e650bc0d56e26da528b4287b3627fcfbf133e7ff1b185e9808a5
MD5 c0adc5728d94294ee848beec4cafbd0f
BLAKE2b-256 64704eb78b52a9ae451492ebf458660cdfa423c785ee7540debc82f0ea3ade55

See more details on using hashes here.

File details

Details for the file phonepe_pg_docs_mcp-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for phonepe_pg_docs_mcp-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f14c3ea9c3eca6ec780333d5989acd544b0247fcadf7c09060ad2396e5488995
MD5 ec29b1c701280f09e7ecf28d10200d0d
BLAKE2b-256 82379ee0f3dffe2e3c1f44df593bc59351531282d9ea9cc58a4f6936612a67ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page