veris-ai 0.2.1__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of veris-ai might be problematic. Click here for more details.
- {veris_ai-0.2.1 → veris_ai-1.0.0}/.github/workflows/release.yml +1 -1
- {veris_ai-0.2.1 → veris_ai-1.0.0}/.github/workflows/test.yml +3 -4
- veris_ai-1.0.0/CLAUDE.md +181 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/PKG-INFO +107 -5
- veris_ai-1.0.0/README.md +215 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/pyproject.toml +6 -2
- veris_ai-1.0.0/src/veris_ai/tool_mock.py +161 -0
- veris_ai-1.0.0/src/veris_ai/utils.py +71 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/tests/conftest.py +3 -0
- veris_ai-1.0.0/tests/fixtures/__init__.py +1 -0
- veris_ai-1.0.0/tests/fixtures/simple_app.py +66 -0
- veris_ai-1.0.0/tests/fixtures/sse_server.py +113 -0
- veris_ai-1.0.0/tests/test_mcp_protocol_server_mocked.py +185 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/tests/test_tool_mock.py +117 -79
- veris_ai-1.0.0/tests/test_utils.py +107 -0
- veris_ai-1.0.0/uv.lock +1057 -0
- veris_ai-0.2.1/README.md +0 -116
- veris_ai-0.2.1/src/veris_ai/tool_mock.py +0 -140
- veris_ai-0.2.1/uv.lock +0 -524
- {veris_ai-0.2.1 → veris_ai-1.0.0}/.gitignore +0 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/CHANGELOG.md +0 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/LICENSE +0 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/src/veris_ai/__init__.py +0 -0
- {veris_ai-0.2.1 → veris_ai-1.0.0}/tests/__init__.py +0 -0
|
@@ -2,9 +2,9 @@ name: Tests
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches: [
|
|
5
|
+
branches: [ main ]
|
|
6
6
|
pull_request:
|
|
7
|
-
branches: [
|
|
7
|
+
branches: [ main ]
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
test:
|
|
@@ -27,8 +27,7 @@ jobs:
|
|
|
27
27
|
|
|
28
28
|
- name: Install dependencies
|
|
29
29
|
run: |
|
|
30
|
-
uv
|
|
31
|
-
uv pip install -e .[dev]
|
|
30
|
+
uv sync --all-extras
|
|
32
31
|
|
|
33
32
|
- name: Run code quality checks with Ruff
|
|
34
33
|
run: |
|
veris_ai-1.0.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is the Veris AI Python SDK - a package that provides simulation capabilities through decorator-based function mocking and FastAPI MCP (Model Context Protocol) integration. The core functionality revolves around:
|
|
8
|
+
- `VerisSDK` class in `src/veris_ai/tool_mock.py:27` - enables environment-aware execution where functions can be mocked in simulation mode or executed normally in production
|
|
9
|
+
- `convert_to_type()` function in `src/veris_ai/utils.py:5` - handles sophisticated type conversion from mock responses
|
|
10
|
+
- `FastApiMCPParams` model in `src/veris_ai/models.py:1` - provides configuration for integrating FastAPI applications with the Model Context Protocol
|
|
11
|
+
- `set_fastapi_mcp()` method in `src/veris_ai/tool_mock.py:54` - configures FastAPI MCP server with automatic OAuth2-based session management
|
|
12
|
+
|
|
13
|
+
## Development Commands
|
|
14
|
+
|
|
15
|
+
This project uses `uv` as the package manager and follows modern Python tooling practices.
|
|
16
|
+
|
|
17
|
+
### Setup
|
|
18
|
+
```bash
|
|
19
|
+
# Install with development dependencies
|
|
20
|
+
uv add "veris-ai[dev]"
|
|
21
|
+
|
|
22
|
+
# Install with FastAPI MCP integration
|
|
23
|
+
uv add "veris-ai[fastapi]"
|
|
24
|
+
|
|
25
|
+
# Set Python version (requires 3.11+)
|
|
26
|
+
pyenv local 3.11.0
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Code Quality (Primary: Ruff)
|
|
30
|
+
```bash
|
|
31
|
+
# Lint code
|
|
32
|
+
ruff check .
|
|
33
|
+
|
|
34
|
+
# Auto-fix linting issues
|
|
35
|
+
ruff check --fix .
|
|
36
|
+
|
|
37
|
+
# Format code
|
|
38
|
+
ruff format .
|
|
39
|
+
|
|
40
|
+
# Check formatting only
|
|
41
|
+
ruff format --check .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Type Checking
|
|
45
|
+
```bash
|
|
46
|
+
# Run static type checking
|
|
47
|
+
mypy src/veris_ai tests
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Testing
|
|
51
|
+
```bash
|
|
52
|
+
# Run all tests with coverage
|
|
53
|
+
pytest tests/ --cov=veris_ai --cov-report=xml --cov-report=term-missing
|
|
54
|
+
|
|
55
|
+
# Run specific test file
|
|
56
|
+
pytest tests/test_tool_mock.py
|
|
57
|
+
|
|
58
|
+
# Run tests with verbose output
|
|
59
|
+
pytest -v tests/
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Building
|
|
63
|
+
```bash
|
|
64
|
+
# Build package distributions
|
|
65
|
+
uv build
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Code Architecture
|
|
69
|
+
|
|
70
|
+
### Core Components
|
|
71
|
+
|
|
72
|
+
**VerisSDK Class** (`src/veris_ai/tool_mock.py:27`)
|
|
73
|
+
- Main SDK class that provides `@veris.mock()` decorator functionality
|
|
74
|
+
- Environment detection: Uses `ENV` environment variable to determine simulation vs production mode
|
|
75
|
+
- HTTP communication with mock endpoints via `httpx`
|
|
76
|
+
- Context extraction for session management via context variables
|
|
77
|
+
- Delegates type conversion to the utils module
|
|
78
|
+
|
|
79
|
+
**API Surface** (`src/veris_ai/__init__.py:5`)
|
|
80
|
+
- Exports single `veris` instance for public use
|
|
81
|
+
- Clean, minimal API design
|
|
82
|
+
|
|
83
|
+
**Type Conversion Utilities** (`src/veris_ai/utils.py:1`)
|
|
84
|
+
- `convert_to_type()` function handles sophisticated type conversion from mock responses
|
|
85
|
+
- Supports primitives, lists, dictionaries, unions, and custom types
|
|
86
|
+
- Modular design with separate conversion functions for each type category
|
|
87
|
+
- Uses Python's typing system for runtime type checking
|
|
88
|
+
|
|
89
|
+
**FastAPI MCP Integration** (`src/veris_ai/models.py:1`)
|
|
90
|
+
- `FastApiMCPParams` Pydantic model for configuring FastAPI MCP server integration
|
|
91
|
+
- Comprehensive configuration options including:
|
|
92
|
+
- Custom server naming and descriptions
|
|
93
|
+
- HTTP client configuration (base URL, headers, timeout)
|
|
94
|
+
- Operation filtering (include/exclude by operation ID or tag)
|
|
95
|
+
- Response schema documentation controls
|
|
96
|
+
- Authentication configuration
|
|
97
|
+
|
|
98
|
+
### Environment Configuration
|
|
99
|
+
|
|
100
|
+
Required environment variables:
|
|
101
|
+
- `VERIS_MOCK_ENDPOINT_URL`: Mock endpoint URL (required)
|
|
102
|
+
- `VERIS_MOCK_TIMEOUT`: Request timeout in seconds (optional, default: 30.0)
|
|
103
|
+
- `ENV`: Set to "simulation" to enable mocking, anything else runs original functions
|
|
104
|
+
|
|
105
|
+
### Type System
|
|
106
|
+
|
|
107
|
+
The SDK handles sophisticated type conversion from mock responses:
|
|
108
|
+
- Type conversion is handled by the `convert_to_type()` function in `src/veris_ai/utils.py`
|
|
109
|
+
- Supports primitives, lists, dictionaries, unions, and custom types
|
|
110
|
+
- Modular design with separate handlers for different type categories
|
|
111
|
+
- Uses Python's typing system for runtime type checking
|
|
112
|
+
|
|
113
|
+
## Testing Strategy
|
|
114
|
+
|
|
115
|
+
**Test Structure**:
|
|
116
|
+
- `tests/conftest.py:1`: Pytest fixtures for environment mocking and context objects
|
|
117
|
+
- `tests/test_tool_mock.py:1`: Unit tests for the VerisSDK class and mock decorator functionality
|
|
118
|
+
- `tests/test_utils.py:1`: Comprehensive tests for type conversion utilities
|
|
119
|
+
|
|
120
|
+
**Key Test Fixtures**:
|
|
121
|
+
- `mock_context`: Provides mock context with session ID
|
|
122
|
+
- `simulation_env`: Sets up simulation environment variables
|
|
123
|
+
- `production_env`: Sets up production environment variables
|
|
124
|
+
|
|
125
|
+
**Test Coverage Areas**:
|
|
126
|
+
- Environment-based behavior switching
|
|
127
|
+
- HTTP client interactions and error handling
|
|
128
|
+
- Type conversion scenarios (parametrized tests)
|
|
129
|
+
- Configuration validation
|
|
130
|
+
|
|
131
|
+
## Code Quality Standards
|
|
132
|
+
|
|
133
|
+
**Ruff Configuration** (80+ rules enabled):
|
|
134
|
+
- Line length: 100 characters
|
|
135
|
+
- Target: Python 3.11+
|
|
136
|
+
- Google-style docstring convention
|
|
137
|
+
- Comprehensive rule set covering style, bugs, security, and complexity
|
|
138
|
+
- Relaxed rules for test files (allows more flexibility in tests)
|
|
139
|
+
|
|
140
|
+
**Development Tools**:
|
|
141
|
+
- **Ruff**: Primary linter and formatter (replaces flake8, black, isort)
|
|
142
|
+
- **MyPy**: Static type checking
|
|
143
|
+
- **Pytest**: Testing with async support and coverage
|
|
144
|
+
- **Pre-commit**: Git hooks for code quality
|
|
145
|
+
|
|
146
|
+
## CI/CD Pipeline
|
|
147
|
+
|
|
148
|
+
**Testing Workflow** (`.github/workflows/test.yml`):
|
|
149
|
+
- Runs on Python 3.11, 3.12, 3.13
|
|
150
|
+
- Code quality checks (Ruff lint/format)
|
|
151
|
+
- Type checking (MyPy)
|
|
152
|
+
- Unit tests with coverage
|
|
153
|
+
|
|
154
|
+
**Release Workflow** (`.github/workflows/release.yml`):
|
|
155
|
+
- Manual trigger for releases
|
|
156
|
+
- Semantic versioning with conventional commits
|
|
157
|
+
- Automated PyPI publishing
|
|
158
|
+
- Uses `uv build` for package building
|
|
159
|
+
|
|
160
|
+
## Key Implementation Details
|
|
161
|
+
|
|
162
|
+
- **Decorator Pattern**: Functions are wrapped to intercept calls in simulation mode
|
|
163
|
+
- **Session Management**: Extracts session ID from context for request correlation
|
|
164
|
+
- **Error Handling**: Comprehensive HTTP and type conversion error handling
|
|
165
|
+
- **Async Support**: Built with async/await pattern throughout
|
|
166
|
+
- **Type Safety**: Full type hints and runtime type conversion validation
|
|
167
|
+
- **Modular Architecture**: Type conversion logic separated into utils module for better maintainability
|
|
168
|
+
|
|
169
|
+
### FastAPI MCP Integration
|
|
170
|
+
|
|
171
|
+
The `set_fastapi_mcp()` method provides:
|
|
172
|
+
- **Automatic Session Handling**: OAuth2-based session ID extraction from bearer tokens
|
|
173
|
+
- **Context Management**: Session IDs are stored in context variables for cross-request correlation
|
|
174
|
+
- **Auth Config Merging**: User-provided auth configs are merged with internal session handling
|
|
175
|
+
- **MCP Server Access**: Configured server available via `veris.fastapi_mcp` property
|
|
176
|
+
|
|
177
|
+
Key implementation aspects:
|
|
178
|
+
- Creates internal OAuth2PasswordBearer scheme for token extraction
|
|
179
|
+
- Dependency injection for automatic session context setting
|
|
180
|
+
- Preserves user auth configurations while adding session management
|
|
181
|
+
- SSE (Server-Sent Events) support for streaming responses
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: veris-ai
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: A Python package for Veris AI tools
|
|
5
5
|
Project-URL: Homepage, https://github.com/veris-ai/veris-python-sdk
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/veris-ai/veris-python-sdk/issues
|
|
@@ -17,11 +17,14 @@ Requires-Dist: pytest-asyncio>=0.21.1; extra == 'dev'
|
|
|
17
17
|
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
18
18
|
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
19
19
|
Requires-Dist: ruff>=0.11.4; extra == 'dev'
|
|
20
|
+
Provides-Extra: fastapi
|
|
21
|
+
Requires-Dist: fastapi; extra == 'fastapi'
|
|
22
|
+
Requires-Dist: fastapi-mcp; extra == 'fastapi'
|
|
20
23
|
Description-Content-Type: text/markdown
|
|
21
24
|
|
|
22
25
|
# Veris AI Python SDK
|
|
23
26
|
|
|
24
|
-
A Python package for Veris AI tools with simulation capabilities.
|
|
27
|
+
A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
|
|
25
28
|
|
|
26
29
|
## Installation
|
|
27
30
|
|
|
@@ -33,6 +36,9 @@ uv add veris-ai
|
|
|
33
36
|
|
|
34
37
|
# Install with development dependencies
|
|
35
38
|
uv add "veris-ai[dev]"
|
|
39
|
+
|
|
40
|
+
# Install with FastAPI MCP integration
|
|
41
|
+
uv add "veris-ai[fastapi]"
|
|
36
42
|
```
|
|
37
43
|
|
|
38
44
|
## Environment Setup
|
|
@@ -93,6 +99,78 @@ When `ENV=simulation` is set, the decorator will:
|
|
|
93
99
|
|
|
94
100
|
When not in simulation mode, the original function will be executed normally.
|
|
95
101
|
|
|
102
|
+
## FastAPI MCP Integration
|
|
103
|
+
|
|
104
|
+
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.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from fastapi import FastAPI
|
|
108
|
+
from veris_ai import veris
|
|
109
|
+
|
|
110
|
+
app = FastAPI()
|
|
111
|
+
|
|
112
|
+
# Set up FastAPI MCP with automatic session handling
|
|
113
|
+
veris.set_fastapi_mcp(
|
|
114
|
+
fastapi=app,
|
|
115
|
+
name="My API Server",
|
|
116
|
+
description="My FastAPI application exposed as MCP tools",
|
|
117
|
+
describe_all_responses=True,
|
|
118
|
+
include_operations=["get_users", "create_user"],
|
|
119
|
+
exclude_tags=["internal"]
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# The MCP server is now available at veris.fastapi_mcp
|
|
123
|
+
mcp_server = veris.fastapi_mcp
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Configuration Options
|
|
127
|
+
|
|
128
|
+
The `set_fastapi_mcp()` method accepts the following parameters:
|
|
129
|
+
|
|
130
|
+
- **fastapi** (required): Your FastAPI application instance
|
|
131
|
+
- **name**: Custom name for the MCP server (defaults to app.title)
|
|
132
|
+
- **description**: Custom description (defaults to app.description)
|
|
133
|
+
- **describe_all_responses**: Whether to include all response schemas in tool descriptions
|
|
134
|
+
- **describe_full_response_schema**: Whether to include full JSON schema for responses
|
|
135
|
+
- **http_client**: Optional custom httpx.AsyncClient instance
|
|
136
|
+
- **include_operations**: List of operation IDs to include as MCP tools
|
|
137
|
+
- **exclude_operations**: List of operation IDs to exclude (can't use with include_operations)
|
|
138
|
+
- **include_tags**: List of tags to include as MCP tools
|
|
139
|
+
- **exclude_tags**: List of tags to exclude (can't use with include_tags)
|
|
140
|
+
- **auth_config**: Optional FastAPI MCP AuthConfig for custom authentication
|
|
141
|
+
|
|
142
|
+
### Session Management
|
|
143
|
+
|
|
144
|
+
The SDK automatically handles session management through OAuth2 authentication:
|
|
145
|
+
- Session IDs are extracted from bearer tokens
|
|
146
|
+
- Context is maintained across API calls
|
|
147
|
+
- Sessions can be managed programmatically:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
# Get current session ID
|
|
151
|
+
session_id = veris.session_id
|
|
152
|
+
|
|
153
|
+
# Set a new session ID
|
|
154
|
+
veris.set_session_id("new-session-123")
|
|
155
|
+
|
|
156
|
+
# Clear the session
|
|
157
|
+
veris.clear_session_id()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Project Structure
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
src/veris_ai/
|
|
164
|
+
├── __init__.py # Main entry point, exports the veris instance
|
|
165
|
+
├── tool_mock.py # VerisSDK class with @veris.mock() decorator
|
|
166
|
+
└── utils.py # Type conversion utilities
|
|
167
|
+
|
|
168
|
+
tests/
|
|
169
|
+
├── conftest.py # Pytest fixtures
|
|
170
|
+
├── test_tool_mock.py # Tests for VerisSDK functionality
|
|
171
|
+
└── test_utils.py # Tests for type conversion utilities
|
|
172
|
+
```
|
|
173
|
+
|
|
96
174
|
## Development
|
|
97
175
|
|
|
98
176
|
This project uses `pyproject.toml` for dependency management and `uv` for package installation.
|
|
@@ -121,16 +199,40 @@ This project uses [Ruff](https://github.com/charliermarsh/ruff) for linting and
|
|
|
121
199
|
To run Ruff:
|
|
122
200
|
|
|
123
201
|
```bash
|
|
202
|
+
# Lint code
|
|
124
203
|
ruff check .
|
|
204
|
+
|
|
205
|
+
# Auto-fix linting issues
|
|
206
|
+
ruff check --fix .
|
|
207
|
+
|
|
208
|
+
# Format code
|
|
209
|
+
ruff format .
|
|
210
|
+
|
|
211
|
+
# Check formatting only
|
|
212
|
+
ruff format --check .
|
|
125
213
|
```
|
|
126
214
|
|
|
127
|
-
|
|
215
|
+
The Ruff configuration is defined in `pyproject.toml` under the `[tool.ruff]` section.
|
|
216
|
+
|
|
217
|
+
### Running Tests
|
|
128
218
|
|
|
129
219
|
```bash
|
|
130
|
-
|
|
220
|
+
# Run all tests with coverage
|
|
221
|
+
pytest tests/ --cov=veris_ai --cov-report=xml --cov-report=term-missing
|
|
222
|
+
|
|
223
|
+
# Run specific test file
|
|
224
|
+
pytest tests/test_tool_mock.py
|
|
225
|
+
|
|
226
|
+
# Run tests with verbose output
|
|
227
|
+
pytest -v tests/
|
|
131
228
|
```
|
|
132
229
|
|
|
133
|
-
|
|
230
|
+
### Type Checking
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Run static type checking
|
|
234
|
+
mypy src/veris_ai tests
|
|
235
|
+
```
|
|
134
236
|
|
|
135
237
|
## License
|
|
136
238
|
|
veris_ai-1.0.0/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Veris AI Python SDK
|
|
2
|
+
|
|
3
|
+
A Python package for Veris AI tools with simulation capabilities and FastAPI MCP (Model Context Protocol) integration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install the package using `uv`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Install the package
|
|
11
|
+
uv add veris-ai
|
|
12
|
+
|
|
13
|
+
# Install with development dependencies
|
|
14
|
+
uv add "veris-ai[dev]"
|
|
15
|
+
|
|
16
|
+
# Install with FastAPI MCP integration
|
|
17
|
+
uv add "veris-ai[fastapi]"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Environment Setup
|
|
21
|
+
|
|
22
|
+
The package requires the following environment variables:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Required: URL for the mock endpoint
|
|
26
|
+
VERIS_MOCK_ENDPOINT_URL=http://your-mock-endpoint.com
|
|
27
|
+
|
|
28
|
+
# Optional: Timeout in seconds (default: 30.0)
|
|
29
|
+
VERIS_MOCK_TIMEOUT=30.0
|
|
30
|
+
|
|
31
|
+
# Optional: Set to "simulation" to enable mock mode
|
|
32
|
+
ENV=simulation
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Python Version
|
|
36
|
+
|
|
37
|
+
This project requires Python 3.11 or higher. We use [pyenv](https://github.com/pyenv/pyenv) for Python version management.
|
|
38
|
+
|
|
39
|
+
To set up the correct Python version:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Install Python 3.11.0 using pyenv
|
|
43
|
+
pyenv install 3.11.0
|
|
44
|
+
|
|
45
|
+
# Set the local Python version for this project
|
|
46
|
+
pyenv local 3.11.0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from veris_ai import veris
|
|
53
|
+
|
|
54
|
+
@veris.mock()
|
|
55
|
+
async def your_function(param1: str, param2: int) -> dict:
|
|
56
|
+
"""
|
|
57
|
+
Your function documentation here.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
param1: Description of param1
|
|
61
|
+
param2: Description of param2
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
A dictionary containing the results
|
|
65
|
+
"""
|
|
66
|
+
# Your implementation here
|
|
67
|
+
return {"result": "actual implementation"}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
When `ENV=simulation` is set, the decorator will:
|
|
71
|
+
1. Capture the function signature, type hints, and docstring
|
|
72
|
+
2. Send this information to the mock endpoint
|
|
73
|
+
3. Convert the mock response to the expected return type
|
|
74
|
+
4. Return the mock result
|
|
75
|
+
|
|
76
|
+
When not in simulation mode, the original function will be executed normally.
|
|
77
|
+
|
|
78
|
+
## FastAPI MCP Integration
|
|
79
|
+
|
|
80
|
+
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.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from fastapi import FastAPI
|
|
84
|
+
from veris_ai import veris
|
|
85
|
+
|
|
86
|
+
app = FastAPI()
|
|
87
|
+
|
|
88
|
+
# Set up FastAPI MCP with automatic session handling
|
|
89
|
+
veris.set_fastapi_mcp(
|
|
90
|
+
fastapi=app,
|
|
91
|
+
name="My API Server",
|
|
92
|
+
description="My FastAPI application exposed as MCP tools",
|
|
93
|
+
describe_all_responses=True,
|
|
94
|
+
include_operations=["get_users", "create_user"],
|
|
95
|
+
exclude_tags=["internal"]
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# The MCP server is now available at veris.fastapi_mcp
|
|
99
|
+
mcp_server = veris.fastapi_mcp
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Configuration Options
|
|
103
|
+
|
|
104
|
+
The `set_fastapi_mcp()` method accepts the following parameters:
|
|
105
|
+
|
|
106
|
+
- **fastapi** (required): Your FastAPI application instance
|
|
107
|
+
- **name**: Custom name for the MCP server (defaults to app.title)
|
|
108
|
+
- **description**: Custom description (defaults to app.description)
|
|
109
|
+
- **describe_all_responses**: Whether to include all response schemas in tool descriptions
|
|
110
|
+
- **describe_full_response_schema**: Whether to include full JSON schema for responses
|
|
111
|
+
- **http_client**: Optional custom httpx.AsyncClient instance
|
|
112
|
+
- **include_operations**: List of operation IDs to include as MCP tools
|
|
113
|
+
- **exclude_operations**: List of operation IDs to exclude (can't use with include_operations)
|
|
114
|
+
- **include_tags**: List of tags to include as MCP tools
|
|
115
|
+
- **exclude_tags**: List of tags to exclude (can't use with include_tags)
|
|
116
|
+
- **auth_config**: Optional FastAPI MCP AuthConfig for custom authentication
|
|
117
|
+
|
|
118
|
+
### Session Management
|
|
119
|
+
|
|
120
|
+
The SDK automatically handles session management through OAuth2 authentication:
|
|
121
|
+
- Session IDs are extracted from bearer tokens
|
|
122
|
+
- Context is maintained across API calls
|
|
123
|
+
- Sessions can be managed programmatically:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
# Get current session ID
|
|
127
|
+
session_id = veris.session_id
|
|
128
|
+
|
|
129
|
+
# Set a new session ID
|
|
130
|
+
veris.set_session_id("new-session-123")
|
|
131
|
+
|
|
132
|
+
# Clear the session
|
|
133
|
+
veris.clear_session_id()
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Project Structure
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
src/veris_ai/
|
|
140
|
+
├── __init__.py # Main entry point, exports the veris instance
|
|
141
|
+
├── tool_mock.py # VerisSDK class with @veris.mock() decorator
|
|
142
|
+
└── utils.py # Type conversion utilities
|
|
143
|
+
|
|
144
|
+
tests/
|
|
145
|
+
├── conftest.py # Pytest fixtures
|
|
146
|
+
├── test_tool_mock.py # Tests for VerisSDK functionality
|
|
147
|
+
└── test_utils.py # Tests for type conversion utilities
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
This project uses `pyproject.toml` for dependency management and `uv` for package installation.
|
|
153
|
+
|
|
154
|
+
### Development Dependencies
|
|
155
|
+
|
|
156
|
+
To install the package with development dependencies:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
uv add "veris-ai[dev]"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This will install the following development tools:
|
|
163
|
+
- **Ruff**: Fast Python linter
|
|
164
|
+
- **pytest**: Testing framework
|
|
165
|
+
- **pytest-asyncio**: Async support for pytest
|
|
166
|
+
- **pytest-cov**: Coverage reporting for pytest
|
|
167
|
+
- **black**: Code formatter
|
|
168
|
+
- **mypy**: Static type checker
|
|
169
|
+
- **pre-commit**: Git hooks for code quality
|
|
170
|
+
|
|
171
|
+
### Code Quality
|
|
172
|
+
|
|
173
|
+
This project uses [Ruff](https://github.com/charliermarsh/ruff) for linting and code quality checks. Ruff is a fast Python linter written in Rust.
|
|
174
|
+
|
|
175
|
+
To run Ruff:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Lint code
|
|
179
|
+
ruff check .
|
|
180
|
+
|
|
181
|
+
# Auto-fix linting issues
|
|
182
|
+
ruff check --fix .
|
|
183
|
+
|
|
184
|
+
# Format code
|
|
185
|
+
ruff format .
|
|
186
|
+
|
|
187
|
+
# Check formatting only
|
|
188
|
+
ruff format --check .
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The Ruff configuration is defined in `pyproject.toml` under the `[tool.ruff]` section.
|
|
192
|
+
|
|
193
|
+
### Running Tests
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Run all tests with coverage
|
|
197
|
+
pytest tests/ --cov=veris_ai --cov-report=xml --cov-report=term-missing
|
|
198
|
+
|
|
199
|
+
# Run specific test file
|
|
200
|
+
pytest tests/test_tool_mock.py
|
|
201
|
+
|
|
202
|
+
# Run tests with verbose output
|
|
203
|
+
pytest -v tests/
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Type Checking
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Run static type checking
|
|
210
|
+
mypy src/veris_ai tests
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "veris-ai"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "1.0.0"
|
|
8
8
|
description = "A Python package for Veris AI tools"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -26,6 +26,10 @@ dev = [
|
|
|
26
26
|
"mypy>=1.5.1",
|
|
27
27
|
"pre-commit>=3.3.3",
|
|
28
28
|
]
|
|
29
|
+
fastapi = [
|
|
30
|
+
"fastapi",
|
|
31
|
+
"fastapi_mcp",
|
|
32
|
+
]
|
|
29
33
|
|
|
30
34
|
[project.urls]
|
|
31
35
|
"Homepage" = "https://github.com/veris-ai/veris-python-sdk"
|
|
@@ -118,7 +122,7 @@ convention = "google"
|
|
|
118
122
|
|
|
119
123
|
[tool.semantic_release]
|
|
120
124
|
version_variables = ["pyproject.toml:version"]
|
|
121
|
-
branch = "
|
|
125
|
+
branch = "main"
|
|
122
126
|
changelog_file = "CHANGELOG.md"
|
|
123
127
|
build_command = "uv build"
|
|
124
128
|
dist_path = "dist/"
|