Uses InfluxDB Line Protocol for inserting data into QuestDB tables with automatic schema creation and type mapping
QuestDB MCP Server
A Model Context Protocol (MCP) server for QuestDB that enables AI assistants to interact with QuestDB databases through tools for querying and inserting data.
Features
Query Execution: Execute SELECT queries on QuestDB tables with structured output
Data Insertion: Insert data into QuestDB tables using the InfluxDB Line Protocol
Table Management: List tables and describe table schemas
Automatic Schema Creation: Tables and columns are created automatically on insert
Type Safety: Full TypeScript support with Zod schema validation
Structured Output: All tools return structured content with output schemas
MCP Logging: Integrated MCP logging messages for better observability
Error Handling: Comprehensive error handling with graceful degradation
Server Instructions: Built-in server instructions for AI assistants
Graceful Shutdown: Proper cleanup on SIGINT/SIGTERM signals
Prerequisites
Node.js v16 or newer
QuestDB instance running (see QuestDB Quick Start)
Installation
As a Package
Install from GitHub Packages:
Authentication Required: You'll need to authenticate to GitHub Packages.
Create a GitHub Personal Access Token (classic) with
read:packagesscopeCreate a
.npmrcfile in your project (or add to your global~/.npmrc):
Important: Never commit the .npmrc file with your token to git. It should be in your .gitignore.
From Source
Clone this repository or navigate to the project directory:
cd questdb-mcpInstall dependencies:
npm installBuild the project:
npm run build
Configuration
The server can be configured using environment variables:
QUESTDB_HOST- QuestDB host (default:localhost)QUESTDB_PORT- QuestDB port (default:9000)QUESTDB_USERNAME- QuestDB username (optional, for authentication)QUESTDB_PASSWORD- QuestDB password (optional, for authentication)QUESTDB_AUTO_FLUSH_ROWS- Auto-flush after N rows (optional)QUESTDB_AUTO_FLUSH_INTERVAL- Auto-flush interval in milliseconds (optional)
Usage
This package can be used in two ways:
1. CLI Usage
Run the MCP server directly:
Or for development:
Or install globally from GitHub Packages:
Note: Make sure you're authenticated to GitHub Packages (see Installation section above).
2. Library Usage
Install as a dependency in your TypeScript project:
Note: Make sure you're authenticated to GitHub Packages (see Installation section above).
Basic Usage
Custom Configuration
Using with Custom Transport
Accessing Internal Components
Creating Custom Tools
Shutdown
TypeScript Types
All types are exported and available for use:
Available Tools
1. query
Execute a SQL SELECT query on QuestDB.
Parameters:
query(string, required): The SQL query to execute (SELECT queries only)format(string, optional): Output format -jsonorcsv(default:json)
Example:
2. insert
Insert data into a QuestDB table. Tables and columns are created automatically if they don't exist.
Parameters:
table(string, required): The name of the table to insert intodata(object, required): An object containing the data to insertKeys are column names
Values are the data (strings, numbers, booleans)
Use
timestampkey for explicit timestamp (milliseconds since epoch)If
timestampis not provided, the current time is used
Example:
3. list_tables
List all tables in the QuestDB database.
Parameters: None
4. describe_table
Get the schema of a specific table.
Parameters:
table(string, required): The name of the table to describe
Example:
QuestDB Setup
Quick Start with Docker
Quick Start with Homebrew (macOS)
The QuestDB Web Console will be available at: http://localhost:9000
Development
Building
Type Checking
Development Mode
Data Types
The insert tool automatically maps JavaScript types to QuestDB types:
String →
SYMBOL(indexed string type)Number (integer) →
LONGNumber (float) →
DOUBLEBoolean →
BOOLEANTimestamp →
TIMESTAMP(when using thetimestampfield)
Security Notes
Only SELECT queries are allowed through the
querytool for safetyThe server uses the QuestDB REST API for queries and the InfluxDB Line Protocol for inserts
Authentication is supported via username/password if your QuestDB instance requires it
GitHub Packages Authentication: When using GitHub Packages, never commit your
.npmrcfile with your personal access token. The.npmrcfile is gitignored and should remain local only. Use.npmrc.exampleas a template.
Examples
Inserting Trade Data
Querying Data
Listing Tables
License
MIT
Resources
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables AI assistants to interact with QuestDB time-series databases through tools for querying data, inserting records using InfluxDB Line Protocol, and managing table schemas with automatic creation.