Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AWS Athena MCP Servershow me the top 10 customers by total sales from the orders table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@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.
Features:
Execute SQL queries via AWS Athena
Support for both stdio (local) and Lambda + API Gateway (remote) deployment
OAuth 2.0 authentication via AWS Cognito (Lambda deployment)
Async query execution with status polling
Named query support
Deployment Options
Option 1: Local (stdio) - For MCP Clients
Use with Claude Desktop, Cline, or other MCP clients:
Option 1: Local (stdio) - For MCP Clients
Use with Claude Desktop, Cline, or other MCP clients:
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:
Option 2: Lambda + API Gateway - For Remote Access
Deploy as a serverless API with OAuth 2.0 authentication:
部署脚本会自动:
构建 TypeScript 代码
使用 SAM 部署到 AWS
创建 Cognito User Pool 和 App Client
配置 API Gateway OAuth 认证
输出完整的 OAuth 配置信息(包括 Client Secret)
保存配置到
.env.oauth文件
部署后输出示例:
测试部署:
手动获取配置(如果需要):
Client Integration:
For detailed OAuth setup instructions, see OAUTH-SETUP-GUIDE.md.
Available Tools
The server provides the following tools:
run_query: Execute a SQL query using AWS AthenaParameters:
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 executionParameters:
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 queryParameters:
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 optionaldescriptionQueries are returned from the configured
ATHENA_WORKGROUPandAWS_REGION
run_saved_query: Run 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:
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:
List Tables in a Database
Message to AI Assistant:
Show me all tables in the default database
MCP parameter:
Get Table Schema
Message to AI Assistant:
What's the schema of the asin_sitebestimg table?
MCP parameter:
Table Rows Preview
Message to AI Assistant:
Show some rows from my_database.mytable
MCP parameter:
Advanced Query with Filtering and Aggregation
Message to AI Assistant:
Find the average price by category for in-stock products
MCP parameter:
Checking Query Status
Getting Results for a Completed Query
Listing Saved Queries
Running a Saved Query
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_WORKGROUPandAWS_REGION
License
MIT