1- import type { AccountGetParams } from 'cloudflare/resources/accounts/accounts.mjs'
2- import type { ReportGetParams } from 'cloudflare/resources/dns/analytics.mjs'
3- import type { ZoneGetParams } from 'cloudflare/resources/dns/settings.mjs'
4- import type { ZoneListParams } from 'cloudflare/resources/zones/zones.mjs'
51import { z } from 'zod'
62
73import { getCloudflareClient } from '@repo/mcp-common/src/cloudflare-api'
84import { getEnv } from '@repo/mcp-common/src/env'
95
6+ import type { AccountGetParams } from 'cloudflare/resources/accounts/accounts.mjs'
7+ import type { ReportGetParams } from 'cloudflare/resources/dns/analytics.mjs'
8+ import type { ZoneGetParams } from 'cloudflare/resources/dns/settings.mjs'
9+ import type { ZoneListParams } from 'cloudflare/resources/zones/zones.mjs'
1010import type { Env } from '../context'
1111import type { DNSAnalyticsMCP } from '../index'
1212
@@ -29,7 +29,7 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
2929 } ,
3030 async ( { zone, days } ) => {
3131 try {
32- const client = getCloudflareClient ( env . DEV_CLOUDFLARE_API_TOKEN )
32+ const client = getCloudflareClient ( agent . props . accessToken )
3333 const start_date = getStartDate ( days )
3434 const params : ReportGetParams = {
3535 zone_id : zone ,
@@ -77,7 +77,7 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
7777 ] ,
7878 }
7979 }
80- const client = getCloudflareClient ( env . DEV_CLOUDFLARE_API_TOKEN )
80+ const client = getCloudflareClient ( agent . props . accessToken )
8181 const params : AccountGetParams = {
8282 account_id : accountId ,
8383 }
@@ -113,7 +113,7 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
113113 } ,
114114 async ( { zone } ) => {
115115 try {
116- const client = getCloudflareClient ( env . DEV_CLOUDFLARE_API_TOKEN )
116+ const client = getCloudflareClient ( agent . props . accessToken )
117117 const params : ZoneGetParams = {
118118 zone_id : zone ,
119119 }
@@ -147,7 +147,7 @@ export function registerAnalyticTools(agent: DNSAnalyticsMCP) {
147147 'List zones under the current active account' ,
148148 async ( ) => {
149149 try {
150- const client = getCloudflareClient ( env . DEV_CLOUDFLARE_API_TOKEN )
150+ const client = getCloudflareClient ( agent . props . accessToken )
151151 const accountId = await agent . getActiveAccountId ( )
152152 if ( ! accountId ) {
153153 return {
0 commit comments