How to integrate Proabono MCP with Pydantic AI

Connect Pydantic AI to Proabono MCP. List all active subscriptions for a customer, create a new subscription for acme corp, and more using natural language, with authentication handled for you.

Proabono logoProabono
Basic

Proabono is a smart subscription management platform that automates billing and recurring payments. It streamlines your subscription operations and customer lifecycle.

64 Tools

Introduction

This guide walks you through connecting Proabono to Pydantic AI using the Composio tool router. By the end, you'll have a working Proabono agent that can manage customers and subscriptions, bill customers, track usage records, list invoices and payments, and update billing addresses through natural language commands.

This guide will help you understand how to give your Pydantic AI agent real control over a Proabono account through Composio's Proabono MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

For exact tool slugs and parameter tables, see the tool catalog in the Composio docs.

Also integrate Proabono with

TL;DR

Here's what you'll learn:
  • How to set up your Composio API key and User ID
  • How to create a Composio Tool Router session for Proabono
  • How to attach an MCP Server to a Pydantic AI agent
  • How to stream responses and maintain chat history
  • How to build a simple REPL-style chat interface to test your Proabono workflows

What is Pydantic AI?

Pydantic AI is a Python framework for building AI agents with strong typing and validation. It leverages Pydantic's data validation capabilities to create robust, type-safe AI applications.

Key features include:

  • Type Safety: Built on Pydantic for automatic data validation
  • MCP Support: Native support for Model Context Protocol servers
  • Streaming: Built-in support for streaming responses
  • Async First: Designed for async/await patterns

What is the Proabono MCP server, and what's possible with it?

The Proabono MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Proabono account. It provides structured and secure access to your customers, subscriptions, offers, invoices, payments, and features, so your agent can create and update customers, review subscriptions, inspect billing activity, and compare offers on your behalf.

  • Customer account management: Have your agent create customers, find existing customer records, update account details, and review billing addresses.
  • Subscription monitoring: Let the agent list subscriptions or find the subscription associated with a specific customer.
  • Invoice and payment review: Direct your agent to list payments, inspect invoices and credit notes, or retrieve a specific billing document.
  • Offer and feature discovery: Instruct your agent to list available subscription offers and features, then retrieve more details about a selected offer.
  • Payment settings and discounts: Have your agent review or update customer payment settings and remove discounts from subscriptions when needed.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Step by step09 STEPS
1

Prerequisites

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account with an active API key
  • Basic familiarity with Python and async programming
2

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.
3

Install dependencies

bash
pip install composio pydantic-ai python-dotenv

Install the required libraries.

What's happening:

  • composio connects your agent to external SaaS tools like Proabono
  • pydantic-ai lets you create structured AI agents with tool support
  • python-dotenv loads your environment variables securely from a .env file
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates your agent to Composio's API
  • USER_ID associates your session with your account for secure tool access
  • OPENAI_API_KEY to access OpenAI LLMs
5

Import dependencies

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP

load_dotenv()
What's happening:
  • We load environment variables and import required modules
  • Composio manages connections to Proabono
  • MCPServerStreamableHTTP connects to the Proabono MCP server endpoint
  • Agent from Pydantic AI lets you define and run the AI assistant
6

Create a Tool Router Session

python
async def main():
    api_key = os.getenv("COMPOSIO_API_KEY")
    user_id = os.getenv("USER_ID")
    if not api_key or not user_id:
        raise RuntimeError("Set COMPOSIO_API_KEY and USER_ID in your environment")

    # Create a Composio Tool Router session for Proabono
    composio = Composio(api_key=api_key)
    session = composio.create(
        user_id=user_id,
        toolkits=["proabono"],
    )
    url = session.mcp.url
    if not url:
        raise ValueError("Composio session did not return an MCP URL")
What's happening:
  • We're creating a Tool Router session that gives your agent access to Proabono tools
  • The create method takes the user ID and specifies which toolkits should be available
  • The returned session.mcp.url is the MCP server URL that your agent will use
7

Initialize the Pydantic AI Agent

python
# Attach the MCP server to a Pydantic AI Agent
proabono_mcp = MCPServerStreamableHTTP(url, headers={"x-api-key": COMPOSIO_API_KEY})
agent = Agent(
    "openai:gpt-5",
    toolsets=[proabono_mcp],
    instructions=(
        "You are a Proabono assistant. Use Proabono tools to help users "
        "with their requests. Ask clarifying questions when needed."
    ),
)
What's happening:
  • The MCP client connects to the Proabono endpoint
  • The agent uses GPT-5 to interpret user commands and perform Proabono operations
  • The instructions field defines the agent's role and behavior
8

Build the chat interface

python
# Simple REPL with message history
history = []
print("Chat started! Type 'exit' or 'quit' to end.\n")
print("Try asking the agent to help you with Proabono.\n")

