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/mongodb-sdk

v0.1.1

Published

Osiris MongoDB SDK

Readme

@osiris-ai/mongodb-sdk

MongoDB database adapter for Osiris MCP authentication and session data storage.

npm version License: MIT

Overview

The MongoDB SDK provides a flexible NoSQL database adapter for the Osiris ecosystem. Store MCP authentication data, user sessions, connections, and secrets in MongoDB with automatic indexing and optimized performance.

Key Features:

  • 🚀 NoSQL Flexibility - Schema-free document storage for complex data
  • 📊 Auto Indexing - Optimized queries with automatic index creation
  • 🔄 Session Management - Built-in session lifecycle and cleanup
  • 🛡️ Secure Storage - Encrypted credential and token management
  • 📝 Full TypeScript - Complete type safety and IDE support
  • High Performance - Optimized for MCP authentication patterns

Installation

npm install @osiris-ai/mongodb-sdk mongodb

Quick Start

Basic MongoDB Setup

import { createMcpServer } from '@osiris-ai/sdk';
import { MongoDBDatabaseAdapter } from '@osiris-ai/mongodb-sdk';

const mongoAdapter = new MongoDBDatabaseAdapter({
  uri: process.env.MONGODB_URI!,
  dbName: 'osiris_mcp',
  collectionName: 'tokens' // Optional: legacy collection name
});

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: mongoAdapter
  },
  configure: (server) => {
    // Your MCP tools here
  }
});

Connection String Examples

// Local MongoDB
const localConfig = {
  uri: 'mongodb://localhost:27017',
  dbName: 'osiris_dev'
};

// MongoDB Atlas
const atlasConfig = {
  uri: 'mongodb+srv://username:[email protected]',
  dbName: 'osiris_prod'
};

// MongoDB with authentication
const authConfig = {
  uri: 'mongodb://user:pass@host:27017/database?authSource=admin',
  dbName: 'osiris_enterprise'
};

Database Collections

The adapter automatically creates and manages these collections:

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

// Legacy collection (backward compatibility)
tokens           // Legacy token storage

API Reference

MongoDBDatabaseAdapter

Main database adapter class implementing the Osiris DatabaseAdapter interface.

class MongoDBDatabaseAdapter implements DatabaseAdapter

Constructor

new MongoDBDatabaseAdapter(config: MongoDBConfig)

Configuration:

  • uri: MongoDB connection string
  • dbName: Database name to use
  • collectionName?: Optional legacy collection name

Authentication Methods

// Store OAuth authentication data
await adapter.storeAuthentication(auth);

// Update authentication tokens
await adapter.updateAuthentication(id, { token, userInfo });

// Retrieve authentication for service
await adapter.getAuthentication(connectionId, service);

// Get all authentications for connection
await adapter.getAuthenticationsForConnection(connectionId);

Session Management

// Create authentication session
await adapter.storeSession(session);

// Update session status
await adapter.updateSession(id, { status: 'completed' });

// Retrieve session
await adapter.getSession(sessionId);

// Cleanup expired sessions
await adapter.cleanupExpiredSessions();

Usage Examples

Environment Configuration

# .env file
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB_NAME=osiris_mcp

# For MongoDB Atlas
MONGODB_URI=mongodb+srv://user:[email protected]

Production Setup

import { MongoDBDatabaseAdapter } from '@osiris-ai/mongodb-sdk';

const adapter = new MongoDBDatabaseAdapter({
  uri: process.env.MONGODB_URI!,
  dbName: process.env.MONGODB_DB_NAME || 'osiris_production'
});

// Use with createMcpServer
await createMcpServer({
  name: 'production-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: adapter
  },
  configure: (server) => {
    // Your production MCP configuration
  }
});

Getting Started

  1. Install MongoDB:

    # Local MongoDB
    brew install mongodb/brew/mongodb-community
    brew services start mongodb/brew/mongodb-community
       
    # Or use MongoDB Atlas (cloud)
  2. Install the adapter:

    npm install @osiris-ai/mongodb-sdk mongodb
  3. Configure your MCP:

    import { MongoDBDatabaseAdapter } from '@osiris-ai/mongodb-sdk';
       
    const adapter = new MongoDBDatabaseAdapter({
      uri: 'mongodb://localhost:27017',
      dbName: 'my_mcp'
    });

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.