Skip to content

feat: add POST /search endpoint to HTTP server#96

Open
tradewithmeai wants to merge 1 commit into
elara-labs:mainfrom
tradewithmeai:feat/http-search-endpoint
Open

feat: add POST /search endpoint to HTTP server#96
tradewithmeai wants to merge 1 commit into
elara-labs:mainfrom
tradewithmeai:feat/http-search-endpoint

Conversation

@tradewithmeai
Copy link
Copy Markdown

What this does

Adds a POST /search endpoint to the HTTP server (cce serve --http), exposing the hybrid retrieval pipeline for custom agent integrations.

The gap

cce serve --http currently only exposes /ingest and /health — there's no way to query an indexed project over HTTP. The cce search CLI 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_search to ContextEngineHTTP as a thin wrapper around the existing HybridRetriever pipeline — the same path the context_search MCP tool already uses internally.

POST /search
Content-Type: application/json

{"query": "cost tracking", "top_k": 5}

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 from cce search CLI.

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.

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
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.

1 participant