这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ElanHasson
Copy link
Contributor

Summary

Fixes Docker container failing when MCP clients change the working directory.

Problem

When Claude or Cursor uses the Docker image with -w ${PWD} to change the working directory, the container fails with:

Could not execute because the specified command or file was not found.
dotnet-InfinityFlow.CSharp.Eval.dll does not exist

Solution

Use absolute path /app/InfinityFlow.CSharp.Eval.dll in the ENTRYPOINT so the application can be found regardless of working directory changes.

Testing

# Build and test locally
docker build -t test-mcp .
docker run --rm -w /tmp test-mcp  # Should work now

Impact

This is a critical fix for Docker-based MCP usage with Claude Desktop and Cursor.

🤖 Generated with Claude Code

The Docker image was failing when Claude/Cursor changed the working directory
with -w flag. Using absolute path /app/InfinityFlow.CSharp.Eval.dll ensures
the application can be found regardless of working directory.

Fixes the "dotnet-InfinityFlow.CSharp.Eval.dll does not exist" error
when using the Docker image with MCP clients.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ElanHasson ElanHasson merged commit 4effb2f into main Aug 21, 2025
7 checks passed
@ElanHasson ElanHasson deleted the feat/nuget-docker-support-clean branch August 21, 2025 07:16
@claude
Copy link

claude bot commented Aug 21, 2025

Claude finished @ElanHasson's task —— View job


✅ PR Review Complete

Excellent fix! This PR addresses a critical Docker compatibility issue with MCP clients. Here's my comprehensive review:

Todo List:

  • Read and analyze the Dockerfile changes
  • Examine codebase structure and context
  • Understand the MCP application functionality
  • Evaluate the fix for correctness and best practices
  • Check security implications
  • Look for related tests or test opportunities
  • Provide comprehensive review feedback

🎯 Problem & Solution

Problem Identified: The Docker image failed when MCP clients (Claude/Cursor) changed the working directory using -w ${PWD}. The relative ENTRYPOINT path couldn't locate the application DLL.

Solution Applied: Changed ENTRYPOINT from relative to absolute path:

# Before (inferred from error description)
ENTRYPOINT ["dotnet", "InfinityFlow.CSharp.Eval.dll"]

# After (line 54)
ENTRYPOINT ["dotnet", "/app/InfinityFlow.CSharp.Eval.dll"]

Code Quality Assessment

Excellent:

  • Correct Fix: Using absolute paths in ENTRYPOINT is the standard Docker best practice
  • Root Cause: Properly addresses the core issue rather than working around it
  • Minimal Change: Single line change with maximum impact - ideal surgical fix
  • Documentation: Clear commit message and PR description explaining the issue

Best Practices Adherence:

  • Docker Standards: Absolute paths in ENTRYPOINT prevent working directory dependencies
  • Consistency: The published location /app/publish matches the absolute reference /app/
  • Container Design: Follows the principle that containers should work regardless of runtime working directory

🔒 Security Analysis

No Security Concerns:

  • Path Safety: Uses absolute path within the controlled container environment
  • No Vulnerabilities: Change doesn't introduce any new attack vectors
  • Principle of Least Surprise: Container behavior is now more predictable

🚀 Performance & Compatibility

Performance:

  • Zero Overhead: Absolute vs relative path resolution has negligible performance difference
  • Startup Time: No impact on container startup time

Compatibility:

  • Backward Compatible: Existing deployments without -w flag continue to work
  • Forward Compatible: Now supports MCP clients that modify working directory
  • Multi-Platform: Fix works across all supported Docker platforms (linux/amd64, linux/arm64)

🧪 Test Coverage Analysis

Current Testing:

  • Comprehensive Unit Tests: CSharpEvalToolsTests.cs has excellent coverage of the C# evaluation functionality
  • Docker Build Tests: CI pipeline validates Docker image builds successfully
  • Manual Testing: PR includes manual testing instructions

Suggestions for Future Enhancements:

  • 💡 Integration Tests: Consider adding a test that verifies the Docker container works with -w flag:
    # Test case for CI pipeline
    docker run --rm -w /tmp ghcr.io/infinityflowapp/csharp-mcp:latest --help
  • 💡 MCP Client Tests: Could add tests that simulate actual MCP client usage patterns

🎯 Context Understanding

This C# MCP server provides:

  • C# Script Execution: Via Roslyn scripting engine (CSharpEvalTools.cs:20-257)
  • NuGet Package Support: Dynamic package resolution
  • File & Direct Code Support: Flexible execution modes
  • Docker Integration: Primary deployment method for MCP clients

The .mcp.json configuration (lines 13-14) shows exactly how MCP clients use -w ${PWD}, making this fix essential for production usage.

📊 Impact Assessment

Critical Fix:

  • 🔥 High Impact: Enables Docker-based usage with Claude Desktop and Cursor
  • 🔥 Zero Risk: Minimal change with no breaking potential
  • 🔥 Production Ready: Addresses a deployment blocker

🏆 Overall Assessment

Rating: ⭐⭐⭐⭐⭐ (Excellent)

This is a textbook perfect fix:

  1. Identifies the exact root cause (working directory sensitivity)
  2. Applies the minimal necessary change (one line)
  3. Follows Docker best practices (absolute paths in ENTRYPOINT)
  4. Thoroughly documented (clear commit message, testing instructions)
  5. Zero side effects (backward compatible)

🚀 Recommendations

  1. Merge Immediately: This is ready for production
  2. Consider Backporting: If there are release branches, consider applying this fix
  3. Update Documentation: Consider adding the working directory flexibility to user documentation

No changes needed - this PR demonstrates excellent engineering practices! 🎉


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants