@@ -2,11 +2,13 @@ package server
2
2
3
3
import (
4
4
"context"
5
+ "slices"
5
6
"time"
6
7
7
8
"github.com/mark3labs/mcp-go/mcp"
8
9
"github.com/mark3labs/mcp-go/server"
9
- "github.com/patrickdappollonio/mcp-domaintools/internal/dns"
10
+ "github.com/miekg/dns"
11
+ internaldns "github.com/patrickdappollonio/mcp-domaintools/internal/dns"
10
12
"github.com/patrickdappollonio/mcp-domaintools/internal/http_ping"
11
13
"github.com/patrickdappollonio/mcp-domaintools/internal/ping"
12
14
"github.com/patrickdappollonio/mcp-domaintools/internal/resolver"
@@ -16,7 +18,7 @@ import (
16
18
17
19
// DomainToolsConfig contains configuration for the domain tools.
18
20
type DomainToolsConfig struct {
19
- QueryConfig * dns .QueryConfig
21
+ QueryConfig * internaldns .QueryConfig
20
22
WhoisConfig * whois.Config
21
23
ResolverConfig * resolver.Config
22
24
PingConfig * ping.Config
@@ -25,6 +27,16 @@ type DomainToolsConfig struct {
25
27
Version string
26
28
}
27
29
30
+ // getDNSRecordTypes returns a sorted slice of all DNS record type names.
31
+ func getDNSRecordTypes () []string {
32
+ var recordTypes []string
33
+ for recordType := range dns .StringToType {
34
+ recordTypes = append (recordTypes , recordType )
35
+ }
36
+ slices .Sort (recordTypes )
37
+ return recordTypes
38
+ }
39
+
28
40
// SetupTools creates and configures the domain query tools.
29
41
func SetupTools (config * DomainToolsConfig ) (* server.MCPServer , error ) {
30
42
// Create a new MCP server
@@ -34,6 +46,9 @@ func SetupTools(config *DomainToolsConfig) (*server.MCPServer, error) {
34
46
server .WithRecovery (),
35
47
)
36
48
49
+ // Get all available DNS record types for the enum
50
+ dnsRecordTypes := getDNSRecordTypes ()
51
+
37
52
// Initialize resolver config if not provided
38
53
if config .ResolverConfig == nil {
39
54
config .ResolverConfig = & resolver.Config {
@@ -74,8 +89,8 @@ func SetupTools(config *DomainToolsConfig) (*server.MCPServer, error) {
74
89
),
75
90
mcp .WithString ("record_type" ,
76
91
mcp .Required (),
77
- mcp .Description ("The type of DNS record to query; defaults to A" ),
78
- mcp .Enum ("A" , "AAAA" , "CNAME" , "MX" , "NS" , "PTR" , "SOA" , "SRV" , "TXT" ),
92
+ mcp .Description ("The type of DNS record to query (supports all standard DNS record types) ; defaults to A" ),
93
+ mcp .Enum (dnsRecordTypes ... ),
79
94
mcp .DefaultString ("A" ),
80
95
),
81
96
)
@@ -89,8 +104,8 @@ func SetupTools(config *DomainToolsConfig) (*server.MCPServer, error) {
89
104
),
90
105
mcp .WithString ("record_type" ,
91
106
mcp .Required (),
92
- mcp .Description ("The type of DNS record to query; defaults to A" ),
93
- mcp .Enum ("A" , "AAAA" , "CNAME" , "MX" , "NS" , "PTR" , "SOA" , "SRV" , "TXT" ),
107
+ mcp .Description ("The type of DNS record to query (supports all standard DNS record types) ; defaults to A" ),
108
+ mcp .Enum (dnsRecordTypes ... ),
94
109
mcp .DefaultString ("A" ),
95
110
),
96
111
)
@@ -173,11 +188,11 @@ func SetupTools(config *DomainToolsConfig) (*server.MCPServer, error) {
173
188
174
189
// Create handler wrappers
175
190
localDNSHandler := func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
176
- return dns .HandleLocalDNSQuery (ctx , request , config .QueryConfig )
191
+ return internaldns .HandleLocalDNSQuery (ctx , request , config .QueryConfig )
177
192
}
178
193
179
194
remoteDNSHandler := func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
180
- return dns .HandleRemoteDNSQuery (ctx , request , config .QueryConfig )
195
+ return internaldns .HandleRemoteDNSQuery (ctx , request , config .QueryConfig )
181
196
}
182
197
183
198
whoisHandler := func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
0 commit comments