This MCP server enables AI assistants to execute SQL queries against AWS Athena databases and retrieve results. It provides a seamless way to interact with your Athena data through an MCP interface.
To use the AWS Athena MCP server, you'll need to configure AWS credentials and add the server to your MCP configuration.
Configure your AWS credentials using one of these methods:
AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
)Add the server 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",
"AWS_PROFILE": "default",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_SESSION_TOKEN": "",
"ATHENA_WORKGROUP": "default_workgroup",
"QUERY_TIMEOUT_MS": "300000",
"MAX_RETRIES": "100",
"RETRY_DELAY_MS": "500"
}
}
}
}
Required Environment Variables:
OUTPUT_S3_PATH
: S3 location where Athena will store query resultsOptional Environment Variables:
AWS_REGION
: AWS region (default: AWS CLI default region)AWS_PROFILE
: AWS CLI profile (default: 'default')AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, AWS_SESSION_TOKEN
: Optional AWS credentialsATHENA_WORKGROUP
: Athena WorkGroup to use (default: 'primary')QUERY_TIMEOUT_MS
: Query timeout in milliseconds (default: 300000ms/5min)MAX_RETRIES
: Maximum retry attempts (default: 100)RETRY_DELAY_MS
: Delay between retries in milliseconds (default: 500ms)Executes a SQL query using AWS Athena.
Parameters:
database
: The Athena database to queryquery
: SQL query to executemaxRows
: Maximum number of rows to return (default: 1000, max: 10000)Returns:
Checks the status of a query execution.
Parameters:
queryExecutionId
: The ID returned from run_queryReturns:
state
: Query state (QUEUED, RUNNING, SUCCEEDED, FAILED, or CANCELLED)stateChangeReason
: Reason for state change (if any)submissionDateTime
: When the query was submittedcompletionDateTime
: When the query completed (if finished)statistics
: Query execution statistics (if available)Retrieves results for a completed query.
Parameters:
queryExecutionId
: The ID returned from run_querymaxRows
: Maximum number of rows to return (default: 1000, max: 10000)Returns:
Lists all saved (named) queries in Athena.
Returns:
id
, name
, and optional description
ATHENA_WORKGROUP
and AWS_REGION
Runs 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:
run_query
: full results or execution IDMessage to AI Assistant:
List all databases in Athena
MCP parameter:
{
"database": "default",
"query": "SHOW DATABASES"
}
Message to AI Assistant:
Show me all tables in the default database
MCP parameter:
{
"database": "default",
"query": "SHOW TABLES"
}
Message to AI Assistant:
What's the schema of the asin_sitebestimg table?
MCP parameter:
{
"database": "default",
"query": "DESCRIBE default.asin_sitebestimg"
}
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
}
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
}
{
"queryExecutionId": "12345-67890-abcdef"
}
{
"queryExecutionId": "12345-67890-abcdef",
"maxRows": 10
}
{
"name": "list_saved_queries",
"arguments": {}
}
{
"name": "run_saved_query",
"arguments": {
"namedQueryId": "abcd-1234-efgh-5678",
"maxRows": 100
}
}
ATHENA_WORKGROUP
and AWS_REGION
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "athena" '{"command":"npx","args":["-y","@lishenxydlgzs/aws-athena-mcp"],"env":{"OUTPUT_S3_PATH":"s3://your-bucket/athena-results/","AWS_REGION":"us-east-1","AWS_PROFILE":"default","AWS_ACCESS_KEY_ID":"","AWS_SECRET_ACCESS_KEY":"","AWS_SESSION_TOKEN":"","ATHENA_WORKGROUP":"default_workgroup","QUERY_TIMEOUT_MS":"300000","MAX_RETRIES":"100","RETRY_DELAY_MS":"500"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"athena": {
"command": "npx",
"args": [
"-y",
"@lishenxydlgzs/aws-athena-mcp"
],
"env": {
"OUTPUT_S3_PATH": "s3://your-bucket/athena-results/",
"AWS_REGION": "us-east-1",
"AWS_PROFILE": "default",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_SESSION_TOKEN": "",
"ATHENA_WORKGROUP": "default_workgroup",
"QUERY_TIMEOUT_MS": "300000",
"MAX_RETRIES": "100",
"RETRY_DELAY_MS": "500"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"athena": {
"command": "npx",
"args": [
"-y",
"@lishenxydlgzs/aws-athena-mcp"
],
"env": {
"OUTPUT_S3_PATH": "s3://your-bucket/athena-results/",
"AWS_REGION": "us-east-1",
"AWS_PROFILE": "default",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_SESSION_TOKEN": "",
"ATHENA_WORKGROUP": "default_workgroup",
"QUERY_TIMEOUT_MS": "300000",
"MAX_RETRIES": "100",
"RETRY_DELAY_MS": "500"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect