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
The unique identifier for the tool (e.g.,
"stk_push").Optional display title for the tool.
A human-readable description of what the tool does.
JSON schema defining the required and optional parameters for the tool. Contains
type, properties, and required fields.JSON schema defining the expected output format of the tool.
Optional list of icon identifiers for the tool.
Optional list of annotations or metadata associated with the tool.
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
Optional metadata associated with the response.
List of content blocks returned by the tool. Each block contains the response data, typically as
TextContent objects with the tool’s output.Optional structured representation of the response content.
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)