aws-athena-mcp
@lishenxydlgzs/aws-athena-mcp
AWS Athenaクエリを実行するためのModel Context Protocol(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: クエリが送信された日時
完了日時: クエリが完了した日時 (完了した場合)
統計: クエリ実行統計(利用可能な場合)
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.
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
Query Postgres, MySQL, BigQuery, Iceberg and files with DuckDB, with per-query cost checks.
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.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-