Skip to main content

dnslib/mcp/
params.rs

1//! MCP parameter DTOs — all tool parameter structs and enums.
2
3use schemars::JsonSchema;
4use serde::Deserialize;
5
6use crate::core::dns::records::{RecordData, RecordSelector};
7use crate::core::dns::zones::ZoneImportOptions;
8
9// ─── Shared server scope ───────────────────────────────────────────────────
10
11#[derive(Deserialize, JsonSchema)]
12pub struct ServerScopeParams {
13    /// The DNS server ID to run this command against (see dns_list_servers)
14    pub server_id: String,
15}
16
17// ─── Zone params ───────────────────────────────────────────────────────────
18
19#[derive(Deserialize, JsonSchema)]
20pub struct ZoneParams {
21    /// The DNS server ID to run this command against (see dns_list_servers)
22    pub server_id: String,
23    /// The zone name, e.g. "example.com"
24    pub zone: String,
25}
26
27#[derive(Deserialize, JsonSchema)]
28pub struct ListZonesParams {
29    /// The DNS server ID to run this command against (see dns_list_servers)
30    pub server_id: String,
31    /// Page number for pagination (default: 1)
32    pub page_number: Option<u32>,
33    /// Zones per page (default: 50)
34    pub zones_per_page: Option<u32>,
35}
36
37#[derive(Deserialize, JsonSchema)]
38pub struct CreateZoneParams {
39    /// The DNS server ID to run this command against (see dns_list_servers)
40    pub server_id: String,
41    /// Zone name, e.g. "example.com"
42    pub zone: String,
43    /// Zone type: Primary, Secondary, Stub, Forwarder
44    pub zone_type: String,
45}
46
47#[derive(Deserialize, JsonSchema)]
48pub struct ExportZoneFileParams {
49    /// The DNS server ID to run this command against (see dns_list_servers)
50    pub server_id: String,
51    /// Zone name to export, e.g. "example.com"
52    pub zone: String,
53}
54
55#[derive(Deserialize, JsonSchema)]
56pub struct ImportZoneFileParams {
57    /// The DNS server ID to run this command against (see dns_list_servers)
58    pub server_id: String,
59    /// Zone name the file will be imported into (must already exist)
60    pub zone: String,
61    /// Full RFC 1035 zone file content as a string
62    pub content: String,
63    /// Filename shown in API logs (default: zone.txt)
64    pub file_name: Option<String>,
65    #[serde(flatten)]
66    pub options: ZoneImportOptions,
67}
68
69// ─── Record params ─────────────────────────────────────────────────────────
70
71#[derive(Deserialize, JsonSchema)]
72pub struct ListRecordsParams {
73    /// The DNS server ID to run this command against (see dns_list_servers)
74    pub server_id: String,
75    /// Domain to list records for
76    pub domain: String,
77    /// Zone name (if different from domain)
78    pub zone: Option<String>,
79    /// Prefer a locally-resolved private IP over the provider's public A/AAAA value
80    #[serde(default, rename = "useLocalIp", alias = "use_local_ip")]
81    pub use_local_ip: Option<bool>,
82}
83
84#[derive(Deserialize, JsonSchema)]
85pub struct AddRecordParams {
86    /// The DNS server ID to run this command against (see dns_list_servers)
87    pub server_id: String,
88    pub zone: String,
89    pub domain: String,
90    /// TTL in seconds (default: 3600)
91    pub ttl: Option<u32>,
92    /// Typed record data, e.g. {"type":"A","ip":"1.2.3.4"} or
93    /// {"type":"MX","exchange":"mail.example.com","preference":10}
94    pub record: RecordData,
95}
96
97#[derive(Deserialize, JsonSchema)]
98pub struct DeleteRecordParams {
99    /// The DNS server ID to run this command against (see dns_list_servers)
100    pub server_id: String,
101    pub zone: String,
102    pub domain: String,
103    /// Which record(s) to delete. Only the `type` field is required.
104    /// Omitting value fields deletes ALL records of that type for the domain.
105    /// e.g. {"type":"A"} deletes all A records; {"type":"A","ipAddress":"1.2.3.4"} deletes one.
106    pub record: RecordSelector,
107}
108
109#[derive(Deserialize, JsonSchema)]
110pub struct DomainParams {
111    /// The DNS server ID to run this command against (see dns_list_servers)
112    pub server_id: String,
113    pub domain: String,
114}
115
116#[derive(Deserialize, JsonSchema)]
117pub struct StatsParams {
118    /// The DNS server ID to run this command against (see dns_list_servers)
119    pub server_id: String,
120    /// LastHour, LastDay, LastWeek, LastMonth, LastYear (default: LastDay)
121    pub stats_type: Option<String>,
122}