mcpField
@
@lishenxydlgzs/aws-athena-mcp

@lishenxydlgzs/aws-athena-mcp

Local
github.com/lishenxydlgzsCloud & Infra41Updated 8w ago

About @lishenxydlgzs/aws-athena-mcp

@lishenxydlgzs/aws-athena-mcp is an MCP server for running SQL queries against AWS Athena databases. It lets AI assistants execute queries and retrieve results, and it also lists and runs saved named queries.

Key features

  1. 01Run SQL queries and return results
  2. 02Check query execution status
  3. 03Retrieve results of completed queries
  4. 04List and run saved named queries
  5. 05Configurable maximum row count

Use cases

  1. 01Browsing databases and table schemas through an AI assistant
  2. 02Previewing table rows or running aggregations
  3. 03Tracking long-running queries by execution ID

MCP support

This project is an MCP server that exposes run_query, get_status, get_result, list_saved_queries and run_saved_query tools to MCP clients.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"aws-athena": {
"command": "npx",
"args": [
"-y",
"@lishenxydlgzs/aws-athena-mcp"
],
"env": {
"OUTPUT_S3_PATH": "<OUTPUT_S3_PATH>",
"AWS_REGION": "<AWS_REGION>",
"AWS_PROFILE": "<AWS_PROFILE>",
"AWS_ACCESS_KEY_ID": "<AWS_ACCESS_KEY_ID>",
"AWS_SECRET_ACCESS_KEY": "<AWS_SECRET_ACCESS_KEY>",
"AWS_SESSION_TOKEN": "<AWS_SESSION_TOKEN>",
"ATHENA_WORKGROUP": "<ATHENA_WORKGROUP>",
"QUERY_TIMEOUT_MS": "<QUERY_TIMEOUT_MS>",
"MAX_RETRIES": "<MAX_RETRIES>",
"RETRY_DELAY_MS": "<RETRY_DELAY_MS>"
}
}
}
}
Run commandnpx -y @lishenxydlgzs/aws-athena-mcp
Environment variables to set
OUTPUT_S3_PATH
AWS_REGION
AWS_PROFILE
AWS_ACCESS_KEY_IDSecret
AWS_SECRET_ACCESS_KEYSecret
AWS_SESSION_TOKENSecret
ATHENA_WORKGROUP
QUERY_TIMEOUT_MS
MAX_RETRIES
RETRY_DELAY_MS

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@lishenxydlgzs/aws-athena-mcp

Tools

5

Saved tool list · updated 3w ago

ParameterTypeRequiredDescription
querystringYesSQL query to execute
maxRowsnumberNoMaximum number of rows to return (default: 1000)
databasestringYesThe Athena database to query
timeoutMsnumberNoTimeout in milliseconds (default: 60000)

Details

From the project README

@lishenxydlgzs/aws-athena-mcp

LightNow

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-athena-mcp MCP server

Usage

  1. 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)
  2. 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
      }
    }
  }
}
  1. The server provides the following tools:
  • run_query: Execute a SQL query using AWS Athena

    • 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
  • get_status: Check the status of a query execution

    • 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)
  • get_result: Retrieve results for a completed query

    • 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
  • list_saved_queries: List all saved (named) queries in Athena.

  • Returns:

    • An array of saved queries with 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.

  • Parameters:

    • namedQueryId: ID of the saved query
    • databaseOverride: Optional override of the saved query's default database
    • maxRows: 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

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_WORKGROUP and AWS_REGION

License

MIT

Repository

GitHub Repository

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.