fix: Bound resource usage and make git transports in MCP server safer#69
Open
fix: Bound resource usage and make git transports in MCP server safer#69
Conversation
…ty-issues # Conflicts: # uv.lock
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
stephantul
approved these changes
May 5, 2026
| cmd = ["git", "clone", "--depth", "1", *(["--branch", ref] if ref else []), "--", url, tmp_dir] | ||
| try: | ||
| result = subprocess.run(cmd, capture_output=True, text=True, stdin=subprocess.DEVNULL) | ||
| result = subprocess.run(cmd, capture_output=True, text=True, stdin=subprocess.DEVNULL, timeout=60) |
Contributor
There was a problem hiding this comment.
maybe consider making this a constant, that makes clear this is in seconds.
Contributor
There was a problem hiding this comment.
Maybe also make this configurable using a flag? It could prevent users with very big repositories from using semble.
| """Initialise an empty cache with a shared embedding model.""" | ||
| self._model = model | ||
| self._tasks: dict[str, asyncio.Task[SembleIndex]] = {} | ||
| self._tasks: OrderedDict[str, asyncio.Task[SembleIndex]] = OrderedDict() |
Contributor
There was a problem hiding this comment.
This is an unrelated change right? I don't think the old version was actually different, or do you rely on ordering?
| source = repo or default_source | ||
| if not source: | ||
| raise ValueError( | ||
| "No repo specified and no default index. Pass an https:// git URL or local directory path as `repo`." |
Contributor
There was a problem hiding this comment.
I'm assuming this error only mentions https because it's actually the preferred option? Same below, you only instruct the LLM to pass https, but http is also accepted.
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.
This PR addresses several issues from #59:
repoargument_IndexCacheat 10 entries (LRU) to prevent unbounded memory growthgit cloneto prevent hung MCP serverThe first concern (file:// URLs allow arbitrary local-repo read) is not addressed yet, as this changes the functionality of Semble (and arguably makes it worse). This is something for a followup PR.