Skip to main content

Overview

The @atxp/sqlite package provides a SQLite-based OAuth database implementation for ATXP. It offers persistent OAuth token storage using SQLite, ensuring data retention across application restarts.
This package is designed to work seamlessly with @atxp/client and @atxp/express packages when you need persistent storage that survives application restarts. For high-scale applications, consider using @atxp/redis instead.

Installation

The @atxp/sqlite package includes TypeScript definitions and requires Node.js 16 or higher. It automatically installs @atxp/common as a dependency.

API Reference

Classes

SQLiteOAuthDatabase

The main class for managing OAuth tokens in a SQLite database.
Constructor
SQLiteOAuthDatabaseOptions
required
Configuration options for the SQLite database connection.
Methods
Promise<void>
Saves an OAuth access token in the database.
Promise<AccessToken | null>
Retrieves an OAuth access token from the database.
Promise<boolean>
Deletes an OAuth token from the database.
string
required
Unique identifier for the token to delete.
Promise<boolean>
Checks if a token exists in the database.
string
required
Unique identifier for the token to check.
Promise<string[]>
Lists all token keys stored in the database.
Promise<void>
Closes the database connection and releases resources.

Interfaces

SQLiteOAuthDatabaseOptions

Configuration options for the SQLite OAuth database.
string
required
Path to the SQLite database file. Can be a relative or absolute path.
boolean
default:"true"
Whether to automatically create the required database tables on initialization.
number
default:"5000"
Connection timeout in milliseconds.

Usage Examples

Integration with ATXP Client

Use SQLite storage with the ATXP client for persistent token management:

Integration with ATXP Server

Use SQLite storage with the ATXP server for persistent session management:

Configuration

Database File Location

The SQLite database file can be placed anywhere on your filesystem:

Environment Variables

Configure the database path using environment variables:

Database Schema

The package automatically creates the following table structure:
The database schema is automatically created when autoCreateTables is set to true (default). You can disable this behavior if you want to manage the schema manually.

Troubleshooting

Common Issues

If you encounter permission errors when creating or accessing the database file:
  • Ensure the directory exists and has write permissions
  • Check that the user running the application has access to the database path
  • Consider using an absolute path instead of a relative path
If you’re experiencing connection timeouts:
  • Increase the connectionTimeout value
  • Check if the database file is locked by another process
  • Ensure sufficient disk space is available

@atxp/client

Client-side integration for MCP clients with OAuth authentication.

@atxp/express

Server-side middleware for MCP servers with payment processing.

@atxp/redis

Redis OAuth database for high-scale applications.

@atxp/common

Shared utilities and types used across ATXP packages.