Repository navigation
Hanan/docker mcp http - #341
Draft
HananKavitzAmat wants to merge 81 commits into
Draft
HananKavitzAmat wants to merge 81 commits into
HananKavitzAmat wants to merge 81 commits into
Conversation
…with contract tests
…ing DB ChunkHound records indexed_root_path in chunks.db.root.json. On every new MCP session the startup scan walks that path and calls _cleanup_orphaned_files, deleting DB records for any file not found on disk. With only auth files at /home/chunkhound, all indexed content was deleted on first connect. Mount the source at /home/chunkhound via CHUNKHOUND_SOURCE_PATH (.env). Mount is writable (not :ro) so Docker can stack .claude.json/.claude/ sub-path mounts on top — Docker cannot bind-mount inside a :ro parent. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…licas.sh Hardcoded HOST_UID=1000 broke on machines where the container user maps to a different UID (e.g. LDAP environments). Now detects the real UID/GID by running `id` inside a throwaway container, making the script portable across machines. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
chunkhound-mcp-wrapper uses pkill and pgrep to evict previous DuckDB sessions; these commands are provided by procps which was missing from the image. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…e overflow On Linux, watchdog 6.0.0 registers IN_OPEN by default (via WATCHDOG_ALL_EVENTS). The initial file scan opening source files for hashing/embedding triggered inotify "opened" events that passed the path admission filter, flooded the 1000-slot queue, and caused overflow → resync → query_ready=false on every startup. Pass an explicit event_filter to observer.schedule() so only actionable inotify flags (create/modify/delete/move) are registered — IN_OPEN and IN_CLOSE_NOWRITE are never seen by the kernel watcher, eliminating the self-feedback loop. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…TIMEOUT Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Implements HttpMCPServer (chunkhound/mcp_server/http_server.py) — a thin aiohttp server that serves the MCP Streamable HTTP protocol in-process, without spawning a subprocess per request. The key fix for Docker code_research timeouts: instead of returning 202 Accepted (mcp-proxy's approach, which forces Claude Code to poll a separate GET SSE channel that times out at ~293s), tools/call now returns 200 OK + text/event-stream inline in the POST response body. A ': ping' SSE comment is streamed every 15s while the tool runs, keeping the connection alive regardless of execution duration. code_research was tested successfully at ~5m25s with no timeout. CLI: chunkhound mcp --transport http --port 5173 Docker: entrypoint now runs chunkhound mcp --transport http instead of mcp-proxy Dockerfile: mcp-proxy and chunkhound-mcp-wrapper removed (no longer needed) nginx/docker-compose: timeouts extended to 1200s to match long tool runs Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…-mcp-http Resolves conflicts in AGENTS.md (kept --transport http flag, added git diff search commands) and stdio.py (kept SSE keepalive, adopted compaction-aware ensure_tool_services() routing from PR). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…is branch Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…-mcp-http Adds output_dims and client_side_truncation support to the OpenAI embedding provider so the Docker MCP deployment can serve semantic search against DBs indexed with client-side truncation (e.g. quest/mono with embeddings_256). Without this, query embeddings would be 2560-dim and the server would fail to find the embeddings_256 table, returning no results for all semantic searches. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…eout Skip initial scan on replica containers to avoid redundant re-indexing on startup. Extend CHUNKHOUND_DB_EXECUTE_TIMEOUT to 7200s to accommodate HNSW index rebuilds on large vector sets (3-5M vectors, 15-30 min first run). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… patterns - Add 3-CPU limit to chunkhound services to prevent monopolizing host during HNSW index load - Reduce deployment from 3 replicas to 2; update nginx upstream accordingly - Switch nginx lb from ip_hash to consistent hash for better load distribution - Extend healthcheck start_period to 120s to account for HNSW index rebuild time - Filter invalid gitignore patterns before compiling PathSpec to avoid crashes Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ird replica Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…icas Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
* feat(mcp): add --read-only flag for safe DuckDB MCP access Opens the DuckDB database read-only for the duration of the MCP session and disables every write path that would otherwise run alongside a query server. * docs(changelog): document `chunkhound mcp --read-only` and warn when it forces single-process stdio * feat(mcp): finish --read-only wiring and rename scan_completed_at → query_ready_at * test(mcp): cover stale-WAL hint, query_ready_at, and forced-stdio for --read-only * test: stabilize chrome headless flags and stub deferred connect in watchman fallback tests Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…se env vars Pass --read-only to chunkhound mcp in the Docker entrypoint now that the flag exists, and remove the manual COMPACTION_ENABLED/SKIP_INITIAL_SCAN workarounds that were serving the same purpose. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Thread TreeProgressDisplay through WideCoverageStrategy → DepthExplorationService and GapDetectionService. Each service gains an _emit_event helper and perf_counter() timing around every step, emitting gap_step events (▶) with per-step durations visible in the terminal progress tree. Also fixes from code review: - gap_stats["chunks_added"] now includes import_chunks_added, matching the completion event message - Step 2.10 / 1.5.6 import-resolution timing event always emits (previously silently dropped when resolve_and_fetch_imports returns []) - gaps_filled reuses the variable from step 2.7 instead of recomputing - total_before_dedup reuses chunks_from_fills instead of re-iterating gap_results - Add gap_step and fact_extraction symbols to TreeProgressDisplay Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…vent duplication GapDetectionService and DepthExplorationService had identical _emit_event implementations. Extracted to a shared ProgressEmitterMixin in the shared package. Also fixes depth_stats["chunks_added"] to include import_chunks_added, matching the semantics of gap_stats["chunks_added"] and the completion log message. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Fix I001: move ProgressEmitterMixin import to correct sorted position in depth_exploration.py - Fix E501: split long f-strings in _emit_event calls across two lines (depth_exploration, gap_detection) - Fix E501: shorten chunks_added inline comment in gap_detection stats dict - Fix blank line missing after TYPE_CHECKING block in gap_detection.py - Add _progress = None default to ProgressEmitterMixin to prevent AttributeError in future subclasses Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… 1.5.3 Firing all 10 exploration queries simultaneously caused a thundering herd on the reranker — 6+ concurrent rerank requests overwhelmed pdc-llm-srv1, producing batch timeouts (30s each) that dominated Step 1.5.3 runtime. Adds asyncio.Semaphore(3) around the asyncio.gather in _execute_exploration_queries so at most 3 unified_search calls (and thus 3 rerank requests) run concurrently. Also adds per-call rerank timing (logger.warning) in unified_search.py to make reranker latency visible alongside the existing step-level timings. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…similarity scoring Phase 1.5 depth exploration previously fired N concurrent HTTP rerank calls (one per exploration query), causing a thundering herd on the reranking server. Replaces Step 7 reranking with a single batch DB query using array_cosine_similarity() when skip_rerank=True. Regex-only chunks (which carry no score) are scored against stored embeddings; semantic chunks already carry similarity from HNSW search. All chunks sort by the uniform similarity field. Also fixes _select_top_files to prefer similarity over rerank_score so file ranking survives if Phase 1 reranking is removed in the future. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…aphore branch Restores timing/progress infrastructure lost when the branch was cut before the timing PR landed on main: - Restore ProgressEmitterMixin, perf_counter timing, and _emit_event calls in DepthExplorationService (steps 1.5.1–1.5.6) and GapDetectionService - Restore progress_mixin.py (was missing entirely — only .pyc existed) - Restore wide_coverage_strategy.py progress forwarding to sub-services - Restore factory.py progress=progress forwarding to WideCoverageStrategy - Restore pluggable_research_service.py to mixin-based version from main - Restore gap_step and fact_extraction symbols in tree_progress.py New additions: - Add search_rerank (⚖️) symbol and timing event to unified_search Step 7: "Cosine-scored N chunks (Xs)" for skip_rerank=True path, "Reranked N chunks (Xs)" for rerank path - Wire emit_event_callback into depth exploration and gap detection unified_search calls so Step 7 timing is visible in terminal tree - Fix _global_dedup and _merge_coverage in DepthExplorationService to use score_field="similarity" (was "rerank_score", causing first-seen-wins) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… layer Implements Section 9 of the deferred-reranking pitch: regex search now returns a similarity score at every call site instead of unordered results. - search_service.search_regex_async accepts query: str | None = None; when set, embeds the query and batch-scores all returned chunks via array_cosine_similarity before result enhancement so similarity_percentage is populated correctly - diff_aware_search_service forwards query through both the protocol stub and the concrete implementation - unified_search.search_by_symbols accepts and forwards query to search_regex_async; the skip_rerank branch is simplified to a sort since regex chunks arrive pre-scored from the service layer - mcp_server/tools.py passes query=query to search_regex_async so MCP regex searches are scored by relevance - cli search.py removes the if-not-is_regex guard so similarity is shown whenever the field is present, regardless of search type - fix test_depth_exploration fixtures to use similarity instead of rerank_score to match the scoring field used by depth exploration since commit fd2d324 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… is provided The sync path accepted a `query` parameter but silently ignored it. Mirror the async path: when called outside an event loop, spin up a temporary loop via asyncio.run() to embed the query and batch-score regex chunks via get_chunk_similarities_async. When called from inside an existing event loop, log a debug message and skip scoring (callers in that context should use search_regex_async). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Embed query once before pagination loop instead of per-page (eliminates N embed calls per symbol) - Move cosine scoring to a single post-pagination bulk call instead of per-page calls (N pages → 1 round-trip per symbol) - Add consecutive dry-pages early exit (3 consecutive fully-excluded pages stops pagination early) to avoid exhausting max_pages on covered symbols - Reduce max_pages from 20 to 10, halving the worst-case scan depth - Fix test_keeps_coverage_chunk_if_higher_score to use similarity field (matches score_field used by _merge_coverage after PR chunkhound#356) - Remove unused sync get_chunk_similarities method from DuckDBProvider - Remove redundant search_service assignment at skip_rerank path Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Empirical comparison on the same query shows max_symbols=3 is both faster and produces higher-quality output than max_symbols=5: - Runtime: −27% (425s → 311s), BFS Step 5: −53% (3×83s → 1×15s) - Quality: 75 files / 88 chunks vs 60 files / 64 chunks; avoids pulling in large .properties noise files via common-symbol regex hits Symbols 4-5 tend to be parameter/type names that are high-frequency across the codebase (e.g. "timeout", "port") and produce noisy regex matches that consume synthesis token budget without adding relevant content. Also revert max_pages 10→20: the reduction didn't improve wall clock because concurrent BFS search count compensates, and it risks missing deeper regex results for genuinely rare symbols. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ations Depth exploration ran each of its 10 serial iterations independently, passing only the current iteration's ~30 semantic chunk IDs as exclusions to the regex pagination loop. Later iterations would re-scan symbols already found in earlier iterations, wasting DB pages before the consecutive-dry-pages early exit could fire. Fix: maintain a global_seen set in _execute_exploration_queries that accumulates returned chunk IDs after each iteration. Pass it to unified_search via a new exclude_ids parameter, which merges it with the per-call semantic exclusions before search_by_symbols runs. Measured on "explain matlab L2 launch sequence" (v2 wide_coverage): - Phase 1.5 Step 5 total: 224s → 178s (−21%) - Phase 1.5 wall clock: 353s → 298s (−55s) - Phase 2 gap detection: 113s → 82s (−31s, fewer gaps due to better coverage) - Grand total: 601s → 550s (−52s, −8.6%) - Output: 67 files cited vs 56 (more unique coverage) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
HananKavitzAmat
added a commit
to HananKavitzAmat/chunkhound
that referenced
this pull request
Jul 21, 2026
Adds a load-balanced chunkhound-mcp deployment behind nginx (sticky routing by client IP), ported from PR chunkhound#341 with two fixes: replica count is now a --replicas CLI flag (scripts/generate-compose.sh, scripts/prepare-db-replicas.sh) instead of hardcoded, and host-specific paths/UID/GID are sourced from .env.docker instead of being hardcoded in the compose file. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This branch has not been deployed
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.
No description provided.