cboettig/mcp-server
If you are the rightful owner of mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Data Query Server is an MCP server that allows LLMs to query datasets using SQL through DuckDB integration.
sql_query
Execute SQL queries against the datasets.
describe_table
Get schema and metadata for a specific table.
list_tables
List all available tables with descriptions.
Data Query Server - MCP
An MCP (Model Context Protocol) server that enables LLMs to query datasets using SQL through DuckDB integration.
Features
- SQL Query Execution: Execute SQL queries against preloaded datasets
- Schema Inspection: Explore table structures and metadata
- Sample Datasets: Includes sales and customer data for demonstration
- Docker Support: Easy deployment with Docker and docker-compose
- Type Safety: Full type hints for better code quality
Quick Start
1. Install Dependencies
uv sync --dev --all-extras
2. Run the Server
uv run python -m data_query_server
3. Using Docker
# Build and run with docker-compose
docker-compose up --build
# Or build manually
docker build -t data-query-server .
docker run -v ./data:/app/data data-query-server
Using Pre-built Images
Docker images are automatically built and published to GitHub Container Registry on every release:
# Pull the latest image
docker pull ghcr.io/cboettig/mcp-server:latest
# Run with the pre-built image
docker run --rm ghcr.io/cboettig/mcp-server:latest
# Or use with docker-compose by updating the image reference
# image: ghcr.io/cboettig/mcp-server:latest
Available tags:
latest
: Latest stable release from main branchv1.0.0
: Specific version tagsmain
: Latest from main branch
Available Tools
The MCP server provides these tools for LLMs:
sql_query
: Execute SQL queries against the datasetsdescribe_table
: Get schema and metadata for a specific tablelist_tables
: List all available tables with descriptions
Sample Datasets
The server comes with two pre-loaded datasets:
Sales Table
order_id
: Unique order identifiercustomer_id
: Customer referenceproduct
: Product name (Product A, B, C)quantity
: Number of items orderedprice
: Price per itemorder_date
: Date of the order
Customers Table
customer_id
: Unique customer identifiername
: Customer nameemail
: Customer email addresscity
: Customer cityregistration_date
: Date customer registered
Example Queries
-- Top selling products
SELECT product, SUM(quantity * price) as revenue
FROM sales
GROUP BY product
ORDER BY revenue DESC;
-- Customer order history
SELECT c.name, COUNT(s.order_id) as order_count, SUM(s.quantity * s.price) as total_spent
FROM customers c
JOIN sales s ON c.customer_id = s.customer_id
GROUP BY c.customer_id, c.name
ORDER BY total_spent DESC;
-- Monthly sales trends
SELECT
strftime('%Y-%m', order_date) as month,
COUNT(*) as orders,
SUM(quantity * price) as revenue
FROM sales
GROUP BY strftime('%Y-%m', order_date)
ORDER BY month;
Development
Project Structure
src/
āāā data_query_server/
ā āāā __init__.py
ā āāā __main__.py
ā āāā server.py # Main MCP server implementation
data/ # DuckDB database files
datasets/ # Additional dataset files
.vscode/
āāā mcp.json # MCP server configuration
āāā tasks.json # VS Code tasks
Configuration
The MCP server is configured in .vscode/mcp.json
:
{
"servers": {
"data-query-server": {
"type": "stdio",
"command": "uv",
"args": ["run", "python", "-m", "data_query_server"]
}
}
}
Adding New Datasets
To add new datasets to the server:
- Place CSV files in the
datasets/
directory - Modify the
load_sample_datasets()
method inserver.py
- Update the
available_datasets
metadata
Example:
# Load your CSV data
new_data = pd.read_csv('datasets/your_data.csv')
# Create table in DuckDB
self.conn.execute("CREATE OR REPLACE TABLE your_table AS SELECT * FROM new_data")
# Add metadata
self.available_datasets['your_table'] = {
'description': 'Description of your dataset',
'columns': list(new_data.columns),
'row_count': len(new_data)
}
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License
- Each note resource has a name, description and text/plain mimetype
Prompts
The server provides a single prompt:
- summarize-notes: Creates summaries of all stored notes
- Optional "style" argument to control detail level (brief/detailed)
- Generates prompt combining all current notes with style preference
Tools
The server implements one tool:
- add-note: Adds a new note to the server
- Takes "name" and "content" as required string arguments
- Updates server state and notifies clients of resource changes
Configuration
[TODO: Add configuration details specific to your implementation]
Quickstart
Install
Claude Desktop
On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
Development/Unpublished Servers Configuration
``` "mcpServers": { "data-query-server": { "command": "uv", "args": [ "--directory", "/home/cboettig/Documents/github/schmidtdse/mcp-server", "run", "data-query-server" ] } } ```Published Servers Configuration
``` "mcpServers": { "data-query-server": { "command": "uvx", "args": [ "data-query-server" ] } } ```Development
Building and Publishing
To prepare the package for distribution:
- Sync dependencies and update lockfile:
uv sync
- Build package distributions:
uv build
This will create source and wheel distributions in the dist/
directory.
- Publish to PyPI:
uv publish
Note: You'll need to set PyPI credentials via environment variables or command flags:
- Token:
--token
orUV_PUBLISH_TOKEN
- Or username/password:
--username
/UV_PUBLISH_USERNAME
and--password
/UV_PUBLISH_PASSWORD
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.
You can launch the MCP Inspector via npm
with this command:
npx @modelcontextprotocol/inspector uv --directory /home/cboettig/Documents/github/schmidtdse/mcp-server run data-query-server
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.