while True:
    user_input = input("You: ").strip()
    if user_input.lower() in {"exit", "quit", "bye"}:
        print("\nGoodbye!")
        break
    if not user_input:
        continue

    print("\nAgent is thinking...\n", flush=True)

    async with agent.run_stream(user_input, message_history=history) as stream_result:
        collected_text = ""
        async for chunk in stream_result.stream_output():
            text_piece = None
            if isinstance(chunk, str):
                text_piece = chunk
            elif hasattr(chunk, "delta") and isinstance(chunk.delta, str):
                text_piece = chunk.delta
            elif hasattr(chunk, "text"):
                text_piece = chunk.text
            if text_piece:
                collected_text += text_piece
        result = stream_result

    print(f"Agent: {collected_text}\n")
    history = result.all_messages()
What's happening:
  • The agent reads input from the terminal and streams its response
  • Proabono API calls happen automatically under the hood
  • The model keeps conversation history to maintain context across turns
9

Run the application

python
if __name__ == "__main__":
    asyncio.run(main())
What's happening:
  • The asyncio loop launches the agent and keeps it running until you exit

Complete Code

Here's the complete code to get you started with Proabono and Pydantic AI:

python
import asyncio
import os
from dotenv import load_dotenv
from composio import Composio
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP

load_dotenv()

