Skip to main content

dnspls_mcp/
lib.rs

1//! Stable MCP tool vocabulary and facade for `DNSpls` domain intelligence.
2//!
3//! Transport implementations can evolve without changing these semantic tool
4//! identities or the evidence kernel re-exported by this package.
5
6use serde::{Deserialize, Serialize};
7
8pub use dnspls::*;
9pub use dnspls_engine as engine;
10pub use dnspls_provider as provider;
11pub use dnspls_snapshot as snapshot;
12
13/// Stable names of the `DNSpls` MCP tools described by RFC 0008.
14#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
15#[serde(rename_all = "snake_case")]
16pub enum ToolName {
17    DomainGenerate,
18    DomainSearch,
19    DomainVerify,
20    DomainBulkScreen,
21    DomainExplain,
22}
23
24impl ToolName {
25    pub const ALL: [Self; 5] = [
26        Self::DomainGenerate,
27        Self::DomainSearch,
28        Self::DomainVerify,
29        Self::DomainBulkScreen,
30        Self::DomainExplain,
31    ];
32
33    pub const fn as_str(self) -> &'static str {
34        match self {
35            Self::DomainGenerate => "domain_generate",
36            Self::DomainSearch => "domain_search",
37            Self::DomainVerify => "domain_verify",
38            Self::DomainBulkScreen => "domain_bulk_screen",
39            Self::DomainExplain => "domain_explain",
40        }
41    }
42
43    pub const fn performs_live_network_io(self) -> bool {
44        matches!(self, Self::DomainVerify)
45    }
46}
47
48#[cfg(test)]
49mod tests {
50    use std::collections::BTreeSet;
51
52    use super::*;
53
54    #[test]
55    fn tool_names_are_unique_and_stable() {
56        let names = ToolName::ALL
57            .map(ToolName::as_str)
58            .into_iter()
59            .collect::<BTreeSet<_>>();
60        assert_eq!(names.len(), ToolName::ALL.len());
61    }
62
63    #[test]
64    fn only_verify_is_live_by_default() {
65        for tool in ToolName::ALL {
66            assert_eq!(
67                tool.performs_live_network_io(),
68                tool == ToolName::DomainVerify
69            );
70        }
71    }
72}