Salesforce Log AI Analyzer MCP
Provides tools for connecting to a Salesforce org via the SFDX CLI, listing and fetching debug logs, parsing raw log content or log files, generating token-efficient summaries, detecting issues (SOQL in loops, N+1 queries, governor limits, CPU hotspots, exceptions), extracting and correlating async jobs (Queueable, Batch, Future, Schedulable) across parent/child logs, and attributing issues to managed package namespaces.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Salesforce Log AI Analyzer - MCP
AI-First Salesforce Debug Log Analyzer - Local-first, AI-optimized debug log analysis for Salesforce via MCP
Overview
SF Debug Analyzer is a comprehensive tool for parsing and analyzing Salesforce debug logs with a focus on AI agent integration. It provides intelligent issue detection, async job correlation, and privacy-preserving analysis through the Model Context Protocol (MCP).
Related MCP server: Apex Log MCP Server
Features
π Intelligent Log Parsing
High-fidelity tokenizer - Parses all Salesforce debug log event types with line-by-line accuracy
AST builder - Creates hierarchical call trees with proper parent-child relationships
Truncation handling - Detects and recovers from log truncation, providing impact analysis
Streaming support - Memory-efficient parsing for large log files
π¨ Issue Detection
SOQL in Loops - Detects queries inside iteration blocks with exact line locations
N+1 Query Patterns - Identifies repeated queries suggesting missing bulkification
Governor Limit Analysis - Tracks CPU time, heap, SOQL limits with threshold warnings
Non-Selective Queries - Flags queries without proper indexing
Recursive Triggers - Detects trigger re-entry patterns
CPU Hotspots - Identifies methods consuming excessive CPU time
Exception Tracking - Captures unhandled exceptions with full stack traces
π’ Managed Package Support
Namespace Detection - Identifies managed package namespaces in logs
Attribution Engine - Attributes issues to specific packages or org code
Visibility Classification - Determines what's visible vs. hidden in ISV logs
AI Guidance - Provides actionable recommendations based on package ownership
π Async Job Correlation
Job Extraction - Identifies Queueable, Batch, Future, and Schedulable references
Cross-Log Tracking - Correlates parent logs with async child executions
Confidence Scoring - Rates correlation confidence based on timing and context
Unified View - Presents async chains as cohesive execution flows
π Privacy & Redaction
PII Detection - Identifies emails, phone numbers, SSNs, credit cards
Credential Masking - Redacts API keys, tokens, passwords
Custom Patterns - Configure organization-specific sensitive data patterns
Audit Trail - Tracks what was redacted without exposing original values
π§ Memory System
Solution Storage - Saves successful fixes for future reference
Episodic Memory - Recalls past debugging sessions by context
Semantic Search - Finds relevant past solutions using similarity matching
SQLite Persistence - Local-first storage with no cloud dependency
π€ MCP Server Integration
Built for AI assistants like GitHub Copilot, Claude, and others via the Model Context Protocol:
Tool | Description |
| Connect to Salesforce org via SFDX CLI |
| List available debug logs |
| Fetch a specific debug log |
| Parse raw log content directly |
| Parse log from file path (recommended for >1MB logs) |
| Get AI-optimized summary (<500 tokens) |
| Detect issues with severity and fix suggestions |
| Query events with flexible filters |
| Get AI-optimized context for specific issues |
| Extract async job references |
| Correlate parent log with async children |
| Store working solutions for learning |
| Get memory system statistics |
| End session with outcome feedback |
π CLI Interface
# Analyze a debug log with full output
sf-debug analyze /path/to/debug.log
# Output as JSON
sf-debug analyze /path/to/debug.log --format json
# Analyze with PII redaction
sf-debug analyze /path/to/debug.log --redact
# List issues with severity filtering
sf-debug issues /path/to/debug.log --min-severity HIGH
# Get a token-efficient summary (<500 tokens)
sf-debug summary /path/to/debug.log
# Query specific events with filtering
sf-debug query /path/to/debug.log --type SOQL_EXECUTE_BEGIN
# Query with pagination
sf-debug query /path/to/debug.log --type SOQL --limit 10Prerequisites
Before installing, ensure you have:
Node.js >= 18.0.0
npm or yarn
Git (for cloning the repository)
Salesforce CLI (SFDX) - Optional, but recommended for authentication
npm install -g @salesforce/cli
Installation
Clone from GitHub
# Clone the repository
git clone https://github.com/SalesforceDiariesBySanket/salesforce-log-ai-analyzer-mcp.git
cd salesforce-log-ai-analyzer-mcp
# Install dependencies
npm install
# Build the project
npm run buildLink for Local Development
To use the CLI commands globally during development:
# Link the package globally
npm link
# Now you can use the CLI anywhere
sf-debug --help
sf-debug-mcp --helpQuick Start
As MCP Server (AI Assistants)
Add to your VS Code MCP settings:
Windows:
%APPDATA%\Code\User\mcp.jsonmacOS:
~/Library/Application Support/Code/User/mcp.jsonLinux:
~/.config/Code/User/mcp.json
Windows Example:
{
"servers": {
"sf-debug-analyzer": {
"type": "stdio",
"command": "node",
"args": ["C:\\Users\\YourUsername\\path\\to\\salesforce-log-ai-analyzer-mcp\\dist\\mcp\\index.js"]
}
}
}macOS/Linux Example:
{
"servers": {
"sf-debug-analyzer": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/salesforce-log-ai-analyzer-mcp/dist/mcp/index.js"]
}
}
}Important Notes:
Use absolute paths (not relative paths like
./dist/mcp/index.js)On Windows, use double backslashes (
\\) or forward slashes (/)Run
npm run buildfirst to create thedistfolderRestart VS Code or reload the MCP connection after changes
For Claude Desktop (claude_desktop_config.json):
Windows:
{
"mcpServers": {
"sf-debug": {
"command": "node",
"args": ["C:\\Users\\YourUsername\\path\\to\\salesforce-log-ai-analyzer-mcp\\dist\\mcp\\index.js"]
}
}
}macOS/Linux:
{
"mcpServers": {
"sf-debug": {
"command": "node",
"args": ["/absolute/path/to/salesforce-log-ai-analyzer-mcp/dist/mcp/index.js"]
}
}
}Programmatic Usage
import { parseLog, analyzeLog, generateSummary } from './dist/index.js';
// Parse a log file
const result = parseLog(logContent);
if (result.success) {
console.log(`Parsed ${result.data.events.length} events`);
// Analyze for issues
const analysis = analyzeLog(result.data);
analysis.issues.forEach(issue => {
console.log(`[${issue.severity}] ${issue.title}`);
});
// Get AI-optimized summary (<500 tokens)
const summary = generateSummary(result.data, analysis);
console.log(`Health: ${summary.health}/100`);
}Salesforce Authentication
The tool supports multiple authentication methods for connecting to Salesforce orgs:
Method | Best For | Requirements |
SFDX Import | Most users | Salesforce CLI installed with cached auth |
OAuth PKCE | Local development | Browser access, localhost available |
Device Code | Remote/headless (SSH, Codespaces) | Org allows device code flow |
Manual Token | Fallback | Session ID from Developer Console |
Recommended: Use SFDX CLI
# Authenticate to your org using Salesforce CLI first
sf org login web --alias myorg
# The analyzer will automatically detect and use this authDevelopment
# Install dependencies
npm install
# Build
npm run build
# Build in watch mode (for development)
npm run build:watch
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Run specific module tests
npm run test:parser
npm run test:analyzer
npm run test:mcp
# Lint
npm run lint
# Lint and fix
npm run lint:fix
# Format
npm run formatPost-Installation Verification
After installation, verify everything works:
# 1. Check the build completed successfully
npm run build
# 2. Verify CLI is working
node dist/cli/index.js --help
# 3. Run tests
npm test
# 4. Test with a sample log (if available)
node dist/cli/index.js analyze __fixtures__/logs/simple/success.logArchitecture
This tool is designed AI-First - meaning AI agents (Claude, GitHub Copilot, etc.) are the primary consumers, with developers as secondary users via CLI.
Design Principles
Structured Output β JSON/JSONL, not prose (AI generates explanations)
Token-Efficient β Summary first, details on demand
Confidence-Scored β Probabilistic, not deterministic (enables AI to communicate uncertainty)
Local-First β No cloud dependency, SQLite persistence
Memory-Enabled β Learns from past debugging sessions
Privacy-Conscious β Auto-redact PII, opt-in persistence
Key Capabilities
Capability | Description |
Streaming Parser | Memory-efficient parsing for 20MB+ logs |
Truncation Handling | Graceful degradation when logs are cut off |
Debug Level Awareness | Adapts analysis based on log verbosity |
Multi-Auth Support | PKCE, Device Code, SFDX import, Manual token |
Trace Flag Management | Auto-create with optimal debug levels |
Project Structure
src/
βββ parser/ # Log tokenization and AST building
βββ analyzer/ # Issue detection and categorization
βββ async/ # Async job correlation (Batch, Queueable, Future)
βββ capture/ # Salesforce authentication and log fetching
βββ cli/ # Command-line interface
βββ managed/ # Managed package attribution
βββ mcp/ # MCP server for AI assistants
βββ memory/ # Solution memory with SQLite persistence
βββ output/ # Formatters and problem context
βββ privacy/ # Data redaction (PII, credentials)
βββ types/ # TypeScript type definitionsDebug Level Presets
The tool includes 11 optimized debug level presets for different debugging scenarios:
Preset | Use Case |
| Low overhead, production monitoring |
| SOQL limit issues, query optimization |
| Track all governor limit consumption |
| Trigger recursion, DML issues |
| CPU timeout, method profiling |
| Exception tracking with stack traces |
| External HTTP callout debugging |
| VF page performance |
| Process Builder, Flow debugging |
| Maximum detail (high overhead) |
| Balanced for AI analysis |
Acknowledgments
This project draws inspiration from several excellent Salesforce debugging tools and libraries in the community:
Log Analysis & Parsing
Certinia/debug-log-analyzer - Flame chart visualization, call tree rendering, SOQL selectivity analysis, governor limits by namespace
financialforcedev/apex-log-parser - JSON output format patterns,
jqpiping support, tree renderer, flat event array designpython-apex-log-parser - Subscriber/ISV log parsing, query ownership hierarchy for namespace attribution
Authentication & Log Capture
felisbinofarms/salesforce-debug-log-analyzer - OAuth PKCE flow implementation, trace flag management, N+1 query detection, Material Design patterns
Visualization & Patterns
SFDC-Log - Git-graph style visualization concepts, trigger pattern detection methodologies
ML & Anomaly Detection (Future Roadmap)
salesforce/logai - ML anomaly detection concepts (Isolation Forest, LSTM), Drain log parser, OpenTelemetry compatibility patterns
Official Salesforce Tools
Salesforce Apex Replay Debugger - Debug context concepts, step-through execution patterns
Troubleshooting
Common Issues
Issue | Solution |
| Ensure you have build tools installed: |
Auth fails in remote environment | Use Device Code flow or SFDX import instead of PKCE |
Logs not captured | Verify trace flags are set on correct user (including "Automated Process" for async jobs) |
MCP server not connecting | 1. Verify |
Module not found error | Check that the path in mcp.json matches your actual project location and includes |
Async Job Logging Note
When debugging async jobs (Batch, Queueable, Future), ensure trace flags are set on both:
The user triggering the action
The "Automated Process" user (for system-context async execution)
License
MIT License - see LICENSE file for details.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Free MCP debugging tools for AI agents and developers. Diagnose failed API and MCP tool calls, identify HTTP errors, validate tool arguments against supported JSON Schema rules, and get actionable troubleshooting recommendations.
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
Scan prompts for injection attacks, redact PII, and audit LLM SDK usage from any MCP client
Live browser debugging for AI assistants β DOM, console, network via MCP.
Related MCP Servers
- FlicenseBqualityCmaintenanceEnables AI-assisted analysis of log files through advanced searching, filtering, and test execution capabilities. Supports time-based queries, pattern matching, test summarization, and code coverage reporting directly within compatible MCP clients.12-

Apex Log MCP Serverofficial
AlicenseAqualityBmaintenanceAn MCP server that gives AI assistants tools to analyze Salesforce Apex debug logs for performance bottlenecks, slow methods, and governor limit usage.8215 npm36BSD 3-Clause- AlicenseAqualityDmaintenanceEnables analyzing Salesforce deployment logs, validating metadata manifests, assessing permission risks, and generating remediation plans through deterministic, local-only rules.4MIT
- AlicenseNot gradedqualityBmaintenanceProvides local, read-only Salesforce debug log analysis via MCP, including listing, searching, summarizing, analyzing, comparing logs, generating reproduction checklists, and exporting incident bundles.MIT