Skip to main content
Python Server is a work in progress.
Logging

mcp-use provides clean, informative logging about MCP operations, making it easy to understand server activity and debug issues in both production and development.
MCP-specific logging provides detailed information about which MCP methods are being called, including the specific method name, session IDs, and execution details.

Why Use MCP-Specific Logging?

This type of logging is essential because:
  • Clear visibility into which MCP methods are being called
  • Easy debugging of MCP protocol interactions
  • Request tracking with session IDs and method names
  • Production monitoring of server usage patterns
  • Error tracking for tools, resources, and prompts
  • Performance insights with execution timing

Log Levels

mcp-use provides three logging modes controlled by the debug parameter and DEBUG environment variable:

Production Logs (Default: debug=False)

Clean, readable logs showing MCP method calls:
INFO: 127.0.0.1:58478 - "POST /mcp [tools/call:search] HTTP/1.1" 200 OK
INFO: 127.0.0.1:58478 - "POST /mcp [resources/list] HTTP/1.1" 200 OK
ERROR: 127.0.0.1:58478 - "POST /mcp [tools/call:search] HTTP/1.1" 200 OK

Debug Logs (debug=True)

Same logs as production + development routes (inspector, docs):
INFO: 127.0.0.1:58478 - "POST /mcp [tools/call:search] HTTP/1.1" 200 OK
INFO: 127.0.0.1:58478 - "GET  /inspector HTTP/1.1" 302
INFO: 127.0.0.1:58478 - "GET  /docs HTTP/1.1" 200

Full Debug Logs (DEBUG=2 environment variable)

Same logs as debug mode + JSON-RPC request/response logging:
INFO: 127.0.0.1:58478 - "POST /mcp [tools/call:search] HTTP/1.1" 200 OK
DEBUG: JSON-RPC Request: {"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "search", "arguments": {"query": "test"}}}
DEBUG: JSON-RPC Response: {"jsonrpc": "2.0", "id": 1, "result": {"content": [...]}}
DEBUG: Duration: 45.2ms

Understanding the Log Format

Each log line contains detailed information about the request:
INFO: 127.0.0.1:58478 - "POST /mcp [b98ed3729a6443e4875d3f0db151881e] [tools/call:search] HTTP/1.1" 200 OK
Breaking down each component:
1

Log Level

INFO: - The severity level of the log message
2

Client Address

127.0.0.1:58478 - The IP address and port of the client making the request
3

HTTP Method

POST - The HTTP method used for the request
4

Endpoint

/mcp - The MCP server endpoint path
5

Session ID

[b98ed3729a6443e4875d3f0db151881e] - Unique session identifier for tracking related requests
6

MCP Method

[tools/call:search] - The specific MCP method being called (e.g., tools/call, resources/list, etc.)
7

HTTP Version

HTTP/1.1 - The HTTP protocol version
8

Status Code

200 OK - The HTTP response status code

Common MCP Methods

The logs clearly show which MCP methods are being called, such as:
  • [initialize] - Server initialization
  • [tools/list] - Listing available tools
  • [tools/call:search] - Calling a specific tool
  • [resources/list] - Listing available resources
  • [resources/read:config] - Reading a specific resource
  • [prompts/get:assistant] - Getting a specific prompt

Configuration

Logging is automatically configured based on the DEBUG environment variable:
# Production logging (default)
python server.py

# Debug mode with development routes (inspector, docs)
DEBUG=1 python server.py

# Full debug mode with JSON-RPC request/response logging
DEBUG=2 python server.py
Or programmatically:
# Production logging (default)
server = MCPServer("my-server")
server.run(transport="streamable-http")

# Debug mode with dev routes
server = MCPServer("my-server", debug=True)
server.run(transport="streamable-http")

# Debug mode with custom paths
server = MCPServer(
    name="my-server",
    debug=True,
    mcp_path="/api/mcp",  # Custom MCP endpoint
    docs_path="/custom-docs",
    inspector_path="/custom-inspector"
)
server.run(transport="streamable-http")

Customization

You can customize the logging behavior by modifying the logging configuration:
from mcp_use.server.logging import get_logging_config

# Get custom logging config
config = get_logging_config(debug=True)
# Modify config as needed
server.run(transport="streamable-http", log_config=config)
This makes it much easier to understand what’s happening with your MCP server and debug any issues in both production and development environments.

Next Steps