logging docs cleanup
This commit is contained in:
parent
fda329cc8f
commit
921e087351
@ -29,15 +29,6 @@ These settings control how the server locates KiCad:
|
|||||||
|---------------------|-------------|---------------|---------|
|
|---------------------|-------------|---------------|---------|
|
||||||
| `KICAD_APP_PATH` | Path to the KiCad application | `/Applications/KiCad/KiCad.app` (macOS)<br>`C:\Program Files\KiCad` (Windows)<br>`/usr/share/kicad` (Linux) | `/Applications/KiCad7/KiCad.app` |
|
| `KICAD_APP_PATH` | Path to the KiCad application | `/Applications/KiCad/KiCad.app` (macOS)<br>`C:\Program Files\KiCad` (Windows)<br>`/usr/share/kicad` (Linux) | `/Applications/KiCad7/KiCad.app` |
|
||||||
|
|
||||||
### Logging Configuration
|
|
||||||
|
|
||||||
These settings control server logging behavior:
|
|
||||||
|
|
||||||
| Environment Variable | Description | Default Value | Example |
|
|
||||||
|---------------------|-------------|---------------|---------|
|
|
||||||
| `LOG_LEVEL` | Sets logging verbosity | `INFO` | `DEBUG`, `INFO`, `WARNING`, `ERROR` |
|
|
||||||
| `LOG_DIR` | Directory for log files | `logs` | `~/.kicad_mcp/logs` |
|
|
||||||
|
|
||||||
## Using a .env File (Recommended)
|
## Using a .env File (Recommended)
|
||||||
|
|
||||||
The recommended way to configure the server is by creating a `.env` file in the project root:
|
The recommended way to configure the server is by creating a `.env` file in the project root:
|
||||||
@ -69,10 +60,6 @@ The recommended way to configure the server is by creating a `.env` file in the
|
|||||||
# KICAD_APP_PATH=C:\Program Files\KiCad
|
# KICAD_APP_PATH=C:\Program Files\KiCad
|
||||||
# Linux:
|
# Linux:
|
||||||
# KICAD_APP_PATH=/usr/share/kicad
|
# KICAD_APP_PATH=/usr/share/kicad
|
||||||
|
|
||||||
# Logging configuration
|
|
||||||
LOG_LEVEL=INFO
|
|
||||||
LOG_DIR=logs
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Directory Structure and Project Discovery
|
## Directory Structure and Project Discovery
|
||||||
@ -147,7 +134,7 @@ You can also set environment variables directly in the client configuration:
|
|||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"KICAD_SEARCH_PATHS": "/custom/path1,/custom/path2",
|
"KICAD_SEARCH_PATHS": "/custom/path1,/custom/path2",
|
||||||
"LOG_LEVEL": "DEBUG"
|
"KICAD_APP_PATH": "/custom/path"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,19 +209,14 @@ KICAD_APP_PATH=/opt/kicad
|
|||||||
|
|
||||||
If you're having configuration problems:
|
If you're having configuration problems:
|
||||||
|
|
||||||
1. Run the server with debug logging:
|
1. Run the server:
|
||||||
```bash
|
```bash
|
||||||
LOG_LEVEL=DEBUG python main.py
|
python main.py
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Check the logs for configuration-related messages:
|
2. Verify environment variables are being loaded:
|
||||||
```bash
|
|
||||||
cat logs/kicad_mcp_*.log | grep "config"
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Verify environment variables are being loaded:
|
|
||||||
```bash
|
```bash
|
||||||
python -c "import os; print(os.environ.get('KICAD_SEARCH_PATHS', 'Not set'))"
|
python -c "import os; print(os.environ.get('KICAD_SEARCH_PATHS', 'Not set'))"
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Try absolute paths to eliminate path resolution issues
|
3. Try absolute paths to eliminate path resolution issues
|
||||||
|
@ -194,14 +194,6 @@ To diagnose issues, check the server logs:
|
|||||||
%APPDATA%\Claude\Logs\
|
%APPDATA%\Claude\Logs\
|
||||||
```
|
```
|
||||||
|
|
||||||
### Enabling Debug Logging
|
|
||||||
|
|
||||||
For more detailed logs, set the logging level to DEBUG in your `.env` file:
|
|
||||||
|
|
||||||
```
|
|
||||||
LOG_LEVEL=DEBUG
|
|
||||||
```
|
|
||||||
|
|
||||||
## DRC and Export Feature Issues
|
## DRC and Export Feature Issues
|
||||||
|
|
||||||
### DRC Checks Failing
|
### DRC Checks Failing
|
||||||
|
@ -105,25 +105,7 @@ def register_export_tools(mcp: FastMCP) -> None:
|
|||||||
await ctx.report_progress(10, 100)
|
await ctx.report_progress(10, 100)
|
||||||
ctx.info(f"Generating thumbnail for {os.path.basename(pcb_file)}")
|
ctx.info(f"Generating thumbnail for {os.path.basename(pcb_file)}")
|
||||||
|
|
||||||
# Method 1: Try to use pcbnew Python module if available
|
# Try to use command-line tools
|
||||||
if kicad_modules_available:
|
|
||||||
try:
|
|
||||||
thumbnail = await generate_thumbnail_with_pcbnew(pcb_file, ctx)
|
|
||||||
if thumbnail:
|
|
||||||
# Cache the result if possible
|
|
||||||
if hasattr(app_context, 'cache'):
|
|
||||||
app_context.cache[cache_key] = thumbnail
|
|
||||||
return thumbnail
|
|
||||||
|
|
||||||
# If pcbnew method failed, log it but continue to try alternative method
|
|
||||||
print("Failed to generate thumbnail with pcbnew, trying CLI method")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error using pcbnew for thumbnail: {str(e)}", exc_info=True)
|
|
||||||
ctx.info(f"Error with pcbnew method, trying alternative approach")
|
|
||||||
else:
|
|
||||||
print("KiCad Python modules not available, trying CLI method")
|
|
||||||
|
|
||||||
# Method 2: Try to use command-line tools
|
|
||||||
try:
|
try:
|
||||||
thumbnail = await generate_thumbnail_with_cli(pcb_file, ctx)
|
thumbnail = await generate_thumbnail_with_cli(pcb_file, ctx)
|
||||||
if thumbnail:
|
if thumbnail:
|
||||||
@ -135,7 +117,7 @@ def register_export_tools(mcp: FastMCP) -> None:
|
|||||||
print(f"Error using CLI for thumbnail: {str(e)}", exc_info=True)
|
print(f"Error using CLI for thumbnail: {str(e)}", exc_info=True)
|
||||||
ctx.info(f"Error generating thumbnail with CLI method")
|
ctx.info(f"Error generating thumbnail with CLI method")
|
||||||
|
|
||||||
# If all methods fail, inform the user
|
# If it fails, inform the user
|
||||||
ctx.info("Could not generate thumbnail for PCB - all methods failed")
|
ctx.info("Could not generate thumbnail for PCB - all methods failed")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
Environment variable handling for KiCad MCP Server.
|
Environment variable handling for KiCad MCP Server.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import logging
|
from typing import Dict, Optional
|
||||||
from pathlib import Path
|
|
||||||
from typing import Dict, Any, Optional
|
|
||||||
|
|
||||||
def load_dotenv(env_file: str = ".env") -> Dict[str, str]:
|
def load_dotenv(env_file: str = ".env") -> Dict[str, str]:
|
||||||
"""Load environment variables from .env file.
|
"""Load environment variables from .env file.
|
||||||
@ -54,7 +52,7 @@ def load_dotenv(env_file: str = ".env") -> Dict[str, str]:
|
|||||||
env_vars[key] = value
|
env_vars[key] = value
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(f"Error loading .env file: {str(e)}")
|
print(f"Error loading .env file: {str(e)}")
|
||||||
|
|
||||||
return env_vars
|
return env_vars
|
||||||
|
|
||||||
|
2
main.py
2
main.py
@ -17,7 +17,7 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
print("Starting KiCad MCP server")
|
print("Starting KiCad MCP server")
|
||||||
|
|
||||||
# Log search paths from config
|
# Print search paths from config
|
||||||
print(f"Using KiCad user directory: {KICAD_USER_DIR}")
|
print(f"Using KiCad user directory: {KICAD_USER_DIR}")
|
||||||
if ADDITIONAL_SEARCH_PATHS:
|
if ADDITIONAL_SEARCH_PATHS:
|
||||||
print(f"Additional search paths: {', '.join(ADDITIONAL_SEARCH_PATHS)}")
|
print(f"Additional search paths: {', '.join(ADDITIONAL_SEARCH_PATHS)}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user