MCP client library for Python — like paramiko, but for MCP servers
Project description
mcpiko
MCP client library for Python — like paramiko, but for MCP servers.
Connect to any Model Context Protocol server and call its tools as native Python methods. No boilerplate, no JSON-RPC plumbing.
from mcpiko import MCPClient
client = MCPClient("http://server:9765", api_key="secret")
print(client.tools())
# ['server_status', 'get_logs', 'active_devices', 'risk_snapshot', ...]
print(client.server_status())
# === CONTAINERS ===
# hos_web Up 3 hours (healthy) 0.0.0.0:80->8000/tcp
# hos_redis Up 3 hours (healthy) 127.0.0.1:6379->6379/tcp
# ...
print(client.active_devices())
# DEVICE ST BALANCE EQUITY MARGIN LICENSE
# ────────────────────────────────────────────────────────────────
# 5f3d88f149… 🟢 $ 100001.76 $ 100001.76 $ 0.00 ACTIVE
Why
paramiko lets you SSH into a server and run commands. mcpiko lets you connect to an MCP server and call structured tools — with proper argument types, auto-generated Python methods, and clean error handling.
paramiko: SSH → raw shell commands
mcpiko: MCP → typed tool calls → Python methods
Install
pip install mcpiko # HTTP transport (default)
pip install mcpiko[ssh] # + SSH transport (paramiko)
Connection modes
HTTP (remote server with exposed port)
from mcpiko import MCPClient
with MCPClient("http://server:9765", api_key="your-key") as client:
print(client.risk_snapshot())
print(client.get_logs(source="app", lines=100))
SSH (no port needed — runs script on remote host)
client = MCPClient.from_ssh(
"root@135.181.25.224",
key_file="~/.ssh/id_ed25519",
script="/opt/app/deploy/mcp_server.py",
)
print(client.active_devices())
client.close()
Environment variables
export MCPIKO_SSH_HOST=135.181.25.224
export MCPIKO_SSH_KEY=~/.ssh/id_ed25519
export MCPIKO_SCRIPT=/opt/app/deploy/mcp_server.py
client = MCPClient.from_env()
CLI
# List tools
mcpiko http://server:9765 --key SECRET tools
# Call a tool
mcpiko http://server:9765 --key SECRET call server_status
mcpiko http://server:9765 --key SECRET call get_logs --source app --lines 50
# Via SSH
mcpiko root@server --ssh-key ~/.ssh/id_ed25519 call active_devices
Tool discovery
client = MCPClient("http://server:9765", api_key="...")
# All available tools
print(client.tools())
# Tool signature
print(client.tool_info("get_logs"))
# {'name': 'get_logs', 'description': '...', 'inputSchema': {...}}
# Call by name (dynamic)
result = client.call("get_logs", source="app", lines=50)
Error handling
from mcpiko import MCPClient, MCPAuthError, MCPToolError, MCPConnectionError
try:
client = MCPClient("http://server:9765", api_key="wrong-key")
except MCPAuthError:
print("Bad API key")
try:
result = client.call("unknown_tool")
except MCPToolError as e:
print(f"Tool failed: {e}")
Roadmap
- v0.1.0 — HTTP transport, auto-discovery, dynamic methods, SSH transport, CLI
- v0.2.0 — Persistent SSH session, async client (
AsyncMCPClient), streaming - v0.3.0 — Tool schema validation, retry logic, connection pooling
- v1.0.0 — Stable API, full test suite, type stubs
License
MIT
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 mcpiko-0.1.0.tar.gz.
File metadata
- Download URL: mcpiko-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f2b2fca203c1a29c7bc03ed8121e6b07eae6e64b1aba875ffbc4a72f583fc02
|
|
| MD5 |
8de1491d73d541ee29c59b790a6a277f
|
|
| BLAKE2b-256 |
64f4ab4ab247e6d76d2037654f402b63f187929770a53d8b6286a4cb421f75d0
|
File details
Details for the file mcpiko-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcpiko-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd8a8c9a8e97e6c462a9466ed04554d25abb22d1f2b0ac92c8eced4173c9566a
|
|
| MD5 |
134af109003deef9a38326d136adc97e
|
|
| BLAKE2b-256 |
cb9fd4a1b1d35f8ae673e99acd08aa23b753b85c9e54be1fbb6195461cb3af08
|