Provides a connector to AWS Athena, enabling SQL queries and database exploration through a standardized interface. Allows listing databases, executing SQL queries, and describing database structures in AWS Athena.
AWS Athena MCP Server
A Model Context Protocol (MCP) server for AWS Athena that enables SQL queries and database exploration through a standardized interface.
🏗️ Project Structure
The project follows best practices for Python project organization:
🚀 Features
- Modular Architecture: Code organized in well-defined modules following single responsibility principle
- Complete Type Hints: Static typing for better maintainability
- Robust Error Handling: Custom exceptions and proper error handling
- Centralized Configuration: All configurations in a single location
- Tests Included: Unit and integration test structure
- Structured Logging: Configurable logging system
- Input Validation: Validators for different data types
🔌 MCP Configuration
To use this server in MCP clients like Cursor, add the following configuration to your mcp.json
file:
Configuration Options
Using Direct Credentials:
Using AWS Profile:
Using System Default Credentials:
Required Environment Variables
- AWS_S3_OUTPUT_LOCATION: S3 location where query results will be stored
Optional Environment Variables
- AWS_ACCESS_KEY_ID: AWS access key (if not using profile)
- AWS_SECRET_ACCESS_KEY: AWS secret key (if not using profile)
- AWS_PROFILE: Locally configured AWS profile
- AWS_REGION or AWS_DEFAULT_REGION: AWS region (default: us-east-1)
- LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)
⚠️ Security: For production environments, we recommend using IAM roles or AWS profiles instead of direct credentials in the configuration file.
📦 Installation
Development Installation
Production Installation
⚙️ Configuration
Configure the following environment variables:
🎯 Usage
Run the Server
Available Tools
- list_databases: Lists all available databases in Athena
- query_athena: Executes SQL queries in Athena
- describe_data_structure: Describes the structure of a database
🧪 Testing
🛠️ Development
Code Quality Tools
Development Environment Setup
📋 Implemented Best Practices
Architecture
- Separation of Concerns: Each module has a specific responsibility
- Dependency Inversion: Use of interfaces and dependency injection
- Single Responsibility Principle: Classes and functions with single purpose
- Factory Pattern: For AWS client creation
- Strategy Pattern: For different types of formatting and validation
Code Quality
- Type Hints: Static typing in all functions and methods
- Docstrings: Complete documentation in Google Style format
- Error Handling: Custom exceptions and proper handling
- Logging: Structured and configurable logging system
- Validation: Rigorous input validation
Project Structure
- src/ Layout: Clear separation between source code and other files
- Namespace Packages: Hierarchical organization of modules
- Test Structure: Tests organized mirroring code structure
- Configuration Files: Centralized and externalized configuration
🔧 Troubleshooting
Consult the TROUBLESHOOTING.md file for common issues and solutions.
📝 Module Structure
Core (src/athena_mcp/core/
)
- config.py: Centralized system configurations
- exceptions.py: Custom domain exceptions
Services (src/athena_mcp/services/
)
- athena_client.py: AWS Athena client factory and management
- athena_service.py: High-level services for Athena operations
Utils (src/athena_mcp/utils/
)
- formatters.py: Formatters for different output types
- helpers.py: General helper functions and utilities
- validators.py: Validators for different input types
Handlers (src/athena_mcp/handlers/
)
- tool_handlers.py: Handlers for MCP tools
🤝 Contributing
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
A Model Context Protocol server that enables SQL queries and database exploration in AWS Athena through a standardized interface.
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.Last updated -JavaScript
- -security-license-qualityA Model Context Protocol server that provides tools for connecting to and interacting with various database systems (SQLite, PostgreSQL, MySQL/MariaDB, SQL Server) through a unified interface.Last updated -Python
- -securityFlicense-qualityA Model Context Protocol server allowing Claude AI to interact with AWS resources through natural language, enabling users to query and manage AWS services without using the traditional AWS Console or CLI.Last updated -TypeScript
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI assistants to securely interact with OceanBase databases by listing tables, reading data, and executing SQL queries through a controlled interface.Last updated -12PythonApache 2.0