Skip to main content

Complete Python SDK for CzechFabric MCP - Perfect mirror of backend with all 13 tools, type-safe models, and TONE format support

Project description

CzechFabric SDK

Complete Python SDK for CzechFabric MCP - Perfect mirror of backend system

PyPI version Python 3.9+ License: MIT Tests Lint Parity Check Documentation PyPI downloads

The CzechFabric SDK provides a complete, type-safe interface to all CzechFabric backend tools. All 13 tools are implemented with exact parameter and schema matching.

Features

  • 13 Tools - Complete coverage of all backend tools
  • Type-Safe - Full Pydantic models matching backend exactly
  • Format Support - TONE (40-60% token savings), JSON, and both formats
  • Async & Sync - Use async/await or synchronous wrappers
  • Validation - Input validation before API calls
  • Error Handling - Comprehensive exception types
  • Version Checking - Automatic compatibility checks
  • Production Ready - Comprehensive testing and documentation

Installation

pip install czechfabric-sdk

Quick Start

Async Usage

import asyncio
from czechfabric_sdk import CzechFabricClient, TransportMode

async def main():
    client = CzechFabricClient(
        api_key="your-api-key",
        base_url="https://mcp.czechfabric.cz"
    )
    
    # Get departures
    result = await client.get_departures(
        stop_name="Anděl",
        mode=TransportMode.METRO,
        max_results=10,
        format="json"
    )
    print(result)

asyncio.run(main())

Sync Usage

from czechfabric_sdk import SyncCzechFabricClient, TransportMode

client = SyncCzechFabricClient(
    api_key="your-api-key",
    base_url="https://mcp.czechfabric.cz"
)

# Get departures
result = client.get_departures(
    stop_name="Anděl",
    mode=TransportMode.METRO,
    max_results=10
)
print(result)

Helper Methods

# Domain-organized helpers
await client.tools.transport.get_departures("Anděl")
await client.tools.air_quality.current("Karlovo náměstí")
await client.tools.routing.plan_route("A", "B")

Tools

Transport (9 tools)

  • Departures: get_departures(), departures_by_coordinates(), suggest_departure_stops_nearby()
  • Geocoding: geocode(), reverse_geocode()
  • Stops: find_all_stops_near(), get_stop_metadata(), list_all_stops()
  • Routing: plan_route_mapycz()

Air Quality (4 tools)

  • get_air_quality_near_location() - Current air quality near location
  • get_air_quality_by_district() - Air quality by district
  • get_air_quality_history() - Historical data
  • list_air_quality_components() - List all pollutants

Response Formats

All tools support three response formats:

  • tone (default) - Token-efficient TONE format string
  • json - Standard JSON dict
  • both - Full Pydantic model with both formats

Error Handling

from czechfabric_sdk.exceptions import (
    InvalidAPIKeyError,
    RateLimitExceededError,
    ValidationError,
    NetworkError
)

try:
    result = await client.get_departures("Anděl")
except InvalidAPIKeyError:
    print("Invalid API key")
except RateLimitExceededError:
    print("Rate limit exceeded")
except ValidationError as e:
    print(f"Validation error: {e}")
except NetworkError as e:
    print(f"Network error: {e}")

Version Compatibility

The SDK automatically checks backend compatibility:

# Strict mode - fails on version mismatch
client = CzechFabricClient(
    api_key="key",
    base_url="https://mcp.czechfabric.cz",
    strict_mode=True  # Raises error on mismatch
)

# Normal mode - warns on mismatch
client = CzechFabricClient(
    api_key="key",
    base_url="https://mcp.czechfabric.cz",
    check_version=True  # Warns on mismatch (default)
)

Documentation

Requirements

  • Python 3.9 or higher
  • Valid CzechFabric API key
  • Internet connection

Development

# Clone repository
git clone https://github.com/czechfabric/czechfabric-sdk.git
cd czechfabric-sdk

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run linting
ruff check czechfabric_sdk

# Run type checking
mypy czechfabric_sdk

License

MIT License - see LICENSE file.

Support

Contributing

Contributions welcome! Please see our contributing guidelines.


Made with ❤️ for the Czech Republic

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: czechfabric_sdk-2.0.2.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for czechfabric_sdk-2.0.2.tar.gz
Algorithm Hash digest
SHA256 7d27f07c606e668303b4cba8996ef8308908adb29d5e421473265e330390734e
MD5 f18af88ec6c27a3acb92e43aecfef116
BLAKE2b-256 d5885aba0234581dc162420eb37d5145a5dcd0690cab8d69eaab0fad427945cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for czechfabric_sdk-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9fb9914796f0f0f687ce385faee9d7d82ccf8843b72695670e0d381d1a165f5d
MD5 6d3109d9209660f9ebae1dcdd4688152
BLAKE2b-256 ddcf58bf59f5c589be55cfd1c4387d603f511a351302b99429209651dd1feb4a

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