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.
| Name | Required | Description | Default |
|---|---|---|---|
| queryExecutionId | Yes | The query execution ID | |
| maxRows | No | Maximum number of rows to return (default: 1000) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It adds value by stating the error condition ('Returns error if query is still running'), which is useful context beyond the input schema. However, it lacks details on permissions, rate limits, response format, or pagination behavior (e.g., how maxRows affects output). For a tool with no annotations, this is a moderate disclosure, scoring a 3.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise and front-loaded: two sentences that directly state the tool's function and a key behavioral constraint. Every sentence earns its place by providing essential information without waste, making it efficient and well-structured for an AI agent.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the basic purpose and an error condition, but lacks details on return values (since no output schema exists), authentication, or how it integrates with sibling tools. For a result-retrieval tool, this is minimally adequate, scoring a 3.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the input schema fully documents both parameters (queryExecutionId and maxRows). The description does not add any parameter-specific semantics beyond what the schema provides (e.g., it doesn't explain the format of queryExecutionId or how maxRows interacts with query results). According to the rules, with high schema coverage (>80%), the baseline is 3 even with no param info in the description, which applies here.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Get results for a completed query.' It specifies the verb ('Get') and resource ('results'), and distinguishes it from siblings like 'get_status' (which checks query status) and 'run_query' (which executes queries). However, it doesn't explicitly differentiate from 'list_saved_queries' or 'run_saved_query' in terms of result retrieval, making it a 4 rather than a 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides implied usage guidance: it should be used only for completed queries ('Returns error if query is still running'), suggesting an alternative might be 'get_status' to check completion first. However, it doesn't explicitly state when to use this tool versus alternatives like 'get_status' for status checks or 'run_query' for execution, nor does it mention prerequisites (e.g., needing a queryExecutionId from a prior run). This is adequate but has gaps, scoring a 3.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_statusC
Get the current status of a query execution
| Name | Required | Description | Default |
|---|---|---|---|
| queryExecutionId | Yes | The query execution ID |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is to 'Get' status, implying a read-only operation, but doesn't specify whether this requires authentication, has rate limits, or details the return format (e.g., pending, completed, error). The description is minimal and misses key behavioral traits for a tool interacting with query executions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence with no wasted words, making it highly concise and front-loaded. It directly states the tool's purpose without unnecessary elaboration, which is efficient for an AI agent to parse and understand.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of query execution tools and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the status includes (e.g., progress indicators, error messages) or how it relates to sibling tools like 'get_result'. For a tool that likely returns dynamic execution state information, more context is needed to guide effective use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the single parameter 'queryExecutionId' documented as 'The query execution ID'. The description doesn't add any meaning beyond this, such as explaining where to obtain this ID or its format. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema adequately handles parameter documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Get' and the resource 'current status of a query execution', making the purpose specific and understandable. However, it doesn't explicitly distinguish this tool from its siblings like 'get_result' or 'run_query', which might also relate to query execution status or results.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'get_result' or 'run_query'. It lacks context about prerequisites, such as needing a query execution ID from a previous operation, and doesn't mention any exclusions or specific scenarios for its use.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_saved_queriesA
List all saved (named) Athena queries available in your AWS account.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden but only states what it does, not how it behaves. It doesn't disclose whether this requires specific IAM permissions, how results are paginated, if there are rate limits, or what the return format looks like.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence with zero waste - every word contributes to understanding the tool's purpose. Front-loaded with the core action ('List all saved queries') followed by clarifying details.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a read-only listing tool with no parameters and no output schema, the description is adequate but minimal. It doesn't address behavioral aspects like authentication requirements, result format, or limitations that would help an agent use it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has 0 parameters with 100% schema description coverage, so the baseline is 4. The description appropriately doesn't discuss parameters since none exist, which is correct for this case.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('List all saved queries') and identifies the target resource ('named Athena queries in your AWS account'). It distinguishes from siblings like run_saved_query (executes) and get_result/status (retrieves query results/metadata).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for retrieving available saved queries, but doesn't explicitly state when to use this versus alternatives like run_saved_query or when not to use it. No prerequisites or exclusions are mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run_queryA
Execute a SQL query using AWS Athena. Returns full results if query completes before timeout, otherwise returns queryExecutionId.
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | The Athena database to query | |
| query | Yes | SQL query to execute | |
| maxRows | No | Maximum number of rows to return (default: 1000) | |
| timeoutMs | No | Timeout in milliseconds (default: 60000) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it executes queries, returns full results if completed before timeout, otherwise returns a queryExecutionId. However, it lacks details on permissions, error handling, rate limits, or what 'full results' entails (e.g., format, pagination).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, front-loaded with the core purpose and followed by critical behavioral detail. Every word earns its place with no redundancy or fluff, making it highly efficient and well-structured.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations, no output schema, and 4 parameters, the description is moderately complete. It covers the core action and timeout behavior but misses details like result format, error cases, or integration with sibling tools (e.g., how queryExecutionId relates to get_result). For a query execution tool, more context would be helpful.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema fully documents all parameters. The description does not add meaning beyond what the schema provides (e.g., it doesn't explain parameter interactions or usage nuances). Baseline 3 is appropriate as the schema handles parameter documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Execute a SQL query using AWS Athena') and the resource ('Athena'), distinguishing it from siblings like get_result (which retrieves results), get_status (checks status), list_saved_queries (lists saved queries), and run_saved_query (runs saved queries). It precisely defines what this tool does.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage by mentioning timeout behavior, but it does not explicitly state when to use this tool versus alternatives like run_saved_query or get_result. No explicit exclusions or prerequisites are provided, leaving usage context somewhat vague.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run_saved_queryC
Execute a saved (named) Athena query by its query ID.
| Name | Required | Description | Default |
|---|---|---|---|
| namedQueryId | Yes | Athena NamedQueryId | |
| databaseOverride | No | Optional database override | |
| maxRows | No | Maximum number of rows to return (default: 1000) | |
| timeoutMs | No | Timeout in milliseconds (default: 60000) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool executes a query but doesn't mention what happens during execution (e.g., query runs on Athena, may take time, returns results directly or via reference), potential side effects, authentication needs, rate limits, or error handling. This is inadequate for a tool that likely involves computational resources and timeouts.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part earns its place by specifying the action, resource type, and key identifier, making it easy to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of executing Athena queries (involving timeouts, row limits, and potential async behavior), no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., results, status ID, error details), how to handle large results, or integration with sibling tools like 'get_status' for monitoring. This leaves critical gaps for an agent to use it effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description doesn't add any parameter-specific information beyond implying 'namedQueryId' is required. It doesn't explain relationships between parameters (e.g., how databaseOverride interacts with saved query settings) or provide usage examples, so it meets the baseline but doesn't enhance understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Execute') and resource ('saved (named) Athena query by its query ID'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'run_query' or 'get_result', but the focus on saved/named queries provides some implicit distinction.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'run_query' (for ad-hoc queries) or 'get_result' (for retrieving results). It mentions saved/named queries but doesn't clarify prerequisites (e.g., needing a saved query ID from 'list_saved_queries') or when this is preferred over other execution methods.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v1.0.0- First observed
get_result - First observed
get_status - First observed
list_saved_queries - First observed
run_query - First observed
run_saved_query
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
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
Ask your databases questions in plain English, run read-only SQL and set up data alerts.
Read your Iceberg tables hosted in Europe: find tables, run read-only SQL, view photos.
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.5798 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables execution of SQL queries against AWS Athena databases with schema discovery, query status management, and result retrieval through a standardized Model Context Protocol interface.23MIT
- 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-