restructure into multiple crates

add mcp server collection
This commit is contained in:
milan
2026-04-07 00:06:13 +02:00
parent 2dbac8a91a
commit ee17e74753
21 changed files with 2095 additions and 164 deletions
+8 -17
View File
@@ -1,13 +1,13 @@
use own_assist_common::config_loader::ConfigLoadingError;
use std::collections::HashMap;
use log::error;
use ollama_rs::headers::{HeaderMap, HeaderValue};
use ollama_rs::Ollama;
use rmcp::model::Implementation;
use serde::Deserialize;
use thiserror::Error;
use url::Url;
use crate::mcp;
use crate::mcp::{guaranteed_mcp_server_name, MCPClient};
use own_mcp::mcp;
use own_mcp::mcp::{guaranteed_mcp_server_name, MCPClient};
use own_assist_common::config_from_file;
#[derive(Debug, Deserialize)]
pub struct Config {
@@ -16,18 +16,9 @@ pub struct Config {
mcp_servers: Vec<MCPServerConfig>
}
#[derive(Debug, Error)]
pub enum ConfigLoadingError{
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
ParseError(#[from] toml::de::Error),
}
impl Config {
pub async fn from_file() -> Result<Self, ConfigLoadingError> {
let toml_string = tokio::fs::read_to_string("assist.toml").await?;
Ok(toml::from_str(&toml_string)?)
pub fn from_file() -> Result<Self, ConfigLoadingError> {
config_from_file("assist.toml")
}
pub fn ollama_config(&self) -> &OllamaConfig {
@@ -56,7 +47,7 @@ impl Config {
let client = mcp::get_client(
mcp_server.url.as_str(),
mcp_server.authorization.clone(),
Implementation::new("OwnAssist", "0.0.1"),
Implementation::new("own_assist", env!("CARGO_PKG_VERSION")),
).await.unwrap();
let server_name = guaranteed_mcp_server_name(mcp_server.name.clone(), &client);
@@ -88,5 +79,5 @@ pub struct OllamaModelConfig {
pub struct MCPServerConfig {
pub name: Option<String>,
pub url: Url,
pub authorization: Option<String>, // should probably implement oauth some time
pub authorization: Option<String>, // should probably implement oauth some time // actually, fuck oauth
}