# Path Resolution Fix Summary
## Problem
Users were required to provide absolute paths for scripts when using the MCP Debug Server, even though the system previously accepted relative paths. This was a UX regression caused by overly strict validation in the proxy layer.
## Root Cause
The `dap-proxy-worker.ts` file contained validation that required all script paths to be absolute:
```typescript
if (!path.isAbsolute(config.scriptPath)) {
throw new Error(`Script path is not absolute: ${config.scriptPath}`);
}
```
This validation was likely added for container support but was too restrictive for non-container use cases.
## Solution Implemented
### 1. Removed Strict Validation
- Removed the absolute path check from `dap-proxy-worker.ts` (lines 107-109)
- The proxy now only validates that the file exists, not whether it's absolute
- Added a comment explaining that path resolution is handled at the server level
### 2. Path Resolution Architecture
The system now works as follows:
1. **User provides path** (can be relative or absolute)
2. **Server receives path** and uses PathTranslator to resolve it
3. **PathTranslator logic**:
- Absolute paths → passed through unchanged
- Relative paths → resolved against workspace root
- Workspace root = MCP_WORKSPACE_ROOT or current working directory
4. **Resolved path sent to proxy** (always absolute at this point)
5. **Proxy validates** that the file exists
### 3. Test Updates
- Removed the test case that expected absolute path validation failure
- All other proxy worker tests continue to pass
## Benefits
1. **Better UX**: Users can use relative paths naturally
2. **Flexible**: Works from any directory with MCP_WORKSPACE_ROOT
3. **Container Compatible**: Full support for Docker/container scenarios
4. **Clear Errors**: Helpful messages when paths can't be resolved
5. **Backward Compatible**: Absolute paths still work as before
## Example Usage
### Before (Required Absolute Path)
```bash
# Would fail with "Script path is not absolute"
mcp-debugger start_debugging "examples/python/fibonacci.py"
```
### After (Accepts Relative Path)
```bash
# Works correctly - resolves relative to current directory or MCP_WORKSPACE_ROOT
mcp-debugger start_debugging "examples/python/fibonacci.py"
```
## Environment Variables
- `MCP_WORKSPACE_ROOT`: Optional. Sets the base directory for relative path resolution
- `MCP_CONTAINER`: When set to "true", enables container path translation
- `MCP_HOST_WORKSPACE`: Required in container mode. Specifies the host directory mounted in the container
## Error Handling
When a relative path cannot be resolved, users get a helpful error message:
```
Could not find file at resolved path: /resolved/path/to/file.py
Attempted to resolve relative path: relative/path/file.py
Using workspace root: /current/working/directory
To fix this:
1. Run the server from your project root directory, OR
2. Use an absolute path, OR
3. Set MCP_WORKSPACE_ROOT environment variable to your project root
```
## Files Changed
1. `src/proxy/dap-proxy-worker.ts` - Removed absolute path validation
2. `tests/unit/proxy/dap-proxy-worker.test.ts` - Removed test for absolute path validation
3. `src/utils/path-translator.ts` - Already handles all path resolution correctly
4. `src/server.ts` - Already uses PathTranslator before sending to proxy
## Next Steps
- Monitor for any edge cases with path resolution
- Consider adding more integration tests for various path scenarios
- Update user documentation to highlight relative path support