async def main():
    api_key = os.getenv("COMPOSIO_API_KEY")
    user_id = os.getenv("USER_ID")
    if not api_key or not user_id:
        raise RuntimeError("Set COMPOSIO_API_KEY and USER_ID in your environment")

    # Create a Composio Tool Router session for Proabono
    composio = Composio(api_key=api_key)
    session = composio.create(
        user_id=user_id,
        toolkits=["proabono"],
    )
    url = session.mcp.url
    if not url:
        raise ValueError("Composio session did not return an MCP URL")

    # Attach the MCP server to a Pydantic AI Agent
    proabono_mcp = MCPServerStreamableHTTP(url, headers={"x-api-key": COMPOSIO_API_KEY})
    agent = Agent(
        "openai:gpt-5",
        toolsets=[proabono_mcp],
        instructions=(
            "You are a Proabono assistant. Use Proabono tools to help users "
            "with their requests. Ask clarifying questions when needed."
        ),
    )

    # Simple REPL with message history
    history = []
    print("Chat started! Type 'exit' or 'quit' to end.\n")
    print("Try asking the agent to help you with Proabono.\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "bye"}:
            print("\nGoodbye!")
            break
        if not user_input:
            continue

        print("\nAgent is thinking...\n", flush=True)

        async with agent.run_stream(user_input, message_history=history) as stream_result:
            collected_text = ""
            async for chunk in stream_result.stream_output():
                text_piece = None
                if isinstance(chunk, str):
                    text_piece = chunk
                elif hasattr(chunk, "delta") and isinstance(chunk.delta, str):
                    text_piece = chunk.delta
                elif hasattr(chunk, "text"):
                    text_piece = chunk.text
                if text_piece:
                    collected_text += text_piece
            result = stream_result

        print(f"Agent: {collected_text}\n")
        history = result.all_messages()

if __name__ == "__main__":
    asyncio.run(main())

Conclusion

You've built a Pydantic AI agent that can interact with Proabono through Composio's Tool Router. With this setup, your agent can perform real Proabono actions through natural language. You can extend this further by:
  • Adding other toolkits like Gmail, HubSpot, or Salesforce
  • Building a web-based chat interface around this agent
  • Using multiple MCP endpoints to enable cross-app workflows (for example, Gmail + Proabono for workflow automation)
This architecture makes your AI agent "agent-native", able to securely use APIs in a unified, composable way without custom integrations.
TOOLS

Supported Tools

Every Proabono action and event your agent gets out of the box.

Anonymize Customer

Tool to anonymize a customer for GDPR compliance.

Bill Customer

Bills a customer's balance using the customer reference, normally creating an invoice for all available balance lines.

Create Customer

Tool to create or declare a customer in ProAbono via the Backoffice API.

Create Feature

Tool to create a new feature in ProAbono via the Backoffice API.

Delete Customer

Tool to delete a customer from ProAbono by ID.

Delete Offer

Tool to delete an offer from ProAbono by ID.

Delete Pricing Table

Tool to delete a pricing table from ProAbono by its ID.

Delete Pricing Table Offer

Tool to delete a pricing table offer via the ProAbono Backoffice API.

Delete Subscription Discount

Delete a subscription discount by its ID via the ProAbono Backoffice API.

Enable Webhook

Tool to enable a webhook in ProAbono via the Notification API.

Get Customer by ID

Requests a single customer by ID using the ProAbono Live API.

Get Customer Billing Address

Tool to retrieve a customer's billing address via the Backoffice API.

Get Customer Billing Address by Reference

Tool to retrieve the billing address for a customer by reference from ProAbono API.

Get Customer by Reference

Tool to retrieve a customer by their reference identifier from ProAbono API.

Get Customer Payment Settings

Retrieves a customer's payment settings by customer reference through the ProAbono Live API, including payment method type and next billing date.

Get Discount

Retrieve a specific discount by ID and business ID from the ProAbono Backoffice API.

Get Feature by ID

Retrieve a ProAbono feature by ID to inspect its details, such as its name, type, visibility, and lifecycle state.

Get Invoice

Tool to retrieve a specific invoice or credit note by ID from ProAbono.

Get Offer by ID

Request details of a single ProAbono offer using an offer ID and business ID.

Get Subscription by Customer Reference

Retrieve a customer's active subscription by customer reference.

Get Subscription Creation Quote

Tool to get a pricing quote for creating a new subscription without actually creating it.

Get Usage Record

Tool to retrieve a single usage record for a specific feature and customer combination from ProAbono.

Get Usages for Customer

Tool to retrieve usage data for customers from ProAbono.

Invalidate Customer

Invalidate a customer by reference, replacing the customer reference so it can be reused and revoking existing portal links.

Invalidate Customer by ID

Tool to invalidate a customer by their ProAbono internal ID.

List Balance Lines

List ProAbono balance lines for a customer reference or subscription ID, with pagination.

List Businesses

Tool to list all businesses from ProAbono via the Backoffice API.

List Business Localization

Tool to list localization entries by business from ProAbono via the HostedPages API.

List Customer Moves

Lists customer balance moves through the ProAbono Backoffice API, with pagination and filters for customer, unbilled status and minimum update date.

List Customers

Tool to list all customers from ProAbono via the Backoffice API.

List Customers by Feature

List customers with active subscriptions containing a specified feature, with feature usage and billing-period details.

List Discounts

Tool to list all discounts from ProAbono's Backoffice API.

List Features

Tool to list all features via the ProAbono Backoffice API.

List Gateway Accounts

Tool to list payment gateway accounts from ProAbono Backoffice API.

List Gateway Permissions

Tool to list gateway permissions from ProAbono API.

List Gateway Requests

Tool to list gateway requests from ProAbono.

List Gateway Transactions

Tool to list gateway transactions from ProAbono.

List Invoice Lines

List a page of invoice lines from the ProAbono Backoffice API, optionally filtered by business, invoice, or minimum amount.

List Invoices and Credit Notes

List invoices and credit notes from the ProAbono Backoffice API, with pagination and optional filters for business, technical invoice state, and minimum payment date.

List Invoices by Customer Reference

Tool to list invoices for a specific customer by their reference identifier from ProAbono API.

List Offers

Tool to list all subscription offers (plans) from ProAbono Backoffice API.

List Payments

Tool to list all payments from ProAbono Backoffice API.

List Pricing Table Offers

Tool to list all pricing table offers via the ProAbono Backoffice API.

List Pricing Tables

Tool to list all pricing tables from ProAbono Backoffice API.

List Segment Localizations

Tool to list localization entries by segment from ProAbono Backoffice API.

List Segments

Tool to list all segments from ProAbono via the Backoffice API.

List Subscription Discounts

List subscription-discount associations for a business via the ProAbono Backoffice API.

List Subscription Features

Tool to list all subscription features via the ProAbono Backoffice API.

List Subscription Periods

Tool to list all subscription periods (billing cycles) from ProAbono Backoffice API.

List Subscriptions

Tool to list all subscriptions from ProAbono via the Backoffice API.

List Tax Profile Exceptions

Tool to list tax profile exceptions from ProAbono Organization API.

List Tax Profiles

Tool to list all tax profiles from ProAbono via the Backoffice API.

List Upgrade Offers

List offers for a customer by reference, with optional pagination and an UpgradeOnly query parameter.

List Webhook Notifications

List webhook notification history for a business, with optional segment, date range, state, or webhook ID filters.

List Webhooks

Tool to list webhooks from ProAbono Notification API.

Quote Balance Line Creation

Request a pricing quote for a customer's proposed balance line, such as a one-time charge or credit.

Revoke Customer Portal Links

Tool to revoke encrypted customer portal links and generate new ones in ProAbono.

Update Business Billing Address

Tool to update business billing address via the Backoffice API.

Update Customer

Tool to update an existing customer in ProAbono via the Backoffice API.

Update Customer Billing Address

Tool to update the billing address for a customer in ProAbono via the API.

Update Customer Payment Settings

Update a customer's payment method using their customer reference in ProAbono.

Update Customer Shipping Address

Tool to update customer shipping address via the Backoffice API.

Update Feature

Tool to update an existing feature in ProAbono via the Backoffice API.

Update Tax Profiles

Tool to update an existing tax profile in ProAbono via the Backoffice API.

FAQ

Frequently asked questions

Start with Proabono.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Proabono tool your agent needs.Free to start.

Start building