clean(mcp): extract constants, use CARGO_PKG_VERSION, fix unreachable

- extract DEFAULT_DATABASE_URL, DEFAULT_SEARCH_LIMIT, SERVER_NAME
- use env!("CARGO_PKG_VERSION") instead of hardcoded "0.1.0"
- content_type_to_str returns &'static str instead of allocating String
- cfg guard on unreachable pattern in wire_repositories
This commit is contained in:
2026-07-12 04:37:27 +02:00
parent ff5f299a84
commit f6b2481758
3 changed files with 17 additions and 10 deletions

View File

@@ -1,8 +1,8 @@
use std::sync::Arc;
use domain::ports::{IMediaProvider, IProviderRegistry, ProviderCapabilities, StreamingProtocol};
use domain::{DomainError, DomainResult, MediaFilter, MediaItemId, MediaItem, ScheduleEngineService};
use domain::ports::StreamQuality;
use domain::{DomainError, DomainResult, MediaFilter, MediaItem, MediaItemId, ScheduleEngineService};
use infra_wiring::DbPool;
use tracing::info;
use uuid::Uuid;
@@ -13,6 +13,8 @@ mod tools;
use server::KTvMcpServer;
const DEFAULT_DATABASE_URL: &str = "sqlite:data.db?mode=rwc";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let _ = dotenvy::dotenv();
@@ -26,7 +28,7 @@ async fn main() -> anyhow::Result<()> {
.init();
let database_url = std::env::var("DATABASE_URL")
.unwrap_or_else(|_| "sqlite:data.db?mode=rwc".to_string());
.unwrap_or_else(|_| DEFAULT_DATABASE_URL.to_string());
let owner_id: Uuid = std::env::var("MCP_USER_ID")
.map_err(|_| anyhow::anyhow!("MCP_USER_ID env var is required (UUID of the user)"))?
@@ -127,6 +129,7 @@ fn wire_repositories(pool: &DbPool) -> anyhow::Result<WireOutput> {
library_query: w.library_query,
})
}
#[cfg(not(any(feature = "sqlite", feature = "postgres")))]
_ => anyhow::bail!("database backend not compiled into this binary"),
}
}