Amazon EMR Log Analysis MCP Server
Discovers, reads, and writes EMR log files in Amazon S3 and stores Athena query results for analysis.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Amazon EMR Log Analysis MCP Server Analyze the logs for EMR cluster j-1ABCD2EFGH3IJ and tell me what's wrong"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Amazon EMR Log Analysis MCP Server
The Amazon EMR Log Analysis Model Context Protocol (MCP) server provides the capability to identify EMR issues by analyzing log files stored in Amazon Simple Storage Service (Amazon S3). It offers an integrated knowledge base of known issues and curated recommendations across Apache Spark, Hadoop YARN and HDFS, Apache Hive, Apache HBase, and Presto frameworks. It includes tools to perform ad-hoc log analysis of user provided log snippets and to query log files for existing EMR log files that are stored in Amazon S3.
Features
Curated Knowledge Base: 150+ known EMR issues across Spark, YARN, Hadoop, Hive, HBase, Presto, and EMR service components with AWS Support Knowledge Center links when available
EMR Cluster Analysis: Automatically discovers logs in S3 for provided EMR Cluster ID and uses Amazon Athena for optimized SQL queries across log files to identify known issues and provided aggregrated recommendations on top findings
Ad-hoc Log Analysis: Analyze user-provided log snippets directly in chat to provide recommendations
Related MCP server: Ops MCP Server
Prerequisites
This MCP server runs locally on the same host as your LLM client.
Set up AWS Identity and Access Management (IAM) credentials with access to EMR, Athena, and S3.
Publish cluster-specific logs to S3.
Athena query editor configured.
Available Tools
analyze_emr_logs- Analyzes EMR log content that is provided directly in chat for quick issue identificationanalyze_emr_cluster_logs- Discovers EMR cluster logs in S3 and performs analysis using Athena
Usage
Once configured, you can ask your AI assistant to analyze EMR logs and troubleshoot issues:
"Analyze the logs for EMR cluster j-XXXX"
"What issues are present in this EMR log?"
Installation
Clone the repository:
git clone https://github.com/aws-samples/sample-emr-log-analysis-mcp.git cd sample-emr-log-analysis-mcpCreate and activate a virtual environment using UV:
uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activateInstall the package:
uv pip install -e .Configure the MCP server in your LLM client such as Amazon Q for command line
For Amazon Q CLI, update MCP Config in
~/.aws/amazonq/mcp.jsonFor Cline, click on "Configure MCP Servers" option from MCP tab
{ "mcpServers": { "emr-log-analysis-mcp": { "autoApprove": [ "analyze_emr_logs", "analyze_emr_cluster_logs" ], "disabled": false, "timeout": 60, "type": "stdio", "command": "uv", "args": ["run", "--directory", "/path/to/sample-emr-log-analysis-mcp", "python", "-m", "emr_log_analysis.server"], "env": { "AWS_PROFILE": "your-aws-profile", "AWS_REGION": "us-east-1", "FASTMCP_LOG_LEVEL": "ERROR" } } } }
Security Considerations
Required IAM Permissions
The AWS credentials used by the user running the MCP server need the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EMRAccess",
"Effect": "Allow",
"Action": [
"emr:DescribeCluster"
],
"Resource": "arn:aws:emr:*:*:cluster/*"
},
{
"Sid": "AthenaAccess",
"Effect": "Allow",
"Action": [
"athena:StartQueryExecution",
"athena:GetQueryExecution",
"athena:GetQueryResults",
"athena:StopQueryExecution"
],
"Resource": [
"arn:aws:athena:*:*:workgroup/primary",
"arn:aws:athena:*:*:workgroup/emr-log-analysis"
]
},
{
"Sid": "S3Access",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject",
"s3:CreateBucket"
],
"Resource": [
"arn:aws:s3:::aws-logs-*",
"arn:aws:s3:::aws-logs-*/*",
"arn:aws:s3:::emr-log-analysis-*",
"arn:aws:s3:::emr-log-analysis-*/*"
]
},
{
"Sid": "GlueAccess",
"Effect": "Allow",
"Action": [
"glue:CreateDatabase",
"glue:CreateTable",
"glue:DeleteDatabase"
],
"Resource": [
"arn:aws:glue:*:*:database/emr_analysis_*",
"arn:aws:glue:*:*:table/emr_analysis_*/*"
]
},
{
"Sid": "STSAccess",
"Effect": "Allow",
"Action": [
"sts:GetCallerIdentity"
],
"Resource": "*"
}
]
}Log Data Protection
Enable S3 encryption on EMR log buckets using server-side encryption (AES-256 or KMS)
Enable Amazon CloudTrail to audit log access and analysis activities
Use VPC endpoints for S3 and Athena to keep traffic private (recommended for sensitive data)
EMR logs may contain sensitive information such as data samples, SQL queries, and configuration details
Environment-Specific AWS Profiles
Configure seperate AWS profiles based on your environment type (for example):
# Development - broader permissions for testing
export AWS_PROFILE=emr-dev
export AWS_REGION=us-east-1
# Production - restricted access with monitoring
export AWS_PROFILE=emr-prod
export AWS_REGION=us-east-1
## Troubleshooting
- If you encounter issues, verify your IAM permissions
## License
This project is licensed under the MIT-0 License. See the [LICENSE](LICENSE) file for details.Available Tools
2 toolsanalyze_emr_cluster_logsAnalyze Emr Cluster LogsB
Analyze EMR cluster logs using Amazon Athena.
This tool connects to an EMR cluster's logs in S3 and runs Athena queries to identify known issues based on a comprehensive knowledge base of curated EMR issues.
Prerequisites
EMR cluster with logging enabled to S3
AWS credentials with permissions for EMR, Athena, and S3
Athena query result location configured
Response Format
The response includes detailed findings with:
Issue summary and description
Component classification (Spark, YARN, Hadoop, etc.)
Occurrence count and sample log evidence
AWS Knowledge Center links when available for additional guidance
Inputs: cluster_id (required), region, time_window. Returns: Response for EMR cluster log analysis using Athena.
analyze_emr_logsAnalyze Emr LogsA
Analyze EMR logs for known issues and recommendations.
This tool performs searchs against a comprehensive knowledge base of curated EMR issues across multiple big data frameworks. It's useful for quick analysis of directly provided EMR logs.
Usage Examples
Analyze Spark driver logs for OutOfMemoryError issues
Check YARN logs for container killed errors
Identify common Hadoop HDFS issues in namenode logs
Response Format
The response includes matched issues with:
Issue summary and detailed description
Matched patterns found in the logs
Confidence score for each match
Links to AWS Knowledge Center articles when available
Recommendations for remediation steps
Inputs: log_content (required). Returns: Response from analyzing EMR logs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
Both tools analyze EMR logs, so their names are close and an ambiguous request could cause misselection. However, the descriptions clearly separate direct log-text analysis from S3/Athena-based cluster log analysis, and each states distinct inputs and response formats.
Both names follow the same snake_case verb_noun pattern: analyze_emr_logs and analyze_emr_cluster_logs. The shared prefix also makes their relationship predictable.
Two tools is slightly thin, but the server has a narrow purpose and each tool covers a distinct analysis mode. Both are substantive and earn their place rather than appearing redundant.
The surface covers the two primary workflows: analyzing supplied logs and analyzing cluster logs stored in S3 via Athena. Minor supporting operations such as listing clusters, discovering log locations, or retrieving raw logs are absent, but agents can work around these with external AWS tooling.
Maintenance
Related MCP Connectors
Read LogBrew errors, slow traces, logs, and product analytics, and triage issues with consent.
Search log events, investigate anomalies, and manage cases in your Knowledge Grid tenant.
Finds what's broken in your product, explains why, and fixes it from your agent.
Read-only access to Auralogs production logs: search logs, inspect errors, review AI analyses.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to analyze Amazon EKS node logs collected by the EKS Log Collector script. It provides tools and troubleshooting workflows for diagnosing issues with VPC CNI, kubelet, DNS, and general node connectivity.-
- FlicenseAqualityDmaintenanceProvides tools for AI assistants to manage and diagnose MWAA Airflow environments, EMR Serverless jobs, S3 files, and Confluence documentation. It features automated pipeline failure diagnosis and comprehensive log retrieval across these integrated platforms.44-
- AlicenseNot gradedqualityDmaintenanceProvides intelligent guidance for EMR cluster management, configuration recommendations, and monitoring capabilities1MIT
- AlicenseNot gradedqualityDmaintenanceEnables log analysis through MCP tools for searching logs, retrieving error contexts, and summarizing incidents with self-verified root-cause hypotheses.ISC