aws-athena-mcp
The @lishenxydlgzs/aws-athena-mcp server enables AI assistants to interact with AWS Athena databases by executing and managing SQL queries.
Capabilities include:
Run SQL queries: Execute custom SQL queries against specified Athena databases
Get query results: Retrieve results for completed queries, limited by a maximum number of rows
Check query status: Monitor the status of query executions, including state, timestamps, and statistics
List saved queries: Fetch all named (saved) queries in Athena
Run saved queries: Execute previously saved queries by their ID, with optional configuration overrides
Configure AWS credentials: Supports multiple credential configurations including CLI, environment variables, and IAM roles
Customize query execution: Set parameters like timeout, maximum retries, and Athena workgroup
Requires Node.js >= 16 to run the MCP server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@aws-athena-mcp show me the top 10 customers by total sales this month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@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 AthenaParameters:
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
get_status: Check the status of a query executionParameters:
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)
get_result: Retrieve results for a completed queryParameters:
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
list_saved_queries: List all saved (named) queries in Athena.Returns:
An array of saved queries with
id,name, and optionaldescriptionQueries are returned from the configured
ATHENA_WORKGROUPandAWS_REGION
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
Related MCP server: AWS Athena MCP Server
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
License
MIT
Repository
Available Tools
5 toolsget_resultA
Get results for a completed query. Returns error if query is still running.
Inputs: queryExecutionId (required), maxRows.
get_statusC
Get the current status of a query execution
Inputs: queryExecutionId (required).
list_saved_queriesA
List all saved (named) Athena queries available in your AWS account.
Inputs: no named parameters.
run_queryA
Execute a SQL query using AWS Athena. Returns full results if query completes before timeout, otherwise returns queryExecutionId.
Inputs: database (required), query (required), maxRows, timeoutMs.
run_saved_queryC
Execute a saved (named) Athena query by its query ID.
Inputs: namedQueryId (required), databaseOverride, maxRows, timeoutMs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose with no overlap: get_result retrieves results, get_status checks status, list_saved_queries lists queries, run_query executes new queries, and run_saved_query executes saved ones. The descriptions make it unambiguous which tool to use for each operation.
All tools follow a consistent verb_noun pattern with snake_case: get_result, get_status, list_saved_queries, run_query, and run_saved_query. This predictable naming makes it easy for agents to understand and select tools.
With 5 tools, this server is well-scoped for AWS Athena operations. Each tool earns its place by covering essential query lifecycle functions: listing, executing (both new and saved), checking status, and retrieving results. This is an appropriate number for the domain.
The tool set provides complete coverage for core Athena workflows: create/run queries (run_query, run_saved_query), monitor (get_status), and retrieve results (get_result), with list_saved_queries for discovery. A minor gap is the lack of tools for managing saved queries (e.g., create, update, delete), but agents can work around this.
Maintenance
Related MCP Connectors
SQL validation, formatting, parsing, metadata extraction, linting, and security analysis.
Query BigQuery, Snowflake, Redshift & Azure Synapse with natural language
Generate and run high performance queries on open and private spatial data at-scale in the cloud
Query your Lumo BI data: curated KPIs, aggregated queries and data exploration.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to execute SQL queries against AWS Athena databases, check query status, retrieve results, and manage saved queries with support for both local and remote deployment via Lambda.5375 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables execution of SQL queries against AWS Athena databases with schema discovery, query status management, and result retrieval through a standardized Model Context Protocol interface.55 PyPI23MIT
- AlicenseNot gradedqualityDmaintenanceEnables querying AWS Cost and Usage Report data via Amazon Athena for cost-effective and detailed cost analysis.2MIT
- FlicenseAqualityDmaintenanceEnables users to execute SQL queries, manage workgroups, databases, tables, and named queries in AWS Athena through natural language.15-