Skip to main content

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

Metadata

Release files for czechfabric-sdk 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for czechfabric-sdk 2.0.2
File Size Uploaded
czechfabric_sdk-2.0.2.tar.gz 23.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for czechfabric-sdk 2.0.2
File Interpreter ABI Platform
czechfabric_sdk-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 46.8 kB

Release files / czechfabric_sdk-2.0.2.tar.gz

Download URL czechfabric_sdk-2.0.2.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7d27f07c606e668303b4cba8996ef8308908adb29d5e421473265e330390734e
BLAKE2b-256 checksum
How to use checksums
d5885aba0234581dc162420eb37d5145a5dcd0690cab8d69eaab0fad427945cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / czechfabric_sdk-2.0.2-py3-none-any.whl

Download URL czechfabric_sdk-2.0.2-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fb9914796f0f0f687ce385faee9d7d82ccf8843b72695670e0d381d1a165f5d
BLAKE2b-256 checksum
How to use checksums
ddcf58bf59f5c589be55cfd1c4387d603f511a351302b99429209651dd1feb4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

0.2.9

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page