Skip to main content

Async Python SDK for CzechFabric MCP server

Project description

🇨🇿 CzechFabric SDK

Async Python SDK for accessing CzechFabric MCP server

PyPI CI License


✨ 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 key
  • RateLimitExceededError – rate limit exceeded
  • ToolExecutionError – generic execution failure
  • NetworkError – 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

czechfabric_sdk-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

czechfabric_sdk-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file czechfabric_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: czechfabric_sdk-0.1.0.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

Hashes for czechfabric_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 822754c6c333ec1e4e415c8cdb2ca884fa037de0f1e30c3cb10913fef5e92fe9
MD5 8481e6e20cf92aefe1487e0860f6d479
BLAKE2b-256 61c8acc53b54f5db3fb030d2d5d0156c5492601b5b969e46e45e1e22436dbf87

See more details on using hashes here.

File details

Details for the file czechfabric_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for czechfabric_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb66868d224053b720c80384e798be07e31534a75c37aabb556c4304e5e29751
MD5 972a9b6787f9290c303c660048490fd2
BLAKE2b-256 9eabb159a548f331836cb441fa0e58d10fcd4518867ce4a523f3be966ed7f2e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page