Skip to content

Commit 6a55e31

Browse files
committed
fix(serve): wire orchestrator and reranker into MCP search handler
The search tool handler now calls search_with_intelligence with the orchestrator and reranker from EngraphServer, enabling LLM-powered query expansion and result reranking in the MCP server. Removes #[allow(dead_code)] from the orchestrator and reranker fields.
1 parent 9017388 commit 6a55e31

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

src/serve.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ pub struct EngraphServer {
132132
profile: Arc<Option<VaultProfile>>,
133133
tool_router: ToolRouter<Self>,
134134
/// Query expansion orchestrator (None when intelligence is disabled or failed to load).
135-
#[allow(dead_code)]
136135
orchestrator: Option<Arc<Mutex<Box<dyn OrchestratorModel + Send>>>>,
137136
/// Result reranker (None when intelligence is disabled or failed to load).
138-
#[allow(dead_code)]
139137
reranker: Option<Arc<Mutex<Box<dyn RerankModel + Send>>>>,
140138
}
141139

@@ -168,8 +166,31 @@ impl EngraphServer {
168166
let top_n = params.0.top_n.unwrap_or(10);
169167
let store = self.store.lock().await;
170168
let mut embedder = self.embedder.lock().await;
171-
let output = search::search_internal(&params.0.query, top_n, &store, &mut *embedder)
172-
.map_err(|e| mcp_err(&e))?;
169+
170+
// Lock orchestrator and reranker if available for intelligence-enhanced search.
171+
let mut orch_guard = match &self.orchestrator {
172+
Some(o) => Some(o.lock().await),
173+
None => None,
174+
};
175+
let mut rerank_guard = match &self.reranker {
176+
Some(r) => Some(r.lock().await),
177+
None => None,
178+
};
179+
180+
let mut config = search::SearchConfig {
181+
orchestrator: orch_guard
182+
.as_mut()
183+
.map(|g| g.as_mut() as &mut dyn OrchestratorModel),
184+
reranker: rerank_guard
185+
.as_mut()
186+
.map(|g| g.as_mut() as &mut dyn RerankModel),
187+
store: &store,
188+
rerank_candidates: 30,
189+
};
190+
191+
let output =
192+
search::search_with_intelligence(&params.0.query, top_n, &mut *embedder, &mut config)
193+
.map_err(|e| mcp_err(&e))?;
173194
to_json_result(&output.results)
174195
}
175196

0 commit comments

Comments
 (0)