Execute a SQL query using AWS Athena
Check the status of a query execution
Retrieve results for a completed query
List all saved (named) queries in Athena
Run a previously saved query by its ID
AWS Athena MCP provides a seamless interface for AI assistants to execute SQL queries against your AWS Athena databases. This server enables AI models to interact directly with your data stored in Amazon S3 through Athena's serverless query service. With this MCP, AI assistants can help you explore databases, analyze data, and generate insights by writing and executing SQL queries. The server handles authentication, query execution, and result retrieval, making it easy to integrate AWS Athena's powerful analytics capabilities into your AI workflows.
To use the AWS Athena MCP server, you'll need to add it to your MCP configuration. The server requires AWS credentials and an S3 bucket for storing query results.
Add the following to your MCP configuration:
{
"mcpServers": {
"athena": {
"command": "npx",
"args": ["-y", "@lishenxydlgzs/aws-athena-mcp"],
"env": {
"OUTPUT_S3_PATH": "s3://your-bucket/athena-results/",
"AWS_REGION": "us-east-1"
}
}
}
}
The server supports multiple authentication methods:
"env": {
"AWS_ACCESS_KEY_ID": "your-access-key",
"AWS_SECRET_ACCESS_KEY": "your-secret-key",
"AWS_SESSION_TOKEN": "your-session-token" // Optional
}
You can customize the server behavior with these additional environment variables:
AWS_PROFILE
: Specify which AWS CLI profile to use (default: "default")ATHENA_WORKGROUP
: Specify the Athena WorkGroup (default: "primary")QUERY_TIMEOUT_MS
: Maximum time to wait for query completion (default: 300000ms/5min)MAX_RETRIES
: Maximum number of status check attempts (default: 100)RETRY_DELAY_MS
: Delay between status check attempts (default: 500ms)Once configured, you can ask your AI assistant to interact with your Athena databases. The assistant will use the appropriate tools to execute queries and retrieve results.
For large datasets, consider:
maxRows
parameter to limit result sizeIf a query takes longer than the timeout period:
get_status
toolget_result
toolThe MCP supports working with Athena's saved (named) queries:
list_saved_queries
run_saved_query
This is useful for complex or frequently used queries that you've saved in the Athena console.