Query AWS Athena Data with AI
MCP server for running SQL queries against AWS Athena, with async execution tracking, saved queries, and configurable result limits.
Maintainer of this project? Claim this page to edit the listing.
1.0.0Add to Favorites
Why it matters
Enable AI assistants to execute SQL queries against AWS Athena databases and retrieve structured results. This connector facilitates data analysis and integration by allowing AI to interact directly with your Athena data.
Outcomes
What it gets done
Execute SQL queries against AWS Athena.
Retrieve query results with configurable row limits.
Manage saved queries within Athena workgroups.
Handle long-running queries with timeout and retry mechanisms.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-aws-athena | bash Capabilities
Tools your agent gets
Execute a SQL query using AWS Athena with parameters for database, query, and maximum number of rows
Check the execution status of a query by queryExecutionId
Retrieve results from a completed query by queryExecutionId
List all saved (named) queries in Athena
Execute a previously saved query by its ID with optional database override
Overview
AWS Athena MCP Server
Runs SQL queries against AWS Athena from an AI assistant via five tools covering execution, status polling, result retrieval, and saved-query management, with configurable timeouts and row limits. Use when an assistant needs to query AWS Athena data conversationally; requires AWS credentials with Athena/S3 permissions and an S3 bucket configured for query output.
What it does
AWS Athena MCP Server lets an AI assistant execute SQL queries against AWS Athena databases and retrieve results. It exposes five tools. run_query executes a SQL query against a specified database with a configurable maxRows cap (default 1,000, max 10,000); if the query finishes within the timeout it returns full results, otherwise it returns just a queryExecutionId for later retrieval. get_status checks a query execution's state (QUEUED, RUNNING, SUCCEEDED, FAILED, or CANCELLED), along with the state-change reason, submission/completion timestamps, and execution statistics when available. get_result retrieves results for a completed query by its execution ID, returning an error if the query failed or is still running. list_saved_queries lists all saved (named) queries configured in Athena, scoped to the configured workgroup and region, returning each query's ID, name, and optional description. run_saved_query runs a previously saved query by ID, optionally overriding its default database, with the same result/execution-ID behavior as run_query.
Example interactions shown in the source include listing all Athena databases (SHOW DATABASES), listing tables in a database (SHOW TABLES), describing a table's schema (DESCRIBE), previewing rows with a LIMIT, and running an aggregation query (average price by category for in-stock products, grouped and ordered). Saved queries can similarly be listed and re-run by ID with an overridden row limit.
When to use - and when NOT to
Use this when an AI assistant needs to query data warehoused in AWS Athena - exploring schema, previewing table contents, or running ad hoc analytical SQL - and get results back conversationally. It requires AWS credentials with appropriate Athena and S3 permissions (configurable via AWS CLI config, environment variables, or an IAM role when running on AWS), and an S3 bucket to hold query results, since Athena writes results to S3 as part of its execution model.
Capabilities
Query timeout, retry count, and retry delay are all configurable (QUERY_TIMEOUT_MS defaults to 5 minutes, MAX_RETRIES defaults to 100 attempts, RETRY_DELAY_MS defaults to 500ms), and a specific Athena workgroup can be targeted via ATHENA_WORKGROUP. Saved (named) queries used with list_saved_queries/run_saved_query must already exist in the configured workgroup and region.
How to install
{
"mcpServers": {
"athena": {
"command": "npx",
"args": ["-y", "@lishenxydlgzs/aws-athena-mcp"],
"env": {
"OUTPUT_S3_PATH": "s3://your-bucket/athena-results/"
}
}
}
}
OUTPUT_S3_PATH is the only required environment variable; AWS_REGION, AWS_PROFILE, AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN, ATHENA_WORKGROUP, and the timeout/retry settings are all optional with sensible defaults. Requirements are Node.js 16 or later, valid AWS credentials, and an S3 bucket for query output.
Who it's for
Data analysts and engineers who want an AI assistant to run ad hoc SQL against AWS Athena - exploring schemas, previewing data, running aggregations, or re-running saved queries - without switching to the AWS console or a separate query tool.
Source README
@lishenxydlgzs/aws-athena-mcp
A Model Context Protocol (MCP) server for running AWS Athena queries. This server enables AI assistants to execute SQL queries against your AWS Athena databases and retrieve results.
Usage
Configure AWS credentials using one of the following methods:
- AWS CLI configuration
- Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - IAM role (if running on AWS)
Add the server to your MCP configuration:
{
"mcpServers": {
"athena": {
"command": "npx",
"args": ["-y", "@lishenxydlgzs/aws-athena-mcp"],
"env": {
// Required
"OUTPUT_S3_PATH": "s3://your-bucket/athena-results/",
// Optional AWS configuration
"AWS_REGION": "us-east-1", // Default: AWS CLI default region
"AWS_PROFILE": "default", // Default: 'default' profile
"AWS_ACCESS_KEY_ID": "", // Optional: AWS access key
"AWS_SECRET_ACCESS_KEY": "", // Optional: AWS secret key
"AWS_SESSION_TOKEN": "", // Optional: AWS session token
// Optional server configuration
"ATHENA_WORKGROUP": "default_workgroup", // Optional: specify the Athena WorkGroup
"QUERY_TIMEOUT_MS": "300000", // Default: 5 minutes (300000ms)
"MAX_RETRIES": "100", // Default: 100 attempts
"RETRY_DELAY_MS": "500" // Default: 500ms between retries
}
}
}
}
- The server provides the following tools:
run_query: Execute a SQL query using AWS Athena- Parameters:
- database: The Athena database to query
- query: SQL query to execute
- maxRows: Maximum number of rows to return (default: 1000, max: 10000)
- Returns:
- If query completes within timeout: Full query results
- If timeout reached: Only the queryExecutionId for later retrieval
- Parameters:
get_status: Check the status of a query execution- Parameters:
- queryExecutionId: The ID returned from run_query
- Returns:
- state: Query state (QUEUED, RUNNING, SUCCEEDED, FAILED, or CANCELLED)
- stateChangeReason: Reason for state change (if any)
- submissionDateTime: When the query was submitted
- completionDateTime: When the query completed (if finished)
- statistics: Query execution statistics (if available)
- Parameters:
get_result: Retrieve results for a completed query- Parameters:
- queryExecutionId: The ID returned from run_query
- maxRows: Maximum number of rows to return (default: 1000, max: 10000)
- Returns:
- Full query results if the query has completed successfully
- Error if query failed or is still running
- Parameters:
list_saved_queries: List all saved (named) queries in Athena.Returns:
- An array of saved queries with
id,name, and optionaldescription - Queries are returned from the configured
ATHENA_WORKGROUPandAWS_REGION
- An array of saved queries with
run_saved_query: Run a previously saved query by its ID.
Parameters:
namedQueryId: ID of the saved querydatabaseOverride: Optional override of the saved query's default databasemaxRows: Maximum number of rows to return (default: 1000)timeoutMs: Timeout in milliseconds (default: 60000)
Returns:
- Same behavior as
run_query: full results or execution ID
- Same behavior as
Usage Examples
Show All Databases
Message to AI Assistant:List all databases in Athena
MCP parameter:
{
"database": "default",
"query": "SHOW DATABASES"
}
List Tables in a Database
Message to AI Assistant:Show me all tables in the default database
MCP parameter:
{
"database": "default",
"query": "SHOW TABLES"
}
Get Table Schema
Message to AI Assistant:What's the schema of the asin_sitebestimg table?
MCP parameter:
{
"database": "default",
"query": "DESCRIBE default.asin_sitebestimg"
}
Table Rows Preview
Message to AI Assistant:Show some rows from my_database.mytable
MCP parameter:
{
"database": "my_database",
"query": "SELECT * FROM my_table LIMIT 10",
"maxRows": 10
}
Advanced Query with Filtering and Aggregation
Message to AI Assistant:Find the average price by category for in-stock products
MCP parameter:
{
"database": "my_database",
"query": "SELECT category, COUNT(*) as count, AVG(price) as avg_price FROM products WHERE in_stock = true GROUP BY category ORDER BY count DESC",
"maxRows": 100
}
Checking Query Status
{
"queryExecutionId": "12345-67890-abcdef"
}
Getting Results for a Completed Query
{
"queryExecutionId": "12345-67890-abcdef",
"maxRows": 10
}
Listing Saved Queries
{
"name": "list_saved_queries",
"arguments": {}
}
Running a Saved Query
{
"name": "run_saved_query",
"arguments": {
"namedQueryId": "abcd-1234-efgh-5678",
"maxRows": 100
}
}
Requirements
- Node.js >= 16
- AWS credentials with appropriate Athena and S3 permissions
- S3 bucket for query results
- Named queries (optional) must exist in the specified
ATHENA_WORKGROUPandAWS_REGION
Repository
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.