1
Initialize PayLink client
Import and initialize the PayLink client:
2
List available tools
List all available tools to verify your connection:Example response:
Tool Attributes
Tool Attributes
string
required
The unique identifier for the tool (e.g.,
"stk_push").string | None
Optional display title for the tool.
string
A human-readable description of what the tool does.
dict
required
JSON schema defining the required and optional parameters for the tool. Contains
type, properties, and required fields.dict | None
JSON schema defining the expected output format of the tool.
list | None
Optional list of icon identifiers for the tool.
list | None
Optional list of annotations or metadata associated with the tool.
dict | None
Additional metadata about the tool.
3
Invoke a tool
The tool name is Now call the tool:Example response:
mpesa. The tool requires the following parameters:Response Attributes
Response Attributes
dict | None
Optional metadata associated with the response.
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.dict | None
Optional structured representation of the response content.
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
- Your
PAYLINK_API_KEYis valid and active - Your
PAYLINK_PROJECTmatches the project name in your dashboard - Your M-Pesa Daraja credentials are correct
- Your
MPESA_BASE_URLpoints to the correct environment (sandbox or production)