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

better-query-mcp

v0.1.0

Published

Model Context Protocol (MCP) server for better-query - enables AI assistants to interact with better-query APIs

Readme

Better Query MCP Server

A Model Context Protocol (MCP) server for better-query, enabling AI assistants to seamlessly discover and interact with better-query APIs.

What is MCP?

The Model Context Protocol is an open standard that allows AI applications to connect to external data sources and tools. This MCP server exposes better-query's CRUD operations, resource schemas, and plugin system to AI assistants like Claude Desktop, enabling them to understand and work with your better-query APIs.

Features

  • 🔍 Resource Discovery - List and explore all resources and their schemas
  • 📊 CRUD Operations - Create, read, update, and delete resource items
  • 🔗 Relationship Navigation - Discover and traverse resource relationships
  • 🧩 Plugin Information - Query active plugins and their capabilities
  • 🎯 Custom Operations - Execute adapter-specific custom operations
  • 📝 API Documentation - Get auto-generated API endpoint information

Installation

Using npm/pnpm

# Install globally
npm install -g better-query-mcp

# Or with pnpm
pnpm add -g better-query-mcp

From Source

# Clone the repository
git clone https://github.com/armelgeek/better-query.git
cd better-query/packages/better-query-mcp

# Install dependencies
pnpm install

# Build
pnpm build

Quick Start

1. Configure MCP Client

Add to your MCP client configuration (e.g., Claude Desktop):

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "better-query": {
      "command": "npx",
      "args": ["better-query-mcp"]
    }
  }
}

2. Start Using

Once configured, AI assistants can use tools like:

  • list_resources - Discover available resources
  • get_resource_schema - View resource schemas
  • list_resource_items - Query resource data
  • create_resource_item - Create new items
  • And more!

Available Tools

Resource Management

list_resources

Lists all available resources with their schemas and configurations.

// No parameters required

get_resource_schema

Gets detailed schema for a specific resource.

{
  resourceName: "user" // Name of the resource
}

CRUD Operations

list_resource_items

Lists items from a resource with filtering and pagination.

{
  resourceName: "user",
  filters?: { email: "[email protected]" },
  limit?: 50,
  offset?: 0,
  orderBy?: "createdAt",
  orderDirection?: "desc"
}

get_resource_item

Gets a single item by ID.

{
  resourceName: "user",
  id: "123"
}

create_resource_item

Creates a new item.

{
  resourceName: "user",
  data: {
    name: "John Doe",
    email: "[email protected]"
  }
}

update_resource_item

Updates an existing item.

{
  resourceName: "user",
  id: "123",
  data: {
    name: "Jane Doe"
  }
}

delete_resource_item

Deletes an item by ID.

{
  resourceName: "user",
  id: "123"
}

Relationships

get_resource_relationships

Gets relationship information for a resource.

{
  resourceName: "user"
}

get_related_items

Gets items related through a specific relationship.

{
  resourceName: "user",
  itemId: "123",
  relationshipName: "posts"
}

Plugin System

list_plugins

Lists all active plugins.

// No parameters required

get_plugin_info

Gets detailed information about a plugin.

{
  pluginId: "audit-log"
}

Advanced

execute_custom_operation

Executes adapter-specific custom operations.

{
  operationName: "bulkImport",
  params: {
    data: [...],
    options: {}
  }
}

get_api_endpoints

Lists all generated API endpoints.

// No parameters required

Integration Examples

With Better Query Application

// Your better-query setup
import { betterQuery, createResource } from 'better-query';
import { z } from 'zod';

const query = betterQuery({
  database: {
    provider: "sqlite",
    url: "./data.db"
  },
  resources: [
    createResource({
      name: "user",
      schema: z.object({
        name: z.string(),
        email: z.string().email(),
      })
    }),
    createResource({
      name: "post",
      schema: z.object({
        title: z.string(),
        content: z.string(),
        userId: z.string(),
      })
    })
  ]
});

// MCP server can now discover and interact with these resources!

Using with AI Assistant

User: "Show me all the resources available in this API"

AI (using list_resources):

Found 2 resources:
1. user - Schema: { name: string, email: string }
2. post - Schema: { title: string, content: string, userId: string }

User: "Create a new user named Alice"

AI (using create_resource_item):

Created user:
{
  id: "cuid123...",
  name: "Alice",
  email: "[email protected]"
}

Architecture

The MCP server acts as a bridge between AI assistants and better-query instances:

┌─────────────┐         ┌──────────────┐         ┌────────────────┐
│ AI Assistant│ ◄─MCP──►│ MCP Server   │ ◄─────► │ Better Query   │
│ (Claude)    │         │ (this pkg)   │         │ Instance       │
└─────────────┘         └──────────────┘         └────────────────┘

Development

Building

pnpm build

Running Locally

# Build and run
pnpm build
node dist/index.js

# Or in development mode
pnpm dev

Testing

pnpm test

Configuration

The MCP server can be configured through environment variables:

# Future configuration options
BETTER_QUERY_BASE_URL=http://localhost:3000/api
BETTER_QUERY_API_KEY=your-api-key

Troubleshooting

MCP Server Not Appearing

  1. Check your MCP client configuration file path
  2. Ensure better-query-mcp is installed globally or path is correct
  3. Restart your MCP client application

Tools Not Working

  1. Verify your better-query instance is running
  2. Check connection configuration
  3. Review MCP client logs for errors

Permission Issues

# Make script executable
chmod +x dist/index.js

Use Cases

  • 🤖 AI-Powered Admin Dashboards - Let AI help manage your data
  • 📊 Natural Language Queries - Query databases with plain language
  • 🔄 Data Migration - AI-assisted data transformations
  • 📝 Documentation - Auto-generate API documentation
  • 🧪 Testing - AI-driven test data generation

Roadmap

  • [ ] Real-time connection to running better-query instances
  • [ ] WebSocket support for live updates
  • [ ] Advanced filtering and search capabilities
  • [ ] Bulk operations support
  • [ ] Transaction management
  • [ ] Schema migrations through MCP
  • [ ] Plugin marketplace integration

Contributing

Contributions are welcome! Please see the Contributing Guide.

License

MIT - see LICENSE

Related


Need help? Open an issue on GitHub