Async Python SDK for CzechFabric MCP server
Project description
🇨🇿 CzechFabric SDK
Async Python SDK for accessing CzechFabric MCP server
✨ Overview
This SDK provides a robust, type-safe, async interface for interacting with a CzechFabric MCP server via FastMCP.
Features:
- ✅ Async operations
- ✅ Automatic retries with exponential backoff
- ✅ In-memory caching
- ✅ Structured logging
- ✅ Rich error handling
🏗 Installation
pip install czechfabric-sdk
Or install locally:
pip install .
⚡ Quickstart
import asyncio
from czechfabric_sdk.client import CzechFabricClient
async def main():
client = CzechFabricClient(
api_key="YOUR_API_KEY",
base_url="https://mcp-server.example.com/mcp"
)
trip = await client.plan_trip("Prague", "Brno")
print("Trip Plan:\n", trip)
departures = await client.get_departures("Florenc")
print("Departures:\n", departures)
geocode = await client.geocode("Karlovo náměstí")
print("Geocode:\n", geocode)
if __name__ == "__main__":
asyncio.run(main())
🚀 API Reference
CzechFabricClient
Initialization
client = CzechFabricClient(
api_key: str,
base_url: str,
timeout: float = 30.0
)
| Param | Type | Description |
|---|---|---|
| api_key | str | Your API key for authentication |
| base_url | str | MCP server base URL |
| timeout | float | Default timeout per request (sec) |
Methods
✅ plan_trip(from_place, to_place)
- Plan a trip between two places.
✅ get_departures(stop_name)
- Retrieve departures for a given stop.
✅ geocode(name, use_cache=True)
- Geocode a place name.
All methods are async and return str.
⚠️ Error Handling
This SDK raises clear, specific exceptions:
InvalidAPIKeyError– invalid or missing API keyRateLimitExceededError– rate limit exceededToolExecutionError– generic execution failureNetworkError– connectivity issues
Example:
from czechfabric_sdk.exceptions import InvalidAPIKeyError
try:
await client.plan_trip("A", "B")
except InvalidAPIKeyError:
print("Your API key is invalid.")
🧠 Caching
By default, geocode() uses in-memory caching via async_lru.
To disable cache:
await client.geocode("Prague", use_cache=False)
🧪 Testing
Install dev dependencies:
pip install pytest pytest-asyncio
Run tests:
pytest
🛠 Development
To build and publish:
python -m build
twine upload dist/*
Or trigger CI/CD by pushing a tag:
git tag v0.1.0
git push --tags
📄 License
MIT License © 2025 Czech Fabric
🤝 Contributing
Issues and PRs welcome!
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 czechfabric_sdk-0.1.1.tar.gz.
File metadata
- Download URL: czechfabric_sdk-0.1.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57a83e7cec102cd49ab5d0399884256a63e5bc3b074052df7cdf18183a2bd96a
|
|
| MD5 |
9ed040465798d0ddc824fff6f9a4e3c0
|
|
| BLAKE2b-256 |
f88fb6131c792d5448ffcc30b12230c228057353b7111d055ad66206eb099ea1
|
File details
Details for the file czechfabric_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: czechfabric_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2798b9bb03d93fe00c6f9557939f5a1b9f0c9bc86bad445b8111be13abd6784
|
|
| MD5 |
643357fa8c30a815bb274400e8e7b420
|
|
| BLAKE2b-256 |
9540961eb33d8618a11b118867e3275f99482af4d06cfc849ae01a4a2d417c20
|