collapse 20 pass-through use cases; handlers call ports directly

delete get/list/list_by_owner channels, get_settings/activity_log admin,
get_item/get_sync_status/list_collections/list_seasons/list_shows/list_genres library,
get/list/delete providers, get/list/patch_label config_snapshots,
get_active/list_history/delete_after schedule — all single-delegation.

remove ChannelQueryDeps, LibraryQueryDeps, deleted query/command structs.
add direct port fields to AppState. update MCP crate accordingly.
This commit is contained in:
2026-07-12 07:18:26 +02:00
parent a6558e15b2
commit e2393be635
68 changed files with 191 additions and 1589 deletions

View File

@@ -1,8 +1,8 @@
use std::sync::Arc;
use application::{
channels::{ChannelCommandDeps, ChannelQueryDeps},
library::LibraryQueryDeps,
channels::ChannelCommandDeps,
library::LibraryCommandDeps,
schedule::ScheduleDeps,
};
use rmcp::{
@@ -21,9 +21,11 @@ const SERVER_NAME: &str = "k-tv-mcp";
#[derive(Clone)]
pub struct KTvMcpServer {
pub channel_cmd_deps: Arc<ChannelCommandDeps>,
pub channel_query_deps: Arc<ChannelQueryDeps>,
pub channel_query: Arc<dyn domain::ports::ChannelQuery>,
pub schedule_deps: Arc<ScheduleDeps>,
pub library_query_deps: Arc<LibraryQueryDeps>,
pub schedule_query: Arc<dyn domain::ports::ScheduleQuery>,
pub library_query: Arc<dyn domain::ports::LibraryQuery>,
pub library_command_deps: Arc<LibraryCommandDeps>,
pub owner_id: Uuid,
}
@@ -80,13 +82,13 @@ fn parse_uuid(s: &str) -> Result<Uuid, String> {
impl KTvMcpServer {
#[tool(description = "List all channels owned by the configured user")]
async fn list_channels(&self) -> String {
channels::list_channels(&self.channel_query_deps, self.owner_id).await
channels::list_channels(&self.channel_query, self.owner_id).await
}
#[tool(description = "Get a channel by UUID")]
async fn get_channel(&self, #[tool(aggr)] p: GetChannelParams) -> String {
match parse_uuid(&p.id) {
Ok(id) => channels::get_channel(&self.channel_query_deps, id).await,
Ok(id) => channels::get_channel(&self.channel_query, id).await,
Err(e) => e,
}
}
@@ -143,7 +145,7 @@ impl KTvMcpServer {
#[tool(description = "Get the currently active schedule for a channel (returns null if none)")]
async fn get_active_schedule(&self, #[tool(aggr)] p: ChannelIdParam) -> String {
match parse_uuid(&p.channel_id) {
Ok(id) => schedule::get_active_schedule(&self.schedule_deps, id).await,
Ok(id) => schedule::get_active_schedule(&self.schedule_query, id).await,
Err(e) => e,
}
}
@@ -160,14 +162,14 @@ impl KTvMcpServer {
#[tool(description = "List media collections/libraries available in the library")]
async fn list_collections(&self) -> String {
library::list_collections(&self.library_query_deps).await
library::list_collections(&self.library_query).await
}
#[tool(
description = "List genres available in the library, optionally filtered by content type (movie/episode/short)"
)]
async fn list_genres(&self, #[tool(aggr)] p: ListGenresParams) -> String {
library::list_genres(&self.library_query_deps, p.content_type).await
library::list_genres(&self.library_query, p.content_type).await
}
#[tool(
@@ -175,7 +177,7 @@ impl KTvMcpServer {
)]
async fn search_media(&self, #[tool(aggr)] p: SearchMediaParams) -> String {
library::search_media(
&self.library_query_deps,
&self.library_command_deps,
p.content_type,
p.genres.unwrap_or_default(),
p.search_term,