A
AWS Athena
community
database
A MCP server for AWS Athena to run SQL queries on Glue Catalog.
@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.
<a href="https://glama.ai/mcp/servers/0i7dhkex6t">
<img width="380" height="200" src="https://glama.ai/mcp/servers/0i7dhkex6t/badge" alt="aws-athena-mcp MCP server" />
</a>
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:
-
: Execute a SQL query using AWS Athenarun_query
- 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:
-
: Check the status of a query executionget_status
- 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:
-
: Retrieve results for a completed queryget_result
- 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 all saved (named) queries in Athena.list_saved_queries
-
Returns:
- An array of saved queries with
,id
, and optionalname
description
- Queries are returned from the configured
andATHENA_WORKGROUP
AWS_REGION
- An array of saved queries with
-
run_saved_query: Run a previously saved query by its ID.
-
Parameters:
: ID of the saved querynamedQueryId
: Optional override of the saved query's default databasedatabaseOverride
: Maximum number of rows to return (default: 1000)maxRows
: Timeout in milliseconds (default: 60000)timeoutMs
-
Returns:
- Same behavior as
: full results or execution IDrun_query
- 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
andATHENA_WORKGROUP
AWS_REGION
License
MIT
Repository
Related Servers
Apache IoTDB
official
MCP Server for [Apache IoTDB](https://github.com/apache/iotdb) database and its tools
View Details