Repository navigation
feat: enhance go:// protocol to support local paths - #487
Merged
Merged
Conversation
JAORMX
force-pushed
the
feature/go-protocol-local-paths
branch
2 times, most recently
from
May 28, 2025 12:26
35126d3 to
a582093
Compare
amirejaz
reviewed
May 28, 2025
JAORMX
force-pushed
the
feature/go-protocol-local-paths
branch
from
May 28, 2025 13:23
b04844a to
796a719
Compare
- Add local path detection for go:// protocol (./path, ../path, /, .) - Implement source code copying for local Go projects - Update Go template to conditionally copy local source files - Add IsLocalPath field to TemplateData struct - Enhance image name generation for local paths - Add comprehensive unit tests (295 lines) covering: - Local path detection logic - File copying with smart skip logic - Image name generation - Protocol scheme parsing - Template data creation - Update documentation with local path usage examples - Refactor HandleProtocolScheme to reduce cyclomatic complexity - Fix all linting issues and maintain code quality standards This allows users to run local Go MCP servers with commands like: - thv run go://./cmd/server - thv run go://. - thv run go:///absolute/path Maintains backward compatibility with existing remote package usage. Signed-off-by: Juan Antonio Osorio <[email protected]>
- Add filepath.Match support for wildcard patterns like *.tmp and *.log - Remove .dockerignore from skip list to respect Docker build context rules - Add comprehensive test cases for wildcard pattern matching - Maintain backward compatibility with exact and prefix matching Addresses PR feedback about wildcard handling in file skip logic.
- Use local directory directly as Docker build context instead of copying files - Remove complex file copying and skip logic in favor of Docker's native .dockerignore - Check for existing Dockerfile and avoid overwriting it - Add marker comments to identify generated Dockerfiles for cleanup - Refactor buildImageFromTemplate into smaller, focused functions: - setupBuildContext: handles local vs temp directory setup - writeDockerfile: writes Dockerfile with existence checks - writeCACertificate: handles CA certificate files - generateImageName: creates unique image names - Remove unused functions: copyLocalSource, shouldSkipPath, copyFile - Update tests to remove tests for deleted functionality - Fix all linting issues This approach is cleaner, more reliable, and leverages Docker's built-in .dockerignore functionality for file filtering.
JAORMX
force-pushed
the
feature/go-protocol-local-paths
branch
from
May 28, 2025 15:01
6895778 to
d49ba75
Compare
amirejaz
approved these changes
May 28, 2025
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the
go://protocol to detect and handle local paths, allowing users to easily containerize and run local Go MCP servers with a simplified, Docker-native approach.Key Features
🎯 Local Path Detection
./,../,/, or just..dockerignorefiles for intelligent file filtering🐳 Docker-Native Approach
🔧 Enhanced Image Naming
Implementation Details
Refactored Architecture
The implementation has been refactored into focused, maintainable functions:
setupBuildContext()- handles local vs temp directory setupwriteDockerfile()- writes Dockerfile with existence checkswriteCACertificate()- handles CA certificate filesgenerateImageName()- creates unique image namesUsage Examples
Benefits
✅ Simpler & More Reliable: No complex file copying or filtering logic
✅ Respects User Intent: Uses existing
.dockerignorefiles and doesn't overwrite Dockerfiles✅ Better Performance: No file copying overhead for local builds
✅ Docker Native: Leverages Docker's built-in capabilities
✅ Cleaner Code: Smaller, focused functions that are easier to test and maintain
Backward Compatibility
✅ Maintains full backward compatibility with existing
go://usage for remote packagesTesting & Quality
Files Modified
pkg/runner/protocol.go- Core implementation with simplified architecturepkg/runner/protocol_test.go- Updated test suitepkg/container/templates/templates.go- Added IsLocalPath fieldpkg/container/templates/go.tmpl- Conditional source copying for local pathsREADME.md- Updated documentation with local path examplescmd/thv/app/run.go- Updated help textThis approach is cleaner, more reliable, and leverages Docker's native
.dockerignorefunctionality for file filtering while maintaining the same user experience.