mcp_server_collection now also a library

own_assist now bundles the server collection by default
This commit is contained in:
2026-05-14 17:41:39 +02:00
parent 18221b7b56
commit d43498154e
19 changed files with 716 additions and 143 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ impl AudioClient {
fn get(&self, url: Url) -> reqwest::RequestBuilder {
self.client.get(url).header(
"Authorization",
self.authorization.clone().unwrap_or(String::new()),
self.authorization.clone().unwrap_or_default(),
)
}
}
+6 -6
View File
@@ -108,11 +108,11 @@ fn start_recording_blocking_with_parameters(
loop {
thread::sleep(Duration::from_millis(100));
if let Ok(guard) = should_stop.lock() {
if *guard {
debug!("Stopping recording gracefully");
break;
}
if let Ok(guard) = should_stop.lock()
&& *guard
{
debug!("Stopping recording gracefully");
break;
}
}
@@ -173,7 +173,7 @@ pub fn stop_and_take_data(
.ok_or(RecordingError::RecordingAlreadyStopped)?;
let samples = handler.samples.clone();
let spec = handler.spec.clone();
let spec = handler.spec;
handler.stop_recording()?;
+13 -6
View File
@@ -8,6 +8,7 @@ use rmcp::ServiceError;
use rmcp::model::{CallToolRequestParams, CallToolResult};
use serde::Deserialize;
use std::collections::HashMap;
use ollama_rs::generation::completion::request::GenerationRequest;
use thiserror::Error;
#[derive(Debug, Copy, Clone, Default, Deserialize, PartialEq)]
@@ -113,6 +114,13 @@ impl AgentChat {
servers.insert(server.name.clone(), server);
}
// lets the ollama server load the model
let ollama_client_clone = ollama_client.clone();
let model_clone = model.clone();
tokio::spawn(async move {
let _ = ollama_client_clone.generate(GenerationRequest::new(model_clone, "")).await;
});
Ok(Self {
ollama_client,
model,
@@ -124,8 +132,7 @@ impl AgentChat {
pub fn get_all_tools(&self) -> impl Iterator<Item = &RestrictedTool> {
self.mcp_servers
.values()
.map(|server| server.translated_tools.iter())
.flatten()
.flat_map(|server| server.translated_tools.iter())
}
///
@@ -300,10 +307,10 @@ impl AgentChat {
let mcp_server_data = self
.get_mcp_server_by_name(mcp_server_name.clone())
.ok_or(ChatError::ServiceNotFoundError(mcp_server_name.clone()))?;
let restricted_tool =
AgentChat::get_tool(&mcp_server_data, full_unparsed_tool_name.clone()).ok_or(
ChatError::ToolNotFoundError(full_unparsed_tool_name.clone()),
)?;
let restricted_tool = AgentChat::get_tool(mcp_server_data, full_unparsed_tool_name.clone())
.ok_or(ChatError::ToolNotFoundError(
full_unparsed_tool_name.clone(),
))?;
match restricted_tool.permission {
ToolPermission::Allowed => {
+1 -1
View File
@@ -12,7 +12,7 @@ pub(in crate::mcp) async fn get_server_tool_info(
.list_all_tools()
.await?
.iter()
.map(|mcp_tool| tool_info_from_mcp_tool(&mcp_tool, server_name))
.map(|mcp_tool| tool_info_from_mcp_tool(mcp_tool, server_name))
.collect::<Vec<_>>();
Ok(tool_info)