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.3.tar.gz (5.7 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.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: czechfabric_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 5.7 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.3.tar.gz
Algorithm Hash digest
SHA256 4e2f791e1a4be39f2a50299225db1d37b5678ffae230b552a8153066b9ac3f5b
MD5 ee611fcd017e0249145462c8a83195d7
BLAKE2b-256 b1709c8ab9b20a0b2d3b42c01ff8995e0d0e34a319276304adce10272309f4bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for czechfabric_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ac85c0251ce2d8872a492b35bf6731782420046c92a87173567e3631aa86ed3a
MD5 4b0970999249a618a718fd155cf87dda
BLAKE2b-256 8dc6c0c75f12ce92a67213cf44ee4a49b618d72c621cc658366fd4d7485a0679

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