DEBUG_LOGGING.mdā¢1.9 kB
# Debug Logging Configuration
The MCP Salesforce TypeScript server now supports configurable debug logging to prevent console output from interfering with the MCP protocol communication.
## How It Works
- **Normal Mode**: No informational logs are output, keeping stdout clean for MCP protocol messages
- **Debug Mode**: Detailed logging is sent to stderr when debug mode is enabled
## Enabling Debug Mode
Set one of these environment variables:
```bash
# Option 1: Set DEBUG flag
export DEBUG=true
# Option 2: Set development environment
export NODE_ENV=development
```
## Debug Output Examples
When debug mode is enabled, you'll see logs like:
```
š Starting MCP Salesforce TypeScript Server...
š§ Configuration Status:
Client ID: ā
Set
Client Secret: ā
Set
Username: ā
Set
Password: ā
Set
Security Token: ā
Set
Access Token: ā Missing
Instance URL: ā Missing
Sandbox: ā
Enabled
š Using username/password authentication with OAuth flow...
š Authenticating with Salesforce using password flow...
ā
Authentication successful!
Instance URL: https://your-org.salesforce.com
ā
Salesforce connection established on startup
ā
MCP Salesforce server is running and ready for connections
```
## Running with Debug Mode
```bash
# Start with debug logging
DEBUG=true npm start
# Or use development mode
NODE_ENV=development npm start
```
## Why This Matters
The Model Context Protocol (MCP) uses stdout for protocol communication. Any console.log output to stdout can interfere with the JSON-RPC messages between the MCP client and server, causing parsing errors like:
```
Failed to parse message: "š Starting MCP Salesforce TypeScript Server...\n"
```
By routing debug logs to stderr and making them optional, the server maintains clean protocol communication while still providing useful debugging information when needed.