Problem: "Unexpected token 'C'" JSON Errors
When using dotnet run, the .NET CLI outputs build information and file paths to stdout, which interferes with the MCP JSON-RPC protocol that requires clean JSON communication.
Solution
Use the compiled executable directly instead of dotnet run.
Configuration Steps
- Build the project in Release mode (recommended for production):
- Update your Claude Desktop config at:
- Windows:
APPDATA%\Claude\claude_desktop_config.json
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Use this configuration:
{
"mcpServers": {
"Sage50ES-server": {
"command": "C:\\dev\\GitHub\\Sage.ES.S50.MCP\\Sage.ES.S50.MCP\\bin\\Release\\net8.0\\Sage.ES.S50.MCP.exe",
"args": []
}
}
}
For Debug builds, use:
{
"mcpServers": {
"Sage50ES-server": {
"command": "C:\\dev\\GitHub\\Sage.ES.S50.MCP\\Sage.ES.S50.MCP\\bin\\Debug\\net8.0\\Sage.ES.S50.MCP.exe",
"args": []
}
}
}
- Restart Claude Desktop completely to apply changes.
Why This Works
- Direct execution: No build output from
dotnet run
- Console redirection: The Program.cs now redirects all console output to null
- Silent logging: All diagnostic information goes to file logs in the
Logs folder
- Clean JSON-RPC: Only valid JSON messages are written to stdout
Debugging
If you still see errors, check the logs in:
C:\dev\GitHub\Sage.ES.S50.MCP\Sage.ES.S50.MCP\bin\Debug\net8.0\Logs\erp-server-YYYY-MM-DD.log
Available Tools
The MCP server exposes these tools to Claude:
ConsultarClientes - Search and retrieve customer information
ConsultarPedidos - Query orders with filters
ConsultarProductos - Search products and check inventory
CrearPedido - Create new sales orders with header and detail lines
EnviarEmail - Send emails using Gmail SMTP configuration
GetSalesSummary - Generate sales statistics
Connection String
Make sure appsettings.json has the correct connection string for your Sage 50 database.
Email Configuration
To use the email functionality, configure SMTP settings in appsettings.json:
{
"SmtpSettings": {
"Host": "smtp.gmail.com",
"Port": 587,
"EnableSsl": true,
"FromEmail": "your-email@gmail.com",
"Username": "your-email@gmail.com",
"Password": "your-gmail-app-password"
}
}
Note: For Gmail, use an App Password instead of your regular password. See EnviarEmail.md for detailed setup instructions.