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

@blaze-money/betterstack-logs-mcp

v1.0.7

Published

MCP server for querying and analyzing Betterstack logs via npx

Readme

Betterstack Logs MCP Server

An MCP (Model Context Protocol) server that enables AI assistants to query and analyze logs from Betterstack. Supports querying across multiple sources and source groups with intelligent source selection.

Features

  • Multi-source querying: Query individual sources or source groups
  • Source management: Discover and inspect available sources and groups
  • Query tools: Execute structured ClickHouse SQL queries with intelligent filtering
  • Historical data: Access both recent and archived logs
  • AI-friendly: Intelligent source selection based on query context

Quick Start with NPX (Recommended)

The easiest way to use this MCP server is via NPX - no installation required!

1. Add to Claude Code Configuration

Add this to your Claude Code MCP configuration file:

{
  "mcpServers": {
    "betterstack": {
      "command": "npx",
      "args": ["-y", "@blaze-money/betterstack-logs-mcp"],
      "env": {
        "BETTERSTACK_API_TOKEN": "your-api-token-here",
        "BETTERSTACK_CLICKHOUSE_USERNAME": "your-clickhouse-username",
        "BETTERSTACK_CLICKHOUSE_PASSWORD": "your-clickhouse-password",
        "BETTERSTACK_CLICKHOUSE_QUERY_ENDPOINT": "your-clickhouse-endpoint"
      }
    }
  }
}

2. Get Your Credentials

  • API Token: Get from BetterStack API settings
  • ClickHouse credentials: Available in your BetterStack team settings under "Log destinations"

3. Restart Claude

Restart Claude Code to load the new MCP server. The server will be automatically downloaded and started via NPX.

Local Development Installation

If you want to develop or modify the server locally:

  1. Clone this repository
  2. Install dependencies: npm install
  3. Build the project: npm run build
  4. Configure environment variables (see Configuration section)

Configuration

Environment Variables

Betterstack requires two different authentication methods:

Copy .env.example to .env and configure:

# ClickHouse Database Credentials (for log queries)
BETTERSTACK_CLICKHOUSE_USERNAME=your_clickhouse_username
BETTERSTACK_CLICKHOUSE_PASSWORD=your_clickhouse_password
BETTERSTACK_CLICKHOUSE_QUERY_ENDPOINT=your_clickhouse_endpoint_url

# API Token (for source management)
BETTERSTACK_API_TOKEN=your_api_token_from_betterstack_dashboard

# Optional
BETTERSTACK_DEFAULT_SOURCE_GROUP=production

Getting Your Credentials:

  1. ClickHouse Credentials (for log queries):

    • In Betterstack dashboard: DashboardsConnect remotelyCreate connection
    • Save the generated username, password, and endpoint URL
  2. API Token (for source management):

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "betterstack": {
      "command": "npx",
      "args": ["-y", "@blaze-money/betterstack-logs-mcp"],
      "env": {
        "BETTERSTACK_CLICKHOUSE_USERNAME": "your_clickhouse_username",
        "BETTERSTACK_CLICKHOUSE_PASSWORD": "your_clickhouse_password",
        "BETTERSTACK_CLICKHOUSE_QUERY_ENDPOINT": "your_clickhouse_endpoint_url",
        "BETTERSTACK_API_TOKEN": "your_api_token_here",
        "BETTERSTACK_DEFAULT_SOURCE_GROUP": "production"
      }
    }
  }
}

Available Tools

Source Management

  • list_sources: Get all available log sources
  • list_source_groups: Get configured source groups
  • get_source_info: Get details about a specific source
  • get_source_group_info: Get details about a source group

Query Tools

  • query_logs: Execute structured log queries with filtering and time range support
  • debug_table_info: Inspect source table schemas and query generation

Usage Examples

# List available sources
AI: What sources do we have?

# Query recent logs with filtering
AI: Show me ERROR level logs from the last hour in production

# Query specific time range
AI: Show me all logs from yesterday between 2pm and 4pm

# Get source group details
AI: What's included in our production source group?

Development

npm run dev    # Watch mode
npm run build  # Build for production

License

MIT