refactoring

different default system prompts for cli and audio
This commit is contained in:
2026-05-04 21:18:09 +02:00
parent 3d8975cfc1
commit 51b1123cf9
16 changed files with 80 additions and 45 deletions
+4 -2
View File
@@ -977,7 +977,7 @@ checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
[[package]]
name = "mcp_server_collection"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"axum",
"chrono",
@@ -994,6 +994,7 @@ dependencies = [
"tokio-util",
"toml",
"tower-http",
"tracing",
"tracing-subscriber",
"url",
"uuid",
@@ -1108,8 +1109,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
[[package]]
name = "own_assist_common"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"log",
"serde",
"thiserror",
"toml",
+2 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "mcp_server_collection"
version = "0.2.0"
version = "0.2.1"
edition = "2024"
[dependencies]
@@ -11,6 +11,7 @@ serde = { version = "1.0.228", features = ["derive"] }
tokio = { version = "1.51.0", features = ["full"] }
own_assist_common = { path = "../common" }
tokio-util = "0.7.18"
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
url = { version = "2.5.8", features = ["serde"] }
uuid = { version = "1.23.0", features = ["v4"], optional = true }
+3 -1
View File
@@ -11,6 +11,8 @@ use rmcp::ErrorData;
use rmcp::model::ErrorCode;
use thiserror::Error;
use tower_http::auth::AddAuthorization;
use tracing::event;
use tracing::Level;
use uuid::Uuid;
pub(crate) type AuthorizedCaldavClient =
@@ -111,7 +113,7 @@ pub(crate) async fn upload_components(
calendar: &FoundCollection,
components: Vec<impl Into<CalendarComponent>>,
) -> Result<PutResourceResponse, CalendarError> {
println!("uploading components to {}", calendar.href);
event!(Level::INFO, "uploading components to {}", calendar.href);
let mut upload_calendar = Calendar::new();
for todo in components {
+11 -1
View File
@@ -52,7 +52,17 @@ impl DateTimeHandler {
annotations(read_only_hint = true)
)]
fn get_weekday() -> String {
Local::now().weekday().to_string()
use chrono::Weekday::*;
match Local::now().weekday() {
Mon => "Monday",
Tue => "Tuesday",
Wed => "Wednesday",
Thu => "Thursday",
Fri => "Friday",
Sat => "Saturday",
Sun => "Sunday",
}.to_string()
}
}
+11 -13
View File
@@ -6,6 +6,7 @@ pub mod datetime;
pub mod caldav;
mod server_handler;
#[cfg(feature = "caldav")]
use crate::caldav::CalDavHandler;
use crate::config::{Config, ServerConfig};
#[cfg(feature = "datetime")]
@@ -15,13 +16,17 @@ use axum::Router;
use axum::response::Json;
use serde::{Deserialize, Serialize};
use tokio::main;
use tracing::{event, Level};
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use own_assist_common::exit_msg;
#[derive(Debug, Clone, Deserialize, Serialize)]
#[non_exhaustive]
pub enum McpServiceType {
#[cfg(feature = "datetime")]
DateTime,
#[cfg(feature = "caldav")]
CalDav,
}
@@ -32,10 +37,12 @@ pub(crate) async fn mcp_router(
for config in server_configs {
router = match config.r#type {
#[cfg(feature = "datetime")]
McpServiceType::DateTime => router.route_service(
config.path.as_str(),
DateTimeHandler::mcp_service(config.additional_properties.clone()).await?,
),
#[cfg(feature = "caldav")]
McpServiceType::CalDav => router.route_service(
config.path.as_str(),
CalDavHandler::mcp_service(config.additional_properties.clone()).await?,
@@ -65,10 +72,7 @@ async fn main() {
.init();
let config = Config::from_file()
.inspect_err(|e| {
eprintln!("Error loading config: {e}");
std::process::exit(1);
})
.inspect_err(exit_msg!("Error loading config: {e}"))
.unwrap();
let routes = Json(
@@ -82,24 +86,18 @@ async fn main() {
let router = mcp_router(&config.servers)
.await
.inspect_err(|e| {
eprintln!("Error loading config: {e}");
std::process::exit(1);
})
.inspect_err(exit_msg!("Error handling server: {e}"))
.unwrap()
.route("/", axum::routing::get(|| async { routes }));
let bind_address = config
.bind_address
.unwrap_or(url::Url::parse("http://localhost:8000").unwrap());
println!("binding address at {bind_address}");
event!(Level::INFO,"binding address at {bind_address}");
let tcp_listener = tokio::net::TcpListener::bind(bind_address_format(bind_address))
.await
.inspect_err(|e| {
eprintln!("Error bind tcp listener: {e:#?}");
std::process::exit(1);
})
.inspect_err(exit_msg!("Error bind tcp listener: {e:#?}"))
.unwrap();
let ct = tokio_util::sync::CancellationToken::new();