@hasna/microservices 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,7 +31,26 @@ import {
31
31
  validateDns,
32
32
  exportPortfolio,
33
33
  checkAllDomains,
34
+ getDomainByName,
34
35
  } from "../db/domains.js";
36
+ import {
37
+ syncToLocalDb,
38
+ renewDomain as namecheapRenew,
39
+ checkAvailability as namecheapCheck,
40
+ } from "../lib/namecheap.js";
41
+ import {
42
+ syncToLocalDb as godaddySyncToLocalDb,
43
+ renewDomain as godaddyRenewDomain,
44
+ } from "../lib/godaddy.js";
45
+ import {
46
+ getAvailableProviders,
47
+ syncAll,
48
+ } from "../lib/registrar.js";
49
+ import {
50
+ monitorBrand,
51
+ getSimilarDomains,
52
+ getThreatAssessment,
53
+ } from "../lib/brandsight.js";
35
54
 
36
55
  const server = new McpServer({
37
56
  name: "microservice-domains",
@@ -523,6 +542,232 @@ server.registerTool(
523
542
  }
524
543
  );
525
544
 
545
+ // --- Namecheap Integration ---
546
+
547
+ server.registerTool(
548
+ "sync_namecheap",
549
+ {
550
+ title: "Sync Namecheap Domains",
551
+ description: "Sync all domains from Namecheap account to local database. Requires NAMECHEAP_API_KEY, NAMECHEAP_USERNAME, and NAMECHEAP_CLIENT_IP env vars.",
552
+ inputSchema: {},
553
+ },
554
+ async () => {
555
+ try {
556
+ const result = await syncToLocalDb({
557
+ getDomainByName,
558
+ createDomain,
559
+ updateDomain,
560
+ });
561
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
562
+ } catch (error: unknown) {
563
+ return {
564
+ content: [{ type: "text", text: `Sync failed: ${error instanceof Error ? error.message : String(error)}` }],
565
+ isError: true,
566
+ };
567
+ }
568
+ }
569
+ );
570
+
571
+ server.registerTool(
572
+ "renew_via_namecheap",
573
+ {
574
+ title: "Renew Domain via Namecheap",
575
+ description: "Renew a domain through the Namecheap API.",
576
+ inputSchema: {
577
+ domain: z.string().describe("Domain name to renew (e.g. example.com)"),
578
+ years: z.number().default(1).describe("Number of years to renew"),
579
+ },
580
+ },
581
+ async ({ domain, years }) => {
582
+ try {
583
+ const result = await namecheapRenew(domain, years);
584
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
585
+ } catch (error: unknown) {
586
+ return {
587
+ content: [{ type: "text", text: `Renewal failed: ${error instanceof Error ? error.message : String(error)}` }],
588
+ isError: true,
589
+ };
590
+ }
591
+ }
592
+ );
593
+
594
+ server.registerTool(
595
+ "check_availability_namecheap",
596
+ {
597
+ title: "Check Domain Availability",
598
+ description: "Check if a domain name is available for registration via Namecheap.",
599
+ inputSchema: {
600
+ domain: z.string().describe("Domain name to check (e.g. example.com)"),
601
+ },
602
+ },
603
+ async ({ domain }) => {
604
+ try {
605
+ const result = await namecheapCheck(domain);
606
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
607
+ } catch (error: unknown) {
608
+ return {
609
+ content: [{ type: "text", text: `Check failed: ${error instanceof Error ? error.message : String(error)}` }],
610
+ isError: true,
611
+ };
612
+ }
613
+ }
614
+ );
615
+
616
+ // --- GoDaddy Integration ---
617
+
618
+ server.registerTool(
619
+ "sync_godaddy",
620
+ {
621
+ title: "Sync GoDaddy Domains",
622
+ description: "Sync all domains from GoDaddy account to local database. Requires GODADDY_API_KEY and GODADDY_API_SECRET env vars.",
623
+ inputSchema: {},
624
+ },
625
+ async () => {
626
+ try {
627
+ const result = await godaddySyncToLocalDb({
628
+ getDomainByName,
629
+ createDomain,
630
+ updateDomain,
631
+ });
632
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
633
+ } catch (error: unknown) {
634
+ return {
635
+ content: [{ type: "text", text: `Sync failed: ${error instanceof Error ? error.message : String(error)}` }],
636
+ isError: true,
637
+ };
638
+ }
639
+ }
640
+ );
641
+
642
+ server.registerTool(
643
+ "renew_via_godaddy",
644
+ {
645
+ title: "Renew Domain via GoDaddy",
646
+ description: "Renew a domain through the GoDaddy API for 1 year.",
647
+ inputSchema: {
648
+ domain: z.string().describe("Domain name to renew (e.g. example.com)"),
649
+ },
650
+ },
651
+ async ({ domain }) => {
652
+ try {
653
+ const result = await godaddyRenewDomain(domain);
654
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
655
+ } catch (error: unknown) {
656
+ return {
657
+ content: [{ type: "text", text: `Renewal failed: ${error instanceof Error ? error.message : String(error)}` }],
658
+ isError: true,
659
+ };
660
+ }
661
+ }
662
+ );
663
+
664
+ // --- Unified Provider Tools ---
665
+
666
+ server.registerTool(
667
+ "sync_all_providers",
668
+ {
669
+ title: "Sync All Providers",
670
+ description: "Sync domains from all configured registrar providers (Namecheap, GoDaddy) to local database.",
671
+ inputSchema: {},
672
+ },
673
+ async () => {
674
+ try {
675
+ const result = await syncAll({
676
+ getDomainByName,
677
+ createDomain,
678
+ updateDomain,
679
+ });
680
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
681
+ } catch (error: unknown) {
682
+ return {
683
+ content: [{ type: "text", text: `Sync failed: ${error instanceof Error ? error.message : String(error)}` }],
684
+ isError: true,
685
+ };
686
+ }
687
+ }
688
+ );
689
+
690
+ server.registerTool(
691
+ "list_providers",
692
+ {
693
+ title: "List Providers",
694
+ description: "Show which registrar providers are configured (have API keys set).",
695
+ inputSchema: {},
696
+ },
697
+ async () => {
698
+ const providers = getAvailableProviders();
699
+ return { content: [{ type: "text", text: JSON.stringify(providers, null, 2) }] };
700
+ }
701
+ );
702
+
703
+ // --- Brandsight Tools ---
704
+
705
+ server.registerTool(
706
+ "monitor_brand",
707
+ {
708
+ title: "Monitor Brand",
709
+ description: "Monitor a brand name for new domain registrations that are similar (typosquats, homoglyphs, keyword matches). Uses Brandsight API.",
710
+ inputSchema: {
711
+ brand: z.string().describe("Brand name to monitor"),
712
+ },
713
+ },
714
+ async ({ brand }) => {
715
+ try {
716
+ const result = await monitorBrand(brand);
717
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
718
+ } catch (error: unknown) {
719
+ return {
720
+ content: [{ type: "text", text: `Monitor failed: ${error instanceof Error ? error.message : String(error)}` }],
721
+ isError: true,
722
+ };
723
+ }
724
+ }
725
+ );
726
+
727
+ server.registerTool(
728
+ "similar_domains",
729
+ {
730
+ title: "Similar Domains",
731
+ description: "Find typosquat/competing domains similar to the given domain. Uses Brandsight API.",
732
+ inputSchema: {
733
+ domain: z.string().describe("Domain to find similar domains for"),
734
+ },
735
+ },
736
+ async ({ domain }) => {
737
+ try {
738
+ const result = await getSimilarDomains(domain);
739
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
740
+ } catch (error: unknown) {
741
+ return {
742
+ content: [{ type: "text", text: `Similar domains check failed: ${error instanceof Error ? error.message : String(error)}` }],
743
+ isError: true,
744
+ };
745
+ }
746
+ }
747
+ );
748
+
749
+ server.registerTool(
750
+ "domain_threats",
751
+ {
752
+ title: "Domain Threats",
753
+ description: "Get a threat assessment for a domain including risk level, threats, and recommendation. Uses Brandsight API.",
754
+ inputSchema: {
755
+ domain: z.string().describe("Domain to assess threats for"),
756
+ },
757
+ },
758
+ async ({ domain }) => {
759
+ try {
760
+ const result = await getThreatAssessment(domain);
761
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
762
+ } catch (error: unknown) {
763
+ return {
764
+ content: [{ type: "text", text: `Threat assessment failed: ${error instanceof Error ? error.message : String(error)}` }],
765
+ isError: true,
766
+ };
767
+ }
768
+ }
769
+ );
770
+
526
771
  // --- Start ---
527
772
  async function main() {
528
773
  const transport = new StdioServerTransport();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/microservices",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Mini business apps for AI agents - invoices, contacts, bookkeeping and more, each with its own SQLite database",
5
5
  "type": "module",
6
6
  "bin": {