Skip to main content

Keycard Python SDK - A workspace for Keycard service packages

Project description

KeyCard Python SDK

A collection of Python packages for KeyCard services, organized as a uv workspace.

Overview

This workspace contains multiple Python packages that provide various KeyCard functionality:

  • keycardai-oauth: OAuth 2.0 implementation with support for RFC 8693 (Token Exchange), RFC 7662 (Introspection), RFC 7009 (Revocation), and more
  • keycardai-mcp: Core MCP (Model Context Protocol) integration utilities
  • keycardai-mcp-fastmcp: FastMCP-specific integration package with decorators and middleware

Getting Started

Prerequisites

  • Python 3.10 or higher
  • uv package manager
  • just task runner (optional, for convenience commands)

Installation

  1. Clone the repository:
git clone git@github.com:keycardai/python-sdk.git
cd python-sdk
  1. Install the workspace:
uv sync

Documentation

Launch Documentation Server

The project includes comprehensive documentation built with Mint. To view the docs locally:

# Using just (recommended)
just docs

# Or directly with npx
cd docs && npx --yes mint@latest dev

This will start a local documentation server (typically at http://localhost:3000) with:

  • API reference for all packages
  • Usage examples
  • Integration guides
  • Architecture decisions

Generate API Documentation

To regenerate the API reference documentation:

# Generate docs for all packages
just sdk-ref-all

# Or generate for specific packages
just sdk-ref-oauth
just sdk-ref-mcp
just sdk-ref-mcp-fastmcp

Development

This project uses uv workspaces to manage multiple related packages. Each package lives in the packages/ directory and has its own pyproject.toml.

Common Tasks

# Install all dependencies
uv sync

# Run tests
just test
# or: uv run pytest

# Lint and format code
just check          # Check for issues
just fix            # Fix auto-fixable issues
just fix-all        # Fix all issues (including unsafe fixes)

# Type checking
just typecheck
# or: uv run mypy .

# Build packages
just build

Working with the workspace

  • Install all dependencies: uv sync
  • Run commands in the workspace root: uv run <command>
  • Run commands in a specific package: uv run --package <package-name> <command>
  • Add dependencies to the workspace: Add to the root pyproject.toml
  • Add dependencies to a specific package: Add to the package's pyproject.toml

Adding a new package

  1. Create a new directory in packages/
  2. Initialize the package: uv init packages/your-package-name
  3. Update the package's pyproject.toml with appropriate metadata
  4. The package will automatically be included in the workspace

Package Structure

python-sdk/
├── pyproject.toml          # Workspace root configuration
├── justfile               # Task runner commands
├── README.md              # This file
├── docs/                  # Documentation
│   ├── docs.json          # Mint documentation config
│   ├── examples/          # Usage examples
│   ├── sdk/              # Auto-generated API reference
│   └── standards/        # Development standards
├── packages/              # Individual packages
│   ├── oauth/            # OAuth 2.0 implementation
│   ├── mcp/              # Core MCP utilities  
│   └── mcp-fastmcp/      # FastMCP integration
├── src/                   # Workspace-level source
└── uv.lock               # Shared lockfile

Available Packages

keycardai-oauth

OAuth 2.0 client implementation with comprehensive support for:

  • Token Exchange (RFC 8693)
  • Dynamic Client Registration (RFC 7591)
  • Server Metadata Discovery (RFC 8414)
  • Token Introspection (RFC 7662)
  • Token Revocation (RFC 7009)

keycardai-mcp

Core utilities for MCP (Model Context Protocol) integration.

keycardai-mcp-fastmcp

FastMCP-specific integration package providing:

  • Authentication providers
  • OAuth middleware
  • Decorators for token exchange
  • MCP server utilities

Examples

Each package includes practical examples in their respective examples/ directories:

  • OAuth examples: Anonymous token exchange, server discovery, dynamic registration
  • MCP examples: Google API integration with delegated token exchange

Workspace Benefits

Using a uv workspace provides several advantages:

  • Consistent Dependencies: All packages share the same lockfile, ensuring consistent versions
  • Cross-package Development: Easy to develop and test packages that depend on each other
  • Simplified CI/CD: Single lockfile and unified testing across all packages
  • Shared Development Tools: Common linting, formatting, and testing configuration

Architecture Decision Records

Important architectural and design decisions are documented using Architecture Decision Records (ADRs). These help explain the reasoning behind key technical choices in the project.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run the development tools to ensure quality:
    just test      # Run tests
    just check     # Lint code
    just typecheck # Type checking
    

Commit Message Guidelines

We use Conventional Commits with specific scopes for our monorepo structure:

Format: <type>(<scope>): <description>

Required Scopes:

  • keycardai-oauth: Changes to the OAuth package
  • keycardai-mcp: Changes to the core MCP package
  • keycardai-mcp-fastmcp: Changes to the FastMCP integration
  • deps: Dependency updates
  • docs: Documentation updates

Common Types: feat, fix, docs, style, refactor, test, chore, ci

Examples:

feat(keycardai-oauth): add PKCE support for enhanced security
fix(keycardai-mcp-fastmcp): resolve connection timeout in auth middleware
docs(keycardai-oauth): update API documentation with new examples
chore(deps): update httpx to v0.25.0 for security patch

Important Notes:

  • Squash commits before merging - only the final commit message appears in changelog
  • Scoped commits automatically appear in generated changelogs
  • Use git commit --amend to fix commit messages if needed
  • Preview changelog generation with: just changelog-preview
  1. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For questions, issues, or support:

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

keycardai-0.2.0.tar.gz (214.4 kB view details)

Uploaded Source

Built Distribution

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

keycardai-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file keycardai-0.2.0.tar.gz.

File metadata

  • Download URL: keycardai-0.2.0.tar.gz
  • Upload date:
  • Size: 214.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.16

File hashes

Hashes for keycardai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2b3a29cf7c41b3cda203d9e0a7213a4798f10da54e9b5dd4af8695e6289eed7c
MD5 3a72f8d92138af60b0bd064a5752bf8d
BLAKE2b-256 36afe5acfccbc0eb07c0a6e96a415e079df26b7eb23dae4f88ef8fdd238f547d

See more details on using hashes here.

File details

Details for the file keycardai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: keycardai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.16

File hashes

Hashes for keycardai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72ed4c1f01995ba0f9892a483d3998bb5a757cb7000e52bd5ccaee8dcc91ae27
MD5 36e4227809121bef491e54754e25fe86
BLAKE2b-256 17aa1b8afeeb7bf04e362644431f5af7f6568b72bed65358f40774fb03d16273

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