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
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A Model Context Protocol server that enables SQL queries and database exploration in AWS Athena through a standardized interface.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that enables secure and structured interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries with controlled access.Last updated -47MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables secure interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.Last updated -226MIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables executing SQL queries and managing connections with Microsoft SQL Server databases.Last updated -1876MIT License