Logging MCP-Use
MCP-Use provides built-in logging functionality that helps diagnose issues in your agent implementation.
Enabling Debug Mode
Choose the debug method that best fits your workflow - environment variables for one-off debugging or programmatic control for conditional debugging.
1. Environment Variable (Recommended for One-off Runs)
Run your script with the
DEBUG
environment variable:This sets the debug level only for that specific Python process - perfect for quick troubleshooting.
2. Setting the Debug Flag Programmatically
Programmatic control is useful for debugging specific parts of your application or conditionally enabling debug mode based on your application state.
You can conditionally enable debugging based on environment or configuration:
Debug Levels
Level 0 - Normal
Minimal OutputOnly WARNING and above messages are shown
set_debug(0)
Level 1 - Info
Default OperationShows INFO level messages and tool calls - useful for basic operational information
DEBUG=1
or set_debug(1)
(default)Level 2 - Full Debug
Maximum VerbosityShows all detailed debugging information including internal operations
DEBUG=2
or set_debug(2)
Agent-Specific Verbosity
If you only want to increase verbosity for the agent component without enabling full debug mode for the entire package, you can use theverbose
parameter when creating an MCPAgent:
Debug Information
When debug mode is enabled, you’ll see more detailed information about:- Server initialization and connection details
- Tool registration and resolution
- Agent steps and decision-making
- Request and response formats
- Communication with MCP servers
- Error details and stack traces