fraiseql_cli/config/toml_schema/server_settings.rs
1//! Server settings configuration for TOML schema (validation, debug, MCP).
2
3use serde::{Deserialize, Serialize};
4
5/// MCP (Model Context Protocol) server configuration.
6///
7/// Enables AI/LLM tools to interact with FraiseQL queries and mutations
8/// through the standardized Model Context Protocol.
9#[derive(Debug, Clone, Deserialize, Serialize)]
10#[serde(default, deny_unknown_fields)]
11pub struct McpConfig {
12 /// Enable MCP server endpoint.
13 pub enabled: bool,
14 /// Transport mode: "http", "stdio", or "both".
15 pub transport: String,
16 /// HTTP path for MCP endpoint (e.g., "/mcp").
17 pub path: String,
18 /// Require authentication for MCP requests.
19 pub require_auth: bool,
20 /// Whitelist of query/mutation names to expose (empty = all).
21 #[serde(default)]
22 pub include: Vec<String>,
23 /// Blacklist of query/mutation names to hide.
24 #[serde(default)]
25 pub exclude: Vec<String>,
26}
27
28impl Default for McpConfig {
29 fn default() -> Self {
30 Self {
31 enabled: false,
32 transport: "http".to_string(),
33 path: "/mcp".to_string(),
34 require_auth: true,
35 include: Vec::new(),
36 exclude: Vec::new(),
37 }
38 }
39}
40
41/// Query validation limits (depth and complexity).
42///
43/// ```toml
44/// [validation]
45/// max_query_depth = 10
46/// max_query_complexity = 100
47/// ```
48#[derive(Debug, Clone, Default, Deserialize, Serialize)]
49#[serde(default, deny_unknown_fields)]
50pub struct ValidationConfig {
51 /// Maximum allowed query nesting depth. `None` uses the server default (10).
52 #[serde(default, skip_serializing_if = "Option::is_none")]
53 pub max_query_depth: Option<u32>,
54
55 /// Maximum allowed query complexity score. `None` uses the server default (100).
56 #[serde(default, skip_serializing_if = "Option::is_none")]
57 pub max_query_complexity: Option<u32>,
58}
59
60/// Debug/development configuration.
61///
62/// Controls features that should only be enabled during development or
63/// in trusted environments. All flags default to off.
64///
65/// ```toml
66/// [debug]
67/// enabled = true
68/// database_explain = true
69/// expose_sql = true
70/// ```
71#[derive(Debug, Clone, Deserialize, Serialize)]
72#[serde(default, deny_unknown_fields)]
73pub struct DebugConfig {
74 /// Master switch — all debug features require this to be `true`.
75 pub enabled: bool,
76
77 /// When `true`, the explain endpoint will also run `EXPLAIN` against the
78 /// database and include the query plan in the response.
79 pub database_explain: bool,
80
81 /// When `true`, the explain endpoint includes the generated SQL in the
82 /// response. Defaults to `true` (SQL is shown even without
83 /// `database_explain`).
84 pub expose_sql: bool,
85}
86
87impl Default for DebugConfig {
88 fn default() -> Self {
89 Self {
90 enabled: false,
91 database_explain: false,
92 expose_sql: true,
93 }
94 }
95}