Troubleshooting¶
Common issues and solutions for the LinkDing MCP Server.
Quick Diagnostics¶
Health Check Script¶
Create a simple diagnostic script to test your setup:
#!/usr/bin/env python3
"""
LinkDing MCP Server Health Check
"""
import os
import httpx
from dotenv import load_dotenv
def main():
print("🔍 LinkDing MCP Server Health Check")
print("=" * 40)
# Load environment
load_dotenv()
# Check environment variables
print("\n1. Environment Variables:")
linkding_url = os.getenv("LINKDING_URL")
linkding_token = os.getenv("LINKDING_API_TOKEN")
debug = os.getenv("DEBUG", "false")
print(f" LINKDING_URL: {'✅' if linkding_url else '❌'} {linkding_url or 'Not set'}")
print(f" LINKDING_API_TOKEN: {'✅' if linkding_token else '❌'} {'Set' if linkding_token else 'Not set'}")
print(f" DEBUG: {debug}")
if not linkding_url or not linkding_token:
print("\n❌ Missing required environment variables")
return False
# Test LinkDing connectivity
print("\n2. LinkDing Connectivity:")
try:
response = httpx.get(f"{linkding_url.rstrip('/')}/api/bookmarks/",
headers={"Authorization": f"Token {linkding_token}"},
params={"limit": 1},
timeout=10.0)
if response.status_code == 200:
print(" ✅ Successfully connected to LinkDing")
data = response.json()
print(f" 📊 Total bookmarks: {data.get('count', 'Unknown')}")
return True
else:
print(f" ❌ HTTP {response.status_code}: {response.text}")
return False
except httpx.ConnectError:
print(f" ❌ Cannot connect to {linkding_url}")
print(" 💡 Check if LinkDing is running and URL is correct")
return False
except httpx.TimeoutException:
print(" ❌ Connection timeout")
print(" 💡 LinkDing may be slow to respond")
return False
except Exception as e:
print(f" ❌ Error: {e}")
return False
if __name__ == "__main__":
success = main()
exit(0 if success else 1)
Save as health_check.py and run:
Common Issues¶
1. Environment Variable Issues¶
"LINKDING_API_TOKEN environment variable is required"¶
Cause: Missing or empty API token
Solutions:
-
Check .env file exists:
-
Verify .env content:
-
Create .env from sample:
-
Check environment loading:
Environment Variables Not Loading¶
Cause: .env file not in correct location or not loaded
Solutions:
-
Verify file location:
-
Check file permissions:
-
Load explicitly:
2. Connection Issues¶
"Connection refused" or "Cannot connect"¶
Cause: LinkDing instance not running or URL incorrect
Solutions:
-
Verify LinkDing is running:
-
Test URL directly:
-
Check port and host:
-
Test API endpoint:
"HTTP 401: Unauthorized"¶
Cause: Invalid or expired API token
Solutions:
- Generate new token:
- Open LinkDing web interface
- Go to Settings → API
- Copy the API token
-
Update .env file
-
Verify token format:
-
Test token manually:
"HTTP 404: Not Found"¶
Cause: Incorrect API endpoint or LinkDing version mismatch
Solutions:
-
Check LinkDing version:
-
Verify API endpoints:
-
Check URL format:
3. Python and Dependency Issues¶
"Module not found" errors¶
Cause: Missing dependencies
Solutions:
-
Install requirements:
-
Check Python version:
-
Use virtual environment:
-
Verify installation:
"Permission denied" errors¶
Cause: Script not executable or permission issues
Solutions:
-
Make script executable:
-
Check file ownership:
-
Run with python explicitly:
4. MCP Client Integration Issues¶
Claude Desktop: "No MCP servers found"¶
Cause: Configuration file issues
Solutions:
-
Check config file location:
-
Validate JSON syntax:
-
Use absolute paths:
-
Check Python path:
"Server failed to start"¶
Cause: Incorrect paths or environment issues
Solutions:
-
Test command manually:
-
Check environment variables in config:
-
Use virtual environment path:
5. Performance Issues¶
Slow response times¶
Cause: Network latency or large datasets
Solutions:
-
Use smaller limits:
-
Enable connection pooling:
-
Check LinkDing performance:
Memory usage issues¶
Cause: Large result sets or memory leaks
Solutions:
-
Use pagination:
-
Monitor memory:
6. Data Issues¶
"Bookmark not found" errors¶
Cause: Bookmark ID doesn't exist or was deleted
Solutions:
-
Verify bookmark exists:
-
Handle missing bookmarks:
Duplicate bookmarks¶
Cause: Not checking for existing URLs
Solutions:
-
Always check before adding:
-
Find duplicates:
Debug Mode¶
Enable Debug Logging¶
-
Set environment variable:
-
Or in .env file:
-
Run server:
Debug Output¶
With debug mode enabled, you'll see:
2024-01-15 10:30:00 - linkding_server - DEBUG - Making request: GET http://127.0.0.1:9090/api/bookmarks/
2024-01-15 10:30:00 - linkding_server - DEBUG - Request params: {'q': 'python', 'limit': 10}
2024-01-15 10:30:00 - linkding_server - DEBUG - Response status: 200
2024-01-15 10:30:00 - linkding_server - DEBUG - Response data: {"count": 25, "results": [...]}
Log Files¶
Debug mode creates log files:
# Check log file
tail -f linkding-mcp.log
# Search for errors
grep -i error linkding-mcp.log
# Search for specific requests
grep "search_bookmarks" linkding-mcp.log
Advanced Troubleshooting¶
Network Analysis¶
-
Monitor HTTP traffic:
-
Check DNS resolution:
-
Test with curl:
Database Issues¶
If LinkDing has database problems:
-
Check LinkDing logs:
-
Database connectivity:
Performance Profiling¶
-
Profile Python code:
-
Monitor system resources:
Getting Help¶
Information to Gather¶
When seeking help, provide:
-
Environment details:
-
Configuration (sanitized):
-
Error messages:
-
Health check results:
Support Channels¶
- GitHub Issues: Report bugs and feature requests
- Documentation: Check this documentation for solutions
- Community: LinkDing and MCP community forums
- Debug Mode: Enable for detailed troubleshooting information
Creating Bug Reports¶
Include in your bug report:
- Steps to reproduce
- Expected behavior
- Actual behavior
- Environment information
- Configuration (sanitized)
- Error logs
- Health check output
Prevention¶
Regular Maintenance¶
-
Update dependencies:
-
Rotate API tokens:
- Generate new token monthly
- Update all configurations
-
Test connectivity
-
Monitor logs:
-
Backup configuration:
Health Monitoring¶
Set up automated health checks:
#!/bin/bash
# health_monitor.sh
if ! python health_check.py; then
echo "LinkDing MCP Server health check failed" | mail -s "Alert" admin@example.com
fi
Add to crontab:
Next Steps¶
- FAQ - Frequently asked questions
- Development Guide - Contribute fixes
- API Reference - Technical details