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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcp-shark/mcp-shark-common

v1.0.1

Published

Shared utilities and database management for MCP Shark - provides database initialization, audit logging, query utilities, and configuration management

Readme

MCP Shark Common

⚠️ ALPHA VERSION - STILL TESTING
This is an alpha version of MCP Shark Common. The software is still under active development and testing. Features may change, and there may be bugs or incomplete functionality. Use at your own risk.

Common library for MCP Shark related work

MCP Shark Common is a shared library that provides common functionality for MCP Shark projects. This package contains reusable utilities including database initialization, logging, query utilities, and configuration management that are used across various MCP Shark components.

🎯 Overview

This package provides:

  • Database Management: SQLite database initialization and schema creation
  • Audit Logging: Structured logging for MCP communications
  • Query Utilities: Database query helpers for packets, conversations, and sessions
  • Configuration Management: Path resolution for app data directories

✨ Features

  • 📊 Database Schema: Complete SQLite schema for packet capture, conversations, and sessions
  • 🔍 Query Helpers: Convenient functions for querying audit logs
  • 📝 Structured Logging: Comprehensive logging with correlation IDs and metadata
  • 🔧 Path Management: Automatic resolution of app data directories (~/.mcp-shark/)

📦 Installation

npm install @mcp-shark/mcp-shark-common

🚀 Usage

This is a common library for MCP Shark projects. Import the utilities you need:

import {
  // Database initialization
  initDb,
  openDb,
  // Logging
  getLogger,
  // Query utilities
  queryPackets,
  queryRequests,
  queryConversations,
  getSessionPackets,
  getSessions,
  getStatistics,
  // Configuration paths
  getWorkingDirectory,
  getDatabasePath,
  getDatabaseFile,
  getMcpConfigPath,
  prepareAppDataSpaces,
  readHelpState,
  writeHelpState,
} from '@mcp-shark/mcp-shark-common';

Database Initialization

import { openDb } from '@mcp-shark/mcp-shark-common';

// Open or create database with schema
const db = openDb('/path/to/database.sqlite');

Logging

import { getLogger } from '@mcp-shark/mcp-shark-common';

const logger = getLogger(db);

// Log a request packet
logger.logRequestPacket({
  method: 'POST',
  url: '/mcp',
  headers: {
    /* ... */
  },
  body: {
    /* ... */
  },
  userAgent: '...',
  remoteAddress: '...',
});

// Log a response packet
logger.logResponsePacket({
  statusCode: 200,
  headers: {
    /* ... */
  },
  body: {
    /* ... */
  },
  requestFrameNumber: frameNumber,
  requestTimestampNs: timestampNs,
});

Configuration Paths

import {
  getWorkingDirectory,
  getDatabasePath,
  getDatabaseFile,
  getMcpConfigPath,
  prepareAppDataSpaces,
} from '@mcp-shark/mcp-shark-common';

// Get paths
const workingDir = getWorkingDirectory(); // ~/.mcp-shark
const dbPath = getDatabasePath(); // ~/.mcp-shark/db
const dbFile = getDatabaseFile(); // ~/.mcp-shark/db/mcp-shark.sqlite
const configPath = getMcpConfigPath(); // ~/.mcp-shark/mcps.json

// Create directories if they don't exist
prepareAppDataSpaces();

📁 Project Structure

This library is organized into modules:

@mcp-shark/mcp-shark-common/
├── index.js             # Main entry point (exports all utilities)
├── db/
│   ├── init.js          # Database initialization and schema
│   ├── logger.js        # Audit logging functions
│   └── query.js         # Database query utilities
└── configs/
    └── index.js         # Configuration path management

🗄️ Database Schema

The package defines a comprehensive SQLite schema with three main tables:

packets

Individual HTTP request/response packets with full metadata:

  • Timestamps (nanosecond precision)
  • Direction (request/response)
  • HTTP metadata (method, URL, status code)
  • Headers and body (raw and parsed JSON)
  • JSON-RPC metadata (ID, method, result, error)
  • Session identification
  • Network metadata

conversations

Correlated request/response pairs:

  • Links requests to their corresponding responses
  • Tracks conversation flow
  • Includes timing and performance metrics

sessions

Session tracking for stateful MCP interactions:

  • Session ID management
  • Session metadata
  • Lifecycle tracking

🛠️ Development

Scripts

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Format code
npm run format

# Check formatting
npm run format:check

Code Quality

  • ESLint: Code linting with Prettier integration
  • Prettier: Code formatting
  • Husky: Git hooks for pre-commit checks
  • Commitlint: Conventional commit message validation

📝 License

ISC

🤝 Contributing

Contributions are welcome! Please ensure your code passes linting and formatting checks before submitting.


Built with ❤️ for MCP Shark