aws athena mcp
Run SQL queries with AWS Athena to access data available from AWS Glue catalog.
Run SQL queries with AWS Athena to access data available from AWS Glue catalog.
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.
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
Returns:
get_status
: Check the status of a query execution
Returns:
get_result
: Retrieve results for a completed query
Returns:
list_saved_queries
: List all saved (named) queries in Athena.
Returns:
id
, name
, and optional description
Queries are returned from the configured ATHENA_WORKGROUP
and AWS_REGION
run_saved_query: Run a previously saved query by its ID.
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)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
MIT
[
{
"description": "Execute a SQL query using AWS Athena. Returns full results if query completes before timeout, otherwise returns queryExecutionId.",
"inputSchema": {
"properties": {
"database": {
"description": "The Athena database to query",
"type": "string"
},
"maxRows": {
"description": "Maximum number of rows to return (default: 1000)",
"maximum": 10000,
"minimum": 1,
"type": "number"
},
"query": {
"description": "SQL query to execute",
"type": "string"
},
"timeoutMs": {
"description": "Timeout in milliseconds (default: 60000)",
"minimum": 1000,
"type": "number"
}
},
"required": [
"database",
"query"
],
"type": "object"
},
"name": "run_query"
},
{
"description": "Get results for a completed query. Returns error if query is still running.",
"inputSchema": {
"properties": {
"maxRows": {
"description": "Maximum number of rows to return (default: 1000)",
"maximum": 10000,
"minimum": 1,
"type": "number"
},
"queryExecutionId": {
"description": "The query execution ID",
"type": "string"
}
},
"required": [
"queryExecutionId"
],
"type": "object"
},
"name": "get_result"
},
{
"description": "Get the current status of a query execution",
"inputSchema": {
"properties": {
"queryExecutionId": {
"description": "The query execution ID",
"type": "string"
}
},
"required": [
"queryExecutionId"
],
"type": "object"
},
"name": "get_status"
}
]