Skip to content

Commit 60ac929

Browse files
committed
Implement DNS TXT record verification for domain ownership validation
1 parent bc4d621 commit 60ac929

File tree

5 files changed

+1100
-46
lines changed

5 files changed

+1100
-46
lines changed

examples/dns-verify/main.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os"
7+
8+
"github.com/modelcontextprotocol/registry/internal/verification"
9+
)
10+
11+
func main() {
12+
if len(os.Args) != 3 {
13+
fmt.Println("Usage: dns-verify <domain> <token>")
14+
fmt.Println("Example: dns-verify example.com TBeVXe_X4npM6p8vpzStnA")
15+
os.Exit(1)
16+
}
17+
18+
domain := os.Args[1]
19+
token := os.Args[2]
20+
21+
fmt.Printf("🔍 Verifying DNS record for domain: %s\n", domain)
22+
fmt.Printf("🎯 Expected token: %s\n", token)
23+
fmt.Printf("📋 Expected DNS record: mcp-verify=%s\n\n", token)
24+
25+
// Perform DNS verification
26+
result, err := verification.VerifyDNSRecord(domain, token)
27+
if err != nil {
28+
log.Printf("❌ DNS verification error: %v", err)
29+
os.Exit(1)
30+
}
31+
32+
// Display results
33+
fmt.Printf("📊 Verification Results:\n")
34+
fmt.Printf(" Success: %t\n", result.Success)
35+
fmt.Printf(" Domain: %s\n", result.Domain)
36+
fmt.Printf(" Token: %s\n", result.Token)
37+
fmt.Printf(" Duration: %s\n", result.Duration)
38+
fmt.Printf(" Message: %s\n", result.Message)
39+
40+
if len(result.TXTRecords) > 0 {
41+
fmt.Printf("\n📝 Found TXT Records:\n")
42+
for i, record := range result.TXTRecords {
43+
fmt.Printf(" %d. %s\n", i+1, record)
44+
}
45+
}
46+
47+
if result.Success {
48+
fmt.Println("\n✅ Domain verification successful!")
49+
os.Exit(0)
50+
} else {
51+
fmt.Println("\n❌ Domain verification failed!")
52+
os.Exit(1)
53+
}
54+
}

0 commit comments

Comments
 (0)