Python SDK for interacting with PayLink MCP servers
Project description
PayLink Python SDK
using y.
Features
- 🚀 Easy-to-use Python SDK for PayLink MCP servers
- 📱 M-Pesa STK Push integration
- 🔧 Tool discovery and execution
- ⚡ Async/await support
- 🛡️ Type hints for better development experience
Installation
pip install paylink
Quick Start
import asyncio
from paylink import PayLink
async def main():
# Initialize the PayLink client
client = PayLink(base_url="http://your-paylink-server:5002/mcp")
# List available tools
tools = await client.list_tools()
print("Available tools:", tools)
# Call a tool (e.g., STK Push)
if "stk_push" in tools:
result = await client.call_tool("stk_push", {
"amount": "100",
"phone_number": "254712345678",
"account_reference": "ORDER123",
"transaction_desc": "Payment"
})
print("Payment result:", result)
if __name__ == "__main__":
asyncio.run(main())
API Reference
PayLink Class
__init__(base_url: str = "http://0.0.0.0:5002/mcp")
Initialize the PayLink client.
Parameters:
base_url(str): The base URL of your PayLink MCP server
async list_tools() -> List[str]
List all available tools from the MCP server.
Returns:
List[str]: A list of available tool names
async call_tool(tool_name: str, args: Dict[str, Any]) -> Any
Call a specific tool exposed by the MCP server.
Parameters:
tool_name(str): The name of the tool to callargs(Dict[str, Any]): Arguments to pass to the tool
Returns:
Any: The result from the tool execution
Examples
STK Push Payment
import asyncio
from paylink import PayLink
async def stk_push_example():
client = PayLink(base_url="http://your-server:5002/mcp")
result = await client.call_tool("stk_push", {
"amount": "100",
"phone_number": "254712345678",
"account_reference": "ORDER123",
"transaction_desc": "Test Payment"
})
print(f"Payment initiated: {result}")
asyncio.run(stk_push_example())
List Available Tools
import asyncio
from paylink import PayLink
async def list_tools_example():
client = PayLink(base_url="http://your-server:5002/mcp")
tools = await client.list_tools()
for tool in tools:
print(f"Available tool: {tool}")
asyncio.run(list_tools_example())
Requirements
- Python 3.10+
- PayLink MCP server running and accessible
Dependencies
mcp[cli]>=1.13.1- Model Context Protocol client
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support and questions, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paylink-0.1.2.tar.gz.
File metadata
- Download URL: paylink-0.1.2.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61031dcbd0152f146e83ef09c030d95cc76af0f5aa968c11c0601ece00f9e322
|
|
| MD5 |
6a18c88c133655655255821ff44a58b2
|
|
| BLAKE2b-256 |
5e4e2fd09cb49ab2698f9159d672c2b04e2d8e4463662c7aac60e5942aae5c96
|
File details
Details for the file paylink-0.1.2-py3-none-any.whl.
File metadata
- Download URL: paylink-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fff7ebeaa8eb5a33caaa1ec173b2b941c98d77ca9dc502041fb771a43d771b9
|
|
| MD5 |
904d38e7e9276962a5c31604d12c7423
|
|
| BLAKE2b-256 |
48eb70416f0d32ed918dfb4f14f7a1f12e5bd783392bf6228443d3e7bfe6d362
|