MCP Midtrans Documentation Server
Provides Django-specific integration code including models, views, service layers, and Django REST Framework examples for implementing Midtrans payment gateway functionality, Snap integration, and webhook notification handlers.
Provides Express.js-specific code examples and implementation guides for handling Midtrans webhooks, payment notifications, and integrating payment processing flows in Express applications.
Provides FastAPI-specific integration examples and implementation guides for integrating Midtrans Snap checkout, charge requests, and payment processing into FastAPI applications.
Provides Node.js integration code and examples for implementing Midtrans payment gateway functionality, including charge requests, Snap integration, and webhook notification handlers.
Provides PHP integration code and examples for implementing Midtrans payment gateway functionality, including charge request generation, Snap integration, and notification handling.
Provides Python integration code and examples for implementing Midtrans payment gateway functionality, including API integration, charge request generation, and webhook signature verification.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Midtrans Documentation Server how do I integrate GoPay payments in Django?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
š¦ MCP Midtrans Documentation Server
A comprehensive Model Context Protocol (MCP) server that gives AI agents complete knowledge of the Midtrans payment gateway ā APIs, payment methods, integration guides, code examples, and best practices.
Table of Contents
Related MCP server: Bootpay Developer Docs MCP Server
Overview
MCP Midtrans is an MCP server that embeds the entire Midtrans payment gateway documentation as structured, searchable tools. When connected to an AI agent (Copilot, Claude, Cursor, etc.), the agent can:
Look up any Midtrans API endpoint, request format, or response schema
Get complete integration code for 15+ payment methods in 5 programming languages (Python, Django, Node.js, Go, PHP)
Generate ready-to-use charge request JSON for any payment type
Get webhook/notification handler code with signature verification
Search across all documentation to find exactly what's needed
No API keys required ā this server provides documentation only; it does not call the Midtrans API.
Architecture
%%{init: {'theme': 'dark', 'themeVariables': {'primaryColor': '#1a1a2e', 'primaryTextColor': '#e0e0e0', 'primaryBorderColor': '#6c63ff', 'lineColor': '#6c63ff', 'secondaryColor': '#16213e', 'tertiaryColor': '#0f3460', 'fontSize': '14px'}}}%%
graph TB
subgraph CLIENT["š„ļø AI Client"]
style CLIENT fill:#1a1a2e,stroke:#6c63ff,stroke-width:2px,color:#e0e0e0
VSCODE["VS Code + Copilot"]
CLAUDE_CODE["Claude Code"]
CLAUDE_DESKTOP["Claude Desktop"]
CURSOR["Cursor"]
end
subgraph MCP_SERVER["ā” MCP Midtrans Server"]
style MCP_SERVER fill:#0f3460,stroke:#6c63ff,stroke-width:2px,color:#e0e0e0
FASTMCP["FastMCP Runtime<br/>(stdio transport)"]
subgraph TOOLS["š§ MCP Tools (10)"]
style TOOLS fill:#16213e,stroke:#00d2ff,stroke-width:1px,color:#e0e0e0
T1["get_documentation_map"]
T2["get_documentation"]
T3["get_payment_method_guide"]
T4["get_json_object_schema"]
T5["get_status_codes"]
T6["get_code_example"]
T7["search_documentation"]
T8["get_charge_example"]
T9["get_notification_handler"]
T10["get_snap_integration"]
end
subgraph KB["š Knowledge Base"]
style KB fill:#16213e,stroke:#ff6b6b,stroke-width:1px,color:#e0e0e0
D1["API Reference"]
D2["Payment Methods 15+"]
D3["Code Examples 5 langs"]
D4["JSON Schemas 14"]
D5["Webhook Guides"]
D6["Status Codes"]
end
end
VSCODE -->|"stdio"| FASTMCP
CLAUDE_CODE -->|"stdio"| FASTMCP
CLAUDE_DESKTOP -->|"stdio"| FASTMCP
CURSOR -->|"stdio"| FASTMCP
FASTMCP --> TOOLS
TOOLS --> KBHow It Works
%%{init: {'theme': 'dark', 'themeVariables': {'primaryColor': '#1a1a2e', 'primaryTextColor': '#e0e0e0', 'primaryBorderColor': '#6c63ff', 'lineColor': '#00d2ff', 'secondaryColor': '#16213e', 'tertiaryColor': '#0f3460', 'fontSize': '14px'}}}%%
sequenceDiagram
box rgb(26,26,46) AI Client
participant User
participant Agent as AI Agent
end
box rgb(15,52,96) MCP Server
participant MCP as FastMCP Server
participant Tool as MCP Tool
participant KB as Knowledge Base
end
User->>Agent: "How do I integrate GoPay in Django?"
Agent->>MCP: tools/call midtrans_get_payment_method_guide<br/>payment_method = gopay
MCP->>Tool: Route to handler
Tool->>KB: PAYMENT_METHOD_DETAILS gopay
KB-->>Tool: Complete GoPay guide
Tool-->>MCP: Formatted response
MCP-->>Agent: GoPay charge example, response format, flow
Agent->>MCP: tools/call midtrans_get_code_example<br/>language = django
MCP->>Tool: Route to handler
Tool->>KB: IMPLEMENTATION_EXAMPLES django
KB-->>Tool: Django integration code
Tool-->>MCP: Models, views, service layer, DRF code
MCP-->>Agent: Complete Django implementation
Agent-->>User: Here is how to integrate GoPay in Django...You ask your AI agent to integrate Midtrans into your app.
The agent calls MCP tools to retrieve relevant documentation.
MCP server returns structured Midtrans documentation, code examples, and schemas.
The agent generates accurate integration code based on official docs.
Available MCP Tools
Tool | Description | Key Inputs |
| Complete documentation index ā start here | ā |
| Detailed docs for a specific topic |
|
| Integration guide per payment method |
|
| JSON object field-level schema |
|
| HTTP status code reference |
|
| Full implementation examples |
|
| Full-text search across all docs |
|
| Generate charge request JSON |
|
| Webhook handler code |
|
| Complete Snap backend + frontend guide |
|
Getting Started
Prerequisites
Installation
git clone https://github.com/your-org/mcp-midtrans.git
cd mcp-midtransRunning with uvx
The fastest way ā no install needed:
# Run directly from PyPI
uvx mcp-midtransOr install as a global tool:
uv tool install mcp-midtrans
mcp-midtransRunning with Docker
# Build the image
docker build -t mcp-midtrans .
# Run with stdio transport
docker run -i --rm mcp-midtransOr with Docker Compose:
docker compose up --buildRunning with pip
pip install mcp-midtrans
mcp-midtransEditor & Agent Setup
VS Code + GitHub Copilot
Create or update .vscode/mcp.json in your workspace root:
Using uvx (recommended):
{
"servers": {
"midtrans": {
"type": "stdio",
"command": "uvx",
"args": ["mcp-midtrans"]
}
}
}Using Docker:
{
"servers": {
"midtrans": {
"type": "stdio",
"command": "docker",
"args": ["run", "-i", "--rm", "mcp-midtrans"]
}
}
}How to use:
Open VS Code with the workspace containing
.vscode/mcp.json.Open Copilot Chat (
Ctrl+Shift+I/Cmd+Shift+I).Switch to Agent mode (not Chat or Edit mode).
The MCP tools appear automatically ā ask about Midtrans and Copilot calls the tools.
Example prompts:
"Help me integrate GoPay payment in my Django app"
"Show me how to handle Midtrans webhooks in Express"
"What's the charge request format for BCA Virtual Account?"
Claude Code (CLI)
Add to your project's .mcp.json (project root) or ~/.claude/mcp.json (global):
Using uvx:
{
"mcpServers": {
"midtrans": {
"command": "uvx",
"args": ["mcp-midtrans"]
}
}
}Using Docker:
{
"mcpServers": {
"midtrans": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp-midtrans"]
}
}
}How to use:
Start Claude Code:
claudeThe MCP server connects automatically on startup.
Verify with:
/mcpā you should seemidtranslisted with 10 tools.Ask about Midtrans ā Claude will use the tools automatically:
"Integrate Midtrans Snap checkout into my FastAPI app"
"Generate a BNI VA charge request with customer details"
"How do I verify Midtrans webhook signatures in Go?"
Claude Desktop
Edit the config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"midtrans": {
"command": "uvx",
"args": ["mcp-midtrans"]
}
}
}Restart Claude Desktop after saving. The š§ icon should show the Midtrans tools.
Cursor
Create .cursor/mcp.json in your workspace root:
{
"mcpServers": {
"midtrans": {
"command": "uvx",
"args": ["mcp-midtrans"]
}
}
}Open Cursor Settings ā Features ā MCP to verify the server is active.
Development Guide
Project Structure
mcp-midtrans/
āāā src/
ā āāā mcp_midtrans/
ā āāā __init__.py # Package version
ā āāā server.py # MCP server, tool definitions, input models
ā āāā knowledge_base.py # All Midtrans documentation (~3500 lines)
ā āāā tools/
ā āāā __init__.py
āāā docs/
ā āāā DIAGRAMS.md # Mermaid architecture & workflow diagrams
āāā pyproject.toml # Build config, dependencies, entry point
āāā Dockerfile # Docker image (Python 3.12 + uv)
āāā docker-compose.yml # Docker Compose config
āāā .vscode/
ā āāā mcp.json # VS Code MCP config (local dev)
āāā .gitignore
āāā README.md # This fileKey Files
File | Purpose |
| FastMCP server initialization, 10 tool handlers, Pydantic input models, enums |
| Complete embedded Midtrans docs ā all API refs, 15 payment methods, 5 language examples, 14 JSON schemas |
| Project metadata, deps ( |
Local Development
# Clone and set up
git clone https://github.com/your-org/mcp-midtrans.git
cd mcp-midtrans
# Create virtual environment with uv
uv venv
source .venv/bin/activate
# Install in editable mode
uv pip install -e .
# Run the server
mcp-midtrans
# Test with MCP Inspector (interactive tool testing)
npx @modelcontextprotocol/inspector mcp-midtransMCP Inspector opens a web UI where you can:
See all registered tools and their input schemas
Send test requests with custom parameters
View formatted responses in real-time
Adding New Tools
Define input model in
server.py:
class GetMyNewGuideInput(BaseModel):
model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
topic: str = Field(..., description="The topic to look up")Add documentation to
knowledge_base.py:
MY_NEW_GUIDE = """
# My New Documentation Section
...
"""Register the tool in
server.py:
@mcp.tool(
name="midtrans_get_my_new_guide",
annotations={"readOnlyHint": True, "destructiveHint": False, "idempotentHint": True},
)
async def midtrans_get_my_new_guide(params: GetMyNewGuideInput) -> str:
"""Description of what this tool returns."""
return MY_NEW_GUIDEImport the new constant in the server's import block.
Adding Documentation Content
All documentation lives in knowledge_base.py as Python string constants and dicts:
Variable | Type | Content |
|
| Products, environments, auth intro |
|
| Auth setup with code examples |
|
| Complete endpoint reference table |
|
| 15 payment method guides (key = method name) |
|
| 14 JSON schema references (key = object type) |
|
| 5 language examples (keys: python, django, nodejs, go, php) |
|
| Status code tables (key = range like "2xx") |
To add content, append to the relevant constant or add a new entry to the dict.
Testing
# Syntax check
python -m py_compile src/mcp_midtrans/server.py
python -m py_compile src/mcp_midtrans/knowledge_base.py
# Verify tools register correctly
python -c "
from mcp_midtrans.server import mcp
tools = [t.name for t in mcp._tool_manager._tools.values()]
print(f'{len(tools)} tools registered:')
for t in tools:
print(f' - {t}')
"
# Verify languages
python -c "
from mcp_midtrans.knowledge_base import IMPLEMENTATION_EXAMPLES
print('Languages:', list(IMPLEMENTATION_EXAMPLES.keys()))
"
# Interactive testing
npx @modelcontextprotocol/inspector mcp-midtransProduction Deployment
Docker Production Build
# Build with tag
docker build -t mcp-midtrans:latest .
# Tag for registry
docker tag mcp-midtrans:latest ghcr.io/your-org/mcp-midtrans:latest
# Push to container registry
docker push ghcr.io/your-org/mcp-midtrans:latestThen users configure their MCP clients with Docker:
{
"mcpServers": {
"midtrans": {
"command": "docker",
"args": ["run", "-i", "--rm", "ghcr.io/your-org/mcp-midtrans:latest"]
}
}
}Publishing to PyPI
# Build distribution
uv build
# Upload to PyPI
uv publish
# or: twine upload dist/*After publishing, users can run directly without cloning:
uvx mcp-midtransCI/CD
Example GitHub Actions workflow (.github/workflows/ci.yml):
name: Build & Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- run: uv venv && source .venv/bin/activate && uv pip install -e .
- run: |
source .venv/bin/activate
python -m py_compile src/mcp_midtrans/server.py
python -m py_compile src/mcp_midtrans/knowledge_base.py
python -c "from mcp_midtrans.server import mcp; assert len(list(mcp._tool_manager._tools)) == 10"
docker:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- run: docker build -t mcp-midtrans .Coverage & Content
Documentation Topics (15)
Topic | Covers |
Overview | Products, environments, auth, key concepts |
Authorization | API keys, Basic Auth, code in 5 languages |
HTTP Request | Base URLs, headers, idempotency |
API Endpoints | Full endpoint table (Payment, Card, GoPay, Subscription, Snap, PayLink, Invoice) |
Snap | Backend + frontend integration, Snap.js, redirect flow |
Charge | Core API charge with all features |
Payment Methods | Complete list with types and categories |
Notification | Webhooks, signature verification, status mapping |
Transaction Mgmt | Get status, cancel, expire, refund, capture |
Subscription | Create / get / update / enable / disable / cancel |
Payment Link | Create / get / delete |
Invoicing | Create / get / void |
Merchant Balance | Balance mutation API |
Testing | Sandbox credentials, test cards, simulation |
Status Codes | 2xx, 3xx, 4xx, 5xx with troubleshooting |
Payment Methods (15)
Credit Card Ā· GoPay Ā· QRIS Ā· ShopeePay Ā· OVO Ā· BCA VA Ā· BNI VA Ā· BRI VA Ā· Permata VA Ā· CIMB VA Ā· Mandiri Bill Ā· Indomaret Ā· Alfamart Ā· Akulaku Ā· Kredivo
Code Examples (5 Languages)
Language | Includes |
Python | Flask, FastAPI, midtransclient library, manual HTTP client |
Django | Models, views (FBV), DRF serializers + ViewSets, service layer, Snap template, management commands |
Node.js | Express, midtrans-client library |
Go | net/http, manual integration |
PHP | Native, midtrans-php library |
JSON Object Schemas (14)
transaction_details Ā· customer_details Ā· item_details Ā· seller_details Ā· custom_expiry Ā· credit_card Ā· gopay Ā· shopeepay Ā· bank_transfer Ā· echannel Ā· qris Ā· ovo Ā· convenience_store Ā· action
Diagrams
Full architecture and workflow diagrams with dark theme styling are in docs/DIAGRAMS.md:
System Architecture ā How AI clients connect to the MCP server
Tool Request Flow ā Sequence diagram of a typical interaction
Payment Integration Flow ā What the MCP teaches about Midtrans Snap integration
Knowledge Base Structure ā Mind map of all documentation content
Deployment Options ā Docker and uvx deployment flows
Tool Coverage Map ā How the 10 tools map to documentation areas
License
MIT
Available Tools
9 toolsmidtrans_get_charge_exampleARead-onlyIdempotent
Generate a complete charge request JSON example for a specific payment method.
Creates a ready-to-use charge request body with all required fields and optionally includes customer_details and item_details.
Args: params: Contains payment method, and flags for optional sections.
Returns: str: Complete charge request JSON example with curl command and response format.
Inputs: params (required). Returns: result
midtrans_get_code_exampleARead-onlyIdempotent
Get complete implementation code examples for Midtrans Core API integration in a specific programming language.
Includes: charge transactions, transaction status checks, cancellation, refunds, notification/webhook handlers with signature verification, and subscription management.
Available languages: python (requests/Flask/FastAPI), javascript (fetch/Express with TypeScript types), go (net/http), rust (reqwest/actix-web/axum).
Args: params: Contains the programming language.
Returns: str: Complete code examples including imports, configuration, API calls, and webhook handlers.
Inputs: params (required). Returns: result
midtrans_get_documentationARead-onlyIdempotent
Get detailed documentation for a specific Midtrans Core API topic.
Covers: overview, authorization, HTTP requests, API endpoints, charge transactions, payment methods list, notifications, transaction management, transaction status guide, channel response codes, subscriptions, payment links, invoicing, merchant balance, testing credentials, and status codes.
Args: params: Contains the topic to retrieve documentation for.
Returns: str: Detailed documentation for the requested topic including explanations, code examples, request/response formats, and best practices.
Inputs: params (required). Returns: result
midtrans_get_documentation_mapARead-onlyIdempotent
Get the complete Midtrans Core API documentation map showing all available topics, APIs, payment methods, and guides. Use this as your starting point to understand what documentation is available and navigate to specific topics.
Returns: str: Complete documentation map with categorized links to all Midtrans Core API documentation topics including APIs, payment methods, and guides.
Inputs: params (required). Returns: result
midtrans_get_json_object_schemaBRead-onlyIdempotent
Get the detailed JSON object schema for Midtrans API request/response objects.
Includes field definitions, types, required status, descriptions, and example JSON for each object type.
Available objects: transaction_details, customer_details, item_details, seller_details, custom_expiry, credit_card_object, gopay_object, shopeepay_object, bank_transfer_object, echannel_object, qris_object, ovo_object, convenience_store_object, action_object, payment_amount_object, dana_object, google_pay_object.
Args: params: Contains the object type to get schema for.
Returns: str: Detailed schema with field table, example JSON, and usage notes.
Inputs: params (required). Returns: result
midtrans_get_notification_handlerARead-onlyIdempotent
Get a complete notification/webhook handler implementation for a specific programming language.
Includes: signature verification, transaction status handling, idempotent processing, and error handling.
Available languages: python, javascript, go, rust.
Args: params: Contains the programming language.
Returns: str: Complete webhook handler code with signature verification and all transaction status cases.
Inputs: params (required). Returns: result
midtrans_get_payment_method_guideARead-onlyIdempotent
Get a complete integration guide for a specific Midtrans payment method.
Includes charge request format, response format, integration flow, special features, and sandbox testing information.
Supported: credit_card, gopay, qris, shopeepay, ovo, dana, google_pay, bca_va, bni_va, bri_va, permata_va, mandiri_bill, cimb_va, indomaret, alfamart, akulaku, kredivo.
Args: params: Contains the payment method to get the guide for.
Returns: str: Complete integration guide with request/response examples, flow descriptions, and payment-method-specific notes.
Inputs: params (required). Returns: result
midtrans_get_status_codesARead-onlyIdempotent
Get Midtrans HTTP status code reference for a specific range.
Includes status code numbers, descriptions, common scenarios, and troubleshooting tips.
Args: params: Contains the status code range (2xx, 3xx, 4xx, or 5xx).
Returns: str: Status code reference table with descriptions and handling guidance.
Inputs: params (required). Returns: result
midtrans_search_documentationARead-onlyIdempotent
Search across all Midtrans Core API documentation for relevant information.
Searches through all documentation topics, payment method guides, JSON schemas, code examples, and reference materials.
Use this when you need to find specific information across multiple documentation sections or when unsure which topic contains the answer.
Args: params: Contains the search query string.
Returns: str: Matching documentation sections with relevant content.
Inputs: params (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 9 tools
Tools are mostly distinct in purpose, though slight overlap exists between midtrans_get_code_example (which includes webhook handlers among broader integration code) and midtrans_get_notification_handler (focused specifically on webhooks). The charge example and payment method guide tools also share related content but serve different use cases (JSON generation vs. comprehensive guides).
Eight tools follow the consistent pattern midtrans_get_<resource>, while midtrans_search_documentation uses a different verb (search instead of get). Otherwise, all use lowercase snake_case consistently and include the midtrans prefix, making the deviation minor and the overall pattern predictable.
Nine tools is well-suited for a documentation server, covering code examples, JSON schemas, payment method guides, status references, search capability, documentation navigation, and specialized handlers without being excessive or sparse.
The surface covers documentation retrieval comprehensively with topics, schemas, examples, guides, and search. Minor gaps might include specialized resources like SDK-specific documentation or changelogs, though these may be accessible via the general documentation topic parameter.
Maintenance
Related MCP Connectors
Indonesia payments for AI agents ā GoPay, QRIS, Alfamart, bank VA via Midtrans. Never holds funds.
Vietnam payments for AI agents ā MoMo wallet QR, ATM, cards. Zero-setup sandbox. Never holds funds.
Indonesian public data, QRIS, rupiah and AI model status tools. No API key needed.
Connect your AI agent to 300+ methods and 100+ live tools
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with access to comprehensive Safaricom Daraja API documentation for all 22 M-Pesa APIs through searchable tools, enabling developers to query payment processing, transaction management, and business operations documentation.17MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI coding tools to search and retrieve Bootpay payment and commerce developer documentation, including integration guides and customer service manuals. It facilitates tasks such as payment linking, billing key issuance, and webhook configuration through natural language queries.2-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to accept Indonesian payments including GoPay, QRIS, ShopeePay, DANA, bank transfers, and convenience store payments via Midtrans Snap's hosted checkout.MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to build PayRetailers cross-border payment integrations accurately by providing official documentation, endpoint specs, country-specific payload validation, webhook guidance, and integration prompts as MCP resources, tools, and prompts.7MIT