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:
Related MCP server: MySQL-MCP
π 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.