npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@osiris-ai/postgres-sdk

v0.1.1

Published

Osiris Postgres SDK

Readme

@osiris-ai/postgres-sdk

PostgreSQL database adapter and secret sharing authenticator for Osiris MCP data storage and query execution.

npm version License: MIT

Overview

The PostgreSQL SDK provides production-ready database storage and secure query execution for the Osiris ecosystem. Store MCP authentication data with proper indexing and constraints, plus execute user-provided SQL queries with built-in safety validation.

Key Features:

  • 📊 Schema Management - Automatic table creation and migrations
  • 📝 Full TypeScript - Complete type safety and IDE support

Installation

npm install @osiris-ai/postgres-sdk pg
npm install --save-dev @types/pg

Quick Start

Database Adapter Setup

import { createMcpServer } from '@osiris-ai/sdk';
import { PostgresDatabaseAdapter } from '@osiris-ai/postgres-sdk';

const postgresAdapter = new PostgresDatabaseAdapter({
  connectionString: process.env.DATABASE_URL!,
  schema: 'osiris' // Optional: defaults to 'public'
});

await createMcpServer({
  name: 'my-mcp',
  version: '1.0.0',
  auth: {
    useHub: true,
    hubConfig: {
      baseUrl: process.env.HUB_BASE_URL!,
      clientId: process.env.OAUTH_CLIENT_ID!,
      clientSecret: process.env.OAUTH_CLIENT_SECRET!,
    },
    database: postgresAdapter
  },
  configure: (server) => {
    // Your MCP tools here
  }
});

Connection Configuration Examples

// Connection string (recommended)
const adapter = new PostgresDatabaseAdapter({
  connectionString: 'postgresql://user:pass@localhost:5432/database'
});

// Individual parameters
const adapter = new PostgresDatabaseAdapter({
  host: 'localhost',
  port: 5432,
  database: 'my_mcp_db',
  user: 'postgres',
  password: 'secret',
  ssl: true,
  schema: 'osiris'
});

// Heroku/Railway style
const adapter = new PostgresDatabaseAdapter({
  connectionString: process.env.DATABASE_URL,
  ssl: process.env.NODE_ENV === 'production'
});

Database Schema

The adapter automatically creates these tables:

-- Core tables (new architecture)
connections      -- MCP connection records
authentications  -- OAuth tokens and user data  
sessions         -- Authentication session management
secrets          -- Encrypted credential storage

-- Legacy table (backward compatibility)
tokens           -- Legacy token storage

API Reference

PostgresDatabaseAdapter

Production-ready database adapter implementing the Osiris DatabaseAdapter interface.

class PostgresDatabaseAdapter implements DatabaseAdapter

Constructor

new PostgresDatabaseAdapter(config: PostgresConfig)

Configuration Options

  • connectionString: PostgreSQL connection URL
  • host, port, database, user, password: Individual connection parameters
  • ssl: Enable SSL connection
  • schema: Database schema (defaults to 'public')

Core Methods

// Authentication management
await adapter.storeAuthentication(auth);
await adapter.getAuthentication(connectionId, service);
await adapter.updateAuthentication(id, updates);

// Session management  
await adapter.storeSession(session);
await adapter.cleanupExpiredSessions();

// Connection management
await adapter.storeConnection(connection);
await adapter.getConnectionsForPackage(packageId);

PostgresSecretSharingAuthenticator

Secure SQL query execution with built-in safety validation.

class PostgresSecretSharingAuthenticator extends SecretSharingAuthenticator

Methods

// Set database credentials
authenticator.set({ db_url: 'postgresql://...' });

// Execute validated SQL query
await authenticator.action(params, secrets);

Usage Examples

Environment Configuration

# .env file
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb
POSTGRES_SCHEMA=osiris

# For production
DATABASE_URL=postgresql://user:pass@prod-host:5432/prod_db?sslmode=require

Security Features

SQL Injection Protection

The authenticator includes built-in validation:

// Blocked dangerous operations
- DROP statements
- DELETE without proper WHERE clauses  
- TRUNCATE statements
- ALTER statements
- Multiple statement execution (SQL injection)

Getting Started

  1. Install PostgreSQL:

    # macOS
    brew install postgresql
    brew services start postgresql
       
    # Ubuntu/Debian
    sudo apt-get install postgresql postgresql-contrib
       
    # Or use managed service (AWS RDS, Railway, Supabase)
  2. Create database:

    CREATE DATABASE my_mcp_db;
    CREATE USER mcp_user WITH PASSWORD 'secure_password';
    GRANT ALL PRIVILEGES ON DATABASE my_mcp_db TO mcp_user;
  3. Install the adapter:

    npm install @osiris-ai/postgres-sdk pg
  4. Configure your MCP:

    import { PostgresDatabaseAdapter } from '@osiris-ai/postgres-sdk';
       
    const adapter = new PostgresDatabaseAdapter({
      connectionString: 'postgresql://mcp_user:secure_password@localhost:5432/my_mcp_db'
    });

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Support

License

MIT License - see LICENSE file for details.


Built with ❤️ by the Osiris Labs team.