aws-athena-mcp
@lishenxydlgzs/aws-athena-mcp
用于运行 AWS Athena 查询的模型上下文协议 (MCP) 服务器。此服务器使 AI 助手能够针对您的 AWS Athena 数据库执行 SQL 查询并检索结果。
用法
使用以下方法之一配置 AWS 凭证:
AWS CLI 配置
环境变量(
AWS_ACCESS_KEY_ID、AWS_SECRET_ACCESS_KEY)IAM 角色(如果在 AWS 上运行)
将服务器添加到您的 MCP 配置:
{
"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
}
}
}
}该服务器提供以下工具:
run_query:使用 AWS Athena 执行 SQL 查询参数:
数据库:要查询的 Athena 数据库
查询:要执行的 SQL 查询
maxRows:返回的最大行数(默认值:1000,最大值:10000)
返回:
如果查询在超时内完成:完整的查询结果
如果超时:仅获取 queryExecutionId 以供后续检索
get_status:检查查询执行的状态参数:
queryExecutionId:从 run_query 返回的 ID
返回:
状态:查询状态(QUEUED、RUNNING、SUCCEEDED、FAILED 或 CANCELLED)
stateChangeReason:状态改变的原因(如果有)
submissionDateTime:查询提交的时间
completionDateTime:查询完成的时间(如果完成)
统计信息:查询执行统计信息(如果有)
get_result:检索已完成查询的结果参数:
queryExecutionId:从 run_query 返回的 ID
maxRows:返回的最大行数(默认值:1000,最大值:10000)
返回:
如果查询成功完成,则显示完整的查询结果
如果查询失败或仍在运行,则出现错误
list_saved_queries:列出 Athena 中所有已保存(命名)的查询。返回:
包含
id、name和可选description的已保存查询数组查询从配置的
ATHENA_WORKGROUP和AWS_REGION返回
run_saved_query:通过 ID 运行之前保存的查询。
参数:
namedQueryId:已保存查询的 IDdatabaseOverride:可选覆盖已保存查询的默认数据库maxRows:返回的最大行数(默认值:1000)timeoutMs:超时时间(毫秒)(默认值:60000)
返回:
与
run_query相同的行为:完整结果或执行 ID
Related MCP server: AWS Athena MCP Server
使用示例
显示所有数据库
给 AI 助手的消息: List all databases in Athena
MCP参数:
{
"database": "default",
"query": "SHOW DATABASES"
}列出数据库中的表
给 AI 助手的消息: Show me all tables in the default database
MCP参数:
{
"database": "default",
"query": "SHOW TABLES"
}获取表架构
给 AI 助手的消息: What's the schema of the asin_sitebestimg table?
MCP参数:
{
"database": "default",
"query": "DESCRIBE default.asin_sitebestimg"
}表格行预览
发送给 AI 助手的消息: Show some rows from my_database.mytable
MCP参数:
{
"database": "my_database",
"query": "SELECT * FROM my_table LIMIT 10",
"maxRows": 10
}具有过滤和聚合的高级查询
给AI助手的消息: Find the average price by category for in-stock products
MCP参数:
{
"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
}
}要求
Node.js >= 16
具有适当 Athena 和 S3 权限的 AWS 凭证
用于存储查询结果的 S3 存储桶
命名查询(可选)必须存在于指定的
ATHENA_WORKGROUP和AWS_REGION中
执照
麻省理工学院
存储库
Available Tools
5 toolsget_resultA
Get results for a completed query. Returns error if query is still running.
Inputs: queryExecutionId (required), maxRows.
get_statusC
Get the current status of a query execution
Inputs: queryExecutionId (required).
list_saved_queriesA
List all saved (named) Athena queries available in your AWS account.
Inputs: no named parameters.
run_queryA
Execute a SQL query using AWS Athena. Returns full results if query completes before timeout, otherwise returns queryExecutionId.
Inputs: database (required), query (required), maxRows, timeoutMs.
run_saved_queryC
Execute a saved (named) Athena query by its query ID.
Inputs: namedQueryId (required), databaseOverride, maxRows, timeoutMs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose with no overlap: get_result retrieves results, get_status checks status, list_saved_queries lists queries, run_query executes new queries, and run_saved_query executes saved ones. The descriptions make it unambiguous which tool to use for each operation.
All tools follow a consistent verb_noun pattern with snake_case: get_result, get_status, list_saved_queries, run_query, and run_saved_query. This predictable naming makes it easy for agents to understand and select tools.
With 5 tools, this server is well-scoped for AWS Athena operations. Each tool earns its place by covering essential query lifecycle functions: listing, executing (both new and saved), checking status, and retrieving results. This is an appropriate number for the domain.
The tool set provides complete coverage for core Athena workflows: create/run queries (run_query, run_saved_query), monitor (get_status), and retrieve results (get_result), with list_saved_queries for discovery. A minor gap is the lack of tools for managing saved queries (e.g., create, update, delete), but agents can work around this.
Maintenance
Related MCP Connectors
SQL validation, formatting, parsing, metadata extraction, linting, and security analysis.
Read data flows and datasets; run read-only SQL on dataset rows in Coupler.io.
Query BigQuery, Snowflake, Redshift & Azure Synapse with natural language
Generate and run high performance queries on open and private spatial data at-scale in the cloud
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to execute SQL queries against AWS Athena databases, check query status, retrieve results, and manage saved queries with support for both local and remote deployment via Lambda.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables execution of SQL queries against AWS Athena databases with schema discovery, query status management, and result retrieval through a standardized Model Context Protocol interface.153 PyPI23MIT
- AlicenseNot gradedqualityDmaintenanceEnables querying AWS Cost and Usage Report data via Amazon Athena for cost-effective and detailed cost analysis.2MIT
- FlicenseAqualityDmaintenanceEnables users to execute SQL queries, manage workgroups, databases, tables, and named queries in AWS Athena through natural language.15-