1use clap::{Parser, ValueEnum};
4use std::path::PathBuf;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum, Default)]
8pub enum TransportMode {
9 #[default]
11 Stdio,
12 Http,
14}
15
16#[derive(Debug, Clone, Parser)]
18#[command(name = "stygian-plugin-mcp")]
19#[command(about = "Standalone MCP server for stygian-plugin extraction", long_about = None)]
20pub struct Config {
21 #[arg(long, value_name = "PATH", default_value = "./plugin-templates")]
23 pub templates_dir: PathBuf,
24
25 #[arg(long, value_name = "LEVEL", default_value = "info")]
27 pub log_level: String,
28
29 #[arg(long, value_name = "NAME", default_value = "stygian-plugin")]
31 pub server_name: String,
32
33 #[arg(long, value_name = "MODE", default_value = "stdio")]
38 pub transport: TransportMode,
39
40 #[arg(long, value_name = "PORT", default_value = "3000")]
42 pub http_port: u16,
43}
44
45impl Config {
46 pub fn from_args() -> Self {
48 Self::parse()
49 }
50
51 pub fn testing() -> Self {
53 Self {
54 templates_dir: PathBuf::from("./test-templates"),
55 log_level: "debug".to_string(),
56 server_name: "stygian-plugin-test".to_string(),
57 transport: TransportMode::Stdio,
58 http_port: 3000,
59 }
60 }
61
62 pub fn testing_http(port: u16) -> Self {
64 Self {
65 templates_dir: PathBuf::from("./test-templates"),
66 log_level: "debug".to_string(),
67 server_name: "stygian-plugin-test".to_string(),
68 transport: TransportMode::Http,
69 http_port: port,
70 }
71 }
72}
73
74pub const SUPPORTED_PROTOCOL_VERSIONS: &[&str] = &["2025-11-25", "2025-06-18", "2024-11-05"];
76
77#[cfg(test)]
78mod tests {
79 use super::*;
80
81 #[test]
82 fn test_config_defaults() {
83 let cfg = Config::testing();
84 assert_eq!(cfg.server_name, "stygian-plugin-test");
85 assert_eq!(cfg.log_level, "debug");
86 assert_eq!(cfg.transport, TransportMode::Stdio);
87 assert_eq!(cfg.http_port, 3000);
88 }
89
90 #[test]
91 fn test_config_http() {
92 let cfg = Config::testing_http(8080);
93 assert_eq!(cfg.transport, TransportMode::Http);
94 assert_eq!(cfg.http_port, 8080);
95 }
96}