MCP server cannot access resources:
Error: Permission denied: /path/to/file
Here is how to fix it.
Fix 1: Check file permissions
# Check permissions
ls -la /path/to/file
# Fix ownership
sudo chown -R $USER:$USER /path/to/file
# Fix permissions
chmod 644 /path/to/file
chmod 755 /path/to/directory
Fix 2: Set working directory
MCP server may be running from wrong directory:
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["./server.js"],
"cwd": "/path/to/project"
}
}
}
Fix 3: Pass API keys correctly
{
"mcpServers": {
"github": {
"command": "node",
"args": ["./github-server.js"],
"env": {
"GITHUB_TOKEN": "ghp_..."
}
}
}
}
Fix 4: Fix Docker permissions
services:
mcp-server:
image: node:20
volumes:
- ./data:/app/data
user: "1000:1000" # Match host user
Fix 5: Check SELinux (Linux)
# Check SELinux status
getenforce
# Temporarily disable
sudo setenforce 0
# Or add context
sudo chcon -t home_repo_t /path/to/data -R
Fix 6: Use environment variables
Pass sensitive data via env vars, not files:
// Instead of reading from file
const token = process.env.GITHUB_TOKEN;
// Not
const token = fs.readFileSync('.env');
Still not working?
- Check server logs β See exact permission error
- Run as root temporarily β Test if it is a permission issue
- Check Docker logs β
docker logs mcp-server - Verify paths β Absolute vs relative paths
FAQ
Why does my MCP server get permission denied?
The most common cause is file ownership or permissions. The MCP server process needs read/write access to the files it operates on. Check ownership with ls -la and fix with chown or chmod.
Can I run MCP server as root?
You can, but it is not recommended. Running as root can create security issues and permission problems for files created by the server. Fix the underlying permission issue instead.
How do I fix permissions in Docker?
Use user: "1000:1000" in your Docker Compose file to match your host user ID. This ensures the container process has the same permissions as your local user.
Related: MCP Complete Developer Guide Β· MCP Server Connection Refused Fix Β· Claude Code Permission Denied Fix Β· What is MCP?