use clap::{Parser, ValueEnum};
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum, Default)]
pub enum TransportMode {
#[default]
Stdio,
Http,
}
#[derive(Debug, Clone, Parser)]
#[command(name = "stygian-plugin-mcp")]
#[command(about = "Standalone MCP server for stygian-plugin extraction", long_about = None)]
pub struct Config {
#[arg(long, value_name = "PATH", default_value = "./plugin-templates")]
pub templates_dir: PathBuf,
#[arg(long, value_name = "LEVEL", default_value = "info")]
pub log_level: String,
#[arg(long, value_name = "NAME", default_value = "stygian-plugin")]
pub server_name: String,
#[arg(long, value_name = "MODE", default_value = "stdio")]
pub transport: TransportMode,
#[arg(long, value_name = "PORT", default_value = "3000")]
pub http_port: u16,
}
impl Config {
pub fn from_args() -> Self {
Self::parse()
}
pub fn testing() -> Self {
Self {
templates_dir: PathBuf::from("./test-templates"),
log_level: "debug".to_string(),
server_name: "stygian-plugin-test".to_string(),
transport: TransportMode::Stdio,
http_port: 3000,
}
}
pub fn testing_http(port: u16) -> Self {
Self {
templates_dir: PathBuf::from("./test-templates"),
log_level: "debug".to_string(),
server_name: "stygian-plugin-test".to_string(),
transport: TransportMode::Http,
http_port: port,
}
}
}
pub const SUPPORTED_PROTOCOL_VERSIONS: &[&str] = &["2025-11-25", "2025-06-18", "2024-11-05"];
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_config_defaults() {
let cfg = Config::testing();
assert_eq!(cfg.server_name, "stygian-plugin-test");
assert_eq!(cfg.log_level, "debug");
assert_eq!(cfg.transport, TransportMode::Stdio);
assert_eq!(cfg.http_port, 3000);
}
#[test]
fn test_config_http() {
let cfg = Config::testing_http(8080);
assert_eq!(cfg.transport, TransportMode::Http);
assert_eq!(cfg.http_port, 8080);
}
}