Skip to main content
After configuring your environment, test your M-Pesa payment provider connection to ensure everything is set up correctly.
1

Initialize PayLink client

Import and initialize the PayLink client:
2

List available tools

List all available tools to verify your connection:
Example response:
name
string
required
The unique identifier for the tool (e.g., "stk_push").
title
string | None
Optional display title for the tool.
description
string
A human-readable description of what the tool does.
inputSchema
dict
required
JSON schema defining the required and optional parameters for the tool. Contains type, properties, and required fields.
outputSchema
dict | None
JSON schema defining the expected output format of the tool.
icons
list | None
Optional list of icon identifiers for the tool.
annotations
list | None
Optional list of annotations or metadata associated with the tool.
meta
dict | None
Additional metadata about the tool.
3

Invoke a tool

The tool name is mpesa. The tool requires the following parameters:
Now call the tool:
Example response:
meta
dict | None
Optional metadata associated with the response.
content
list
required
List of content blocks returned by the tool. Each block contains the response data, typically as TextContent objects with the tool’s output.
structuredContent
dict | None
Optional structured representation of the response content.
isError
boolean
required
Indicates whether the tool invocation resulted in an error. False means the call was successful.

Expected Results

If your configuration is correct, you should see:
  • ✓ Tools listed successfully (including stk_push)
  • ✓ Tool invocation returns a success response with checkout_request_id
  • ✓ Payment prompt sent to the specified phone number
If you encounter errors, verify:
  • Your PAYLINK_API_KEY is valid and active
  • Your PAYLINK_PROJECT matches the project name in your dashboard
  • Your M-Pesa Daraja credentials are correct
  • Your MPESA_BASE_URL points to the correct environment (sandbox or production)
Use sandbox credentials while testing to avoid live charges.

Next Steps

Now that your payment provider is working correctly, you’re ready to build your agent. Proceed to Build Agent to integrate PayLink into your AI agent workflow.