Skip to content
Back to skills

3058 Enable Payload Logging C75da92d

ASecurity

This guide shows how to enable request payload logging to debug and validate tool registration requests and other API calls.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
securitybashapisecurityperformance

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 3058-enable_payload_logging_c75da92d --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 3058 Enable Payload Logging C75da92d?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 3058 Enable Payload Logging C75da92d
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-3058-enable-payload-logging-c75da92d/badge)](https://www.skillsdirectory.com/skills/tools-only-3058-enable-payload-logging-c75da92d)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Enable Request Payload Logging in ContextForge

This guide shows how to enable request payload logging to debug and validate tool registration requests and other API calls.

## Quick Setup

To enable request payload logging, set these environment variables:

```bash
# Enable request logging
LOG_REQUESTS=true

# Set log level to INFO or DEBUG to see request payloads
LOG_LEVEL=INFO

# Optional: Enable file logging to persist logs
LOG_TO_FILE=true
LOG_FILE=mcpgateway.log
LOG_FOLDER=logs
LOG_FILEMODE=a+
```

## Configuration Options

### Required Settings

- `LOG_REQUESTS=true` - Enables the request logging middleware
- `LOG_LEVEL=INFO` - Ensures request logs are visible (INFO or DEBUG)

### Optional Settings

- `LOG_TO_FILE=true` - Saves logs to file (default: console only)
- `LOG_FILE=mcpgateway.log` - Log file name
- `LOG_FOLDER=logs` - Log folder path
- `LOG_FILEMODE=a+` - File mode (append)
- `LOG_MAX_SIZE_MB=1` - Maximum request body size to log (in MB)

## Example .env Configuration

```env
# Request Logging
LOG_REQUESTS=true
LOG_LEVEL=INFO

# File Logging (optional)
LOG_TO_FILE=true
LOG_FILE=mcpgateway.log
LOG_FOLDER=logs
LOG_FILEMODE=a+
LOG_MAX_SIZE_MB=4

# Other settings
MCPGATEWAY_UI_ENABLED=true
MCPGATEWAY_ADMIN_API_ENABLED=true
PLATFORM_ADMIN_EMAIL=admin@example.com
PLATFORM_ADMIN_PASSWORD=changeme
PLATFORM_ADMIN_FULL_NAME="Platform Administrator"
```

## What Gets Logged

When enabled, you'll see detailed request information including:

- HTTP method and path
- Query parameters
- Request headers (with sensitive data masked)
- Request body/payload (with sensitive fields masked)
- Truncation notice if body exceeds size limit

### Example Log Output

```
📩 Incoming request: POST /tools
Query params: {}
Headers: {'host': 'localhost:4444', 'content-type': 'application/json', 'authorization': '******'}
Body: {
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "get_system_time",
    "arguments": {
      "timezone": "Europe/Dublin"
    }
  },
  "id": 1758624387514
}
```

## Security Features

The logging middleware automatically masks sensitive information:

- **Headers**: Authorization, authentication tokens
- **Body fields**: password, secret, token, apikey, access_token, refresh_token, client_secret
- **Large payloads**: Truncated with notice if they exceed the size limit

## Troubleshooting

### No Request Logs Appearing

1. Check that `LOG_REQUESTS=true` is set
2. Verify `LOG_LEVEL` is set to `INFO` or `DEBUG`
3. Restart the gateway after changing configuration

### Logs Not Saved to File

1. Ensure `LOG_TO_FILE=true` is set
2. Check that the log folder exists and is writable
3. Verify `LOG_FILE` and `LOG_FOLDER` paths are correct

### Request Bodies Truncated

- Increase `LOG_MAX_SIZE_MB` if you need to see larger payloads
- Default is 1MB to prevent log files from becoming too large

## Performance Considerations

- Request logging adds minimal overhead
- Large request bodies are automatically truncated
- Sensitive data is masked, not removed, so original functionality is preserved
- Logging is skipped entirely if `LOG_REQUESTS=false`

## Example Usage

1. Set environment variables:
   ```bash
   export LOG_REQUESTS=true
   export LOG_LEVEL=INFO
   export LOG_TO_FILE=true
   export LOG_FOLDER=logs
   ```

2. Start the gateway:
   ```bash
   mcpgateway --host 0.0.0.0 --port 4444
   ```

3. Make a request and check the logs:
   ```bash
   # Check console output or log file
   tail -f logs/mcpgateway.log
   ```

Now you can see the full request payloads (with sensitive data masked) to debug tool registration and other API issues.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.