A Python package for Veris AI tools
Project description
Veris AI Python SDK
A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
Installation
You can install the package using uv:
# Install the package
uv add veris-ai
# Install with development dependencies
uv add "veris-ai[dev]"
# Install with FastAPI MCP integration
uv add "veris-ai[fastapi]"
Environment Setup
The package requires the following environment variables:
# Required: URL for the mock endpoint
VERIS_MOCK_ENDPOINT_URL=http://your-mock-endpoint.com
# Optional: Timeout in seconds (default: 30.0)
VERIS_MOCK_TIMEOUT=30.0
# Optional: Set to "simulation" to enable mock mode
ENV=simulation
Python Version
This project requires Python 3.11 or higher. We use pyenv for Python version management.
To set up the correct Python version:
# Install Python 3.11.0 using pyenv
pyenv install 3.11.0
# Set the local Python version for this project
pyenv local 3.11.0
Usage
from veris_ai import veris
@veris.mock()
async def your_function(param1: str, param2: int) -> dict:
"""
Your function documentation here.
Args:
param1: Description of param1
param2: Description of param2
Returns:
A dictionary containing the results
"""
# Your implementation here
return {"result": "actual implementation"}
When ENV=simulation is set, the decorator will:
- Capture the function signature, type hints, and docstring
- Send this information to the mock endpoint
- Convert the mock response to the expected return type
- Return the mock result
When not in simulation mode, the original function will be executed normally.
FastAPI MCP Integration
The SDK provides integration with FastAPI applications through the Model Context Protocol (MCP). This allows your FastAPI endpoints to be exposed as MCP tools that can be used by AI agents.
from fastapi import FastAPI
from veris_ai import veris
app = FastAPI()
# Set up FastAPI MCP with automatic session handling
veris.set_fastapi_mcp(
fastapi=app,
name="My API Server",
description="My FastAPI application exposed as MCP tools",
describe_all_responses=True,
include_operations=["get_users", "create_user"],
exclude_tags=["internal"]
)
# The MCP server is now available at veris.fastapi_mcp
mcp_server = veris.fastapi_mcp
Configuration Options
The set_fastapi_mcp() method accepts the following parameters:
- fastapi (required): Your FastAPI application instance
- name: Custom name for the MCP server (defaults to app.title)
- description: Custom description (defaults to app.description)
- describe_all_responses: Whether to include all response schemas in tool descriptions
- describe_full_response_schema: Whether to include full JSON schema for responses
- http_client: Optional custom httpx.AsyncClient instance
- include_operations: List of operation IDs to include as MCP tools
- exclude_operations: List of operation IDs to exclude (can't use with include_operations)
- include_tags: List of tags to include as MCP tools
- exclude_tags: List of tags to exclude (can't use with include_tags)
- auth_config: Optional FastAPI MCP AuthConfig for custom authentication
Session Management
The SDK automatically handles session management through OAuth2 authentication:
- Session IDs are extracted from bearer tokens
- Context is maintained across API calls
- Sessions can be managed programmatically:
# Get current session ID
session_id = veris.session_id
# Set a new session ID
veris.set_session_id("new-session-123")
# Clear the session
veris.clear_session_id()
Project Structure
src/veris_ai/
├── __init__.py # Main entry point, exports the veris instance
├── tool_mock.py # VerisSDK class with @veris.mock() decorator
└── utils.py # Type conversion utilities
tests/
├── conftest.py # Pytest fixtures
├── test_tool_mock.py # Tests for VerisSDK functionality
└── test_utils.py # Tests for type conversion utilities
Development
This project uses pyproject.toml for dependency management and uv for package installation.
Development Dependencies
To install the package with development dependencies:
uv add "veris-ai[dev]"
This will install the following development tools:
- Ruff: Fast Python linter
- pytest: Testing framework
- pytest-asyncio: Async support for pytest
- pytest-cov: Coverage reporting for pytest
- black: Code formatter
- mypy: Static type checker
- pre-commit: Git hooks for code quality
Code Quality
This project uses Ruff for linting and code quality checks. Ruff is a fast Python linter written in Rust.
To run Ruff:
# Lint code
ruff check .
# Auto-fix linting issues
ruff check --fix .
# Format code
ruff format .
# Check formatting only
ruff format --check .
The Ruff configuration is defined in pyproject.toml under the [tool.ruff] section.
Running Tests
# Run all tests with coverage
pytest tests/ --cov=veris_ai --cov-report=xml --cov-report=term-missing
# Run specific test file
pytest tests/test_tool_mock.py
# Run tests with verbose output
pytest -v tests/
Type Checking
# Run static type checking
mypy src/veris_ai tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file veris_ai-1.0.0.tar.gz.
File metadata
- Download URL: veris_ai-1.0.0.tar.gz
- Upload date:
- Size: 62.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f933b474f343a54e6a2f3c193df0db4c499015ff6ce5f74027564e2806a896b
|
|
| MD5 |
0b8d486ff899ca178887240787108d85
|
|
| BLAKE2b-256 |
75bffc0ea6deede0a1b99b91cd1cb855368e41e2d988c053dad874e899a0b8b7
|
File details
Details for the file veris_ai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: veris_ai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeba4ed9044f75cdd50b138c2bc444b94f9ebeef8f23bb6a9758342852c78d1e
|
|
| MD5 |
336b1dd33a38e02d9e9a174290d16e4a
|
|
| BLAKE2b-256 |
b0265abf625a477a85819db7ba603fac2c80e6985d6549a8873ece8c03248455
|