Easier access to logs at startup

Updated documentation
This commit is contained in:
Fahad
2025-06-15 07:09:44 +04:00
parent 99fab3e83d
commit 318b5c7ae7
4 changed files with 65 additions and 9 deletions

View File

@@ -1,14 +1,30 @@
# Logging
## Quick Start - Follow Logs
The easiest way to monitor logs is to use the `-f` flag when starting the server:
```bash
# Start server and automatically follow MCP logs
./run-server.sh -f
```
This will start the server and immediately begin tailing the MCP server logs.
## Viewing Logs in Docker
To monitor MCP server activity in real-time:
```bash
# View all container logs
docker-compose logs -f
# Follow MCP server logs (recommended)
docker exec zen-mcp-server tail -f -n 500 /tmp/mcp_server.log
# Or use the -f flag when starting the server
./run-server.sh -f
```
**Note**: Due to MCP protocol limitations, container logs don't show tool execution details. Always use the commands above for debugging.
## Log Files
Logs are stored in the container's `/tmp/` directory and rotate daily at midnight, keeping 7 days of history:

View File

@@ -8,6 +8,7 @@ This project includes comprehensive test coverage through unit tests and integra
- Python virtual environment activated: `source venv/bin/activate`
- All dependencies installed: `pip install -r requirements.txt`
- Docker containers running (for simulator tests): `./run-server.sh`
- Use `./run-server.sh -f` to automatically follow logs after starting
### Unit Tests
@@ -37,7 +38,10 @@ Simulator tests replicate real-world Claude CLI interactions with the MCP server
To monitor logs during test execution:
```bash
# Monitor main server logs (includes all tool execution details)
# Start server and automatically follow logs
./run-server.sh -f
# Or manually monitor main server logs (includes all tool execution details)
docker exec zen-mcp-server tail -f -n 500 /tmp/mcp_server.log
# Monitor MCP activity logs (tool calls and completions)

View File

@@ -43,7 +43,11 @@ cat .env
If you need to update your API keys, edit the `.env` file and then run:
```bash
# Restart services
./run-server.sh
# Or restart and follow logs for troubleshooting
./run-server.sh -f
```
This will validate your configuration and restart the services.
@@ -56,13 +60,15 @@ View the container logs for detailed error information:
# Check if containers are running
docker-compose ps
# View all logs
docker-compose logs -f
# View MCP server logs (recommended - shows actual tool execution)
docker exec zen-mcp-server tail -f -n 500 /tmp/mcp_server.log
# View specific service logs
docker-compose logs -f zen-mcp
# Or use the -f flag when starting to automatically follow logs
./run-server.sh -f
```
**Note**: Due to MCP protocol limitations, `docker-compose logs` only shows startup logs, not tool execution logs. Always use the docker exec command above or the `-f` flag for debugging.
See [Logging Documentation](logging.md) for more details on accessing logs.
### 5. Common Issues

View File

@@ -9,6 +9,25 @@ set -euo pipefail
# - Initial setup of the Docker environment
# - Restart services after changing .env configuration
# - Rebuild and restart after code changes
#
# Usage: ./run-server.sh [-f]
# Options:
# -f Follow logs after starting (tail -f the MCP server log)
# Parse command line arguments
FOLLOW_LOGS=false
while getopts "f" opt; do
case $opt in
f)
FOLLOW_LOGS=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Usage: $0 [-f]" >&2
exit 1
;;
esac
done
# Spinner function for long-running operations
show_spinner() {
@@ -386,9 +405,20 @@ fi
echo "🔧 Useful commands:"
echo " Start services: $COMPOSE_CMD up -d"
echo " Stop services: $COMPOSE_CMD down"
echo " View logs: $COMPOSE_CMD logs -f"
echo " View MCP logs: docker exec zen-mcp-server tail -f -n 500 /tmp/mcp_server.log"
echo " Restart services: $COMPOSE_CMD restart"
echo " Service status: $COMPOSE_CMD ps"
echo ""
echo "Happy Clauding!"
# Follow logs if -f flag was specified
if [ "$FOLLOW_LOGS" = true ]; then
echo "📜 Following MCP server logs (press Ctrl+C to stop)..."
echo ""
# Give the container a moment to fully start
sleep 2
docker exec zen-mcp-server tail -f -n 500 /tmp/mcp_server.log
else
echo "💡 Tip: Use './run-server.sh -f' next time to automatically follow logs after startup"
echo ""
echo "Happy Clauding!"
fi