Skip to main content

Prerequisites

Before installing, ensure you have:
  • Node.js 18+ - Download Node.js
  • Package manager - npm, yarn, or pnpm
  • Storage Backend (optional, defaults to in-memory):
    • Redis - Production distributed storage
    • File System - Local JSON persistence
    • SQLite - Native persistent database
    • Supabase - Cloud-native PostgreSQL
    • Neon - Serverless Postgres

Install the Package

Choose your preferred package manager:
npm2yarn

Configure Storage Backend

The library automatically selects a storage backend based on your environment variables. Choose the option that best fits your needs:

Option 1: Redis (Production)

Recommended for production and serverless deployments.

Local Redis Setup

Environment Configuration


Option 2: File System (Development)

Perfect for local development with persistent sessions across restarts.

Option 3: In-Memory (Testing)

Fast ephemeral storage, ideal for testing. Sessions are lost on restart.
This is the default if no storage configuration is provided.

Storage Selection Logic

The library uses the following priority:
  1. Explicit: If MCP_TS_STORAGE_TYPE is set, use that backend
  2. Auto-detect Redis: If REDIS_URL is present, use Redis
  3. Auto-detect File: If MCP_TS_STORAGE_FILE is present, use File
  4. Auto-detect SQLite: If MCP_TS_STORAGE_SQLITE_PATH is present, use SQLite
  5. Auto-detect Supabase: If SUPABASE_URL is present, use Supabase
  6. Auto-detect Neon: If NEON_DATABASE_URL is present, use Neon
  7. Default: Fall back to In-Memory storage
See Storage Overview for more details.

Verify Installation

Test your setup with a simple script:

TypeScript Configuration

If using TypeScript, ensure your tsconfig.json includes:

Next Steps