feat: add POST /search endpoint to HTTP server#96
Open
tradewithmeai wants to merge 1 commit into
Open
Conversation
Exposes the hybrid retrieval pipeline as a single HTTP endpoint,
enabling custom Python agents to query CCE without subprocess management.
The HTTP server previously only exposed /ingest and /health — no query
surface at all. This adds /search as a thin wrapper around the existing
HybridRetriever pipeline (the same path used by the context_search MCP tool).
Accepts: {"query": "...", "top_k": 10, "confidence_threshold": 0.2}
Returns: ranked chunks with file_path, line range, content, confidence_score
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.
What this does
Adds a
POST /searchendpoint to the HTTP server (cce serve --http), exposing the hybrid retrieval pipeline for custom agent integrations.The gap
cce serve --httpcurrently only exposes/ingestand/health— there's no way to query an indexed project over HTTP. Thecce searchCLI works, but requires subprocess management and produces human-readable text output rather than structured data.Custom Python agents (not Claude Code) that want to use CCE for semantic code search currently have two bad options: parse CLI text output, or re-implement the retrieval pipeline themselves.
The change
One file changed (~35 lines). Adds
handle_searchtoContextEngineHTTPas a thin wrapper around the existingHybridRetrieverpipeline — the same path thecontext_searchMCP tool already uses internally.Response:
{ "results": [ { "id": "b1294739d28245a1", "file_path": "memory/journal.py", "start_line": 81, "end_line": 86, "content": "def record_usage(model, provider, input_tokens, ...)", "chunk_type": "function", "language": "python", "confidence_score": 0.878, "metadata": {"_distance": 0.774} } ] }Real-world test
Tested live against an indexed Python project on my instance of a Hermes agent — a personal AI assistant that clones repos to a VPS and queries them for code analysis. Query
"cost tracking", top_k=3 returned three correctly ranked functions across two files with confidence scores. Matches the results fromcce searchCLI.Background
I've been using CCE inside my Hermes agent to give it semantic search over cloned repos, getting ~93% token reduction compared to reading full files (400 tokens served vs 6,151 full file tokens on a real query). This endpoint makes that integration cleaner and opens the same pattern to any agent framework that speaks HTTP.
No new logic, no new dependencies, no new commands. Just surfaces what's already there.