MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / registerGscOverviewTools

Function registerGscOverviewTools

packages/mcp/src/tools/gsc/overview.ts:14–67  ·  view source on GitHub ↗
(
  server: McpServer,
  context: McpAuthContext
)

Source from the content-addressed store, hash-verified

12} from '../shared';
13
14export function registerGscOverviewTools(
15 server: McpServer,
16 context: McpAuthContext
17) {
18 server.tool(
19 'gsc_get_overview',
20 'Get Google Search Console performance over time: clicks, impressions, CTR, and average position. Requires GSC to be connected for the project.',
21 {
22 projectId: projectIdSchema(context),
23 ...zDateRange,
24 interval: z
25 .enum(['day', 'week', 'month'])
26 .default('day')
27 .optional()
28 .describe('Time interval for aggregation (default: day)'),
29 },
30 async ({
31 projectId: inputProjectId,
32 startDate: sd,
33 endDate: ed,
34 interval,
35 }) =>
36 withErrorHandling(async () => {
37 const projectId = await resolveProjectId(context, inputProjectId);
38 const { startDate, endDate } = resolveDateRange(sd, ed);
39 const data = await getGscOverview(
40 projectId,
41 startDate,
42 endDate,
43 interval ?? 'day'
44 );
45 return {
46 data,
47 summary: {
48 total_clicks: data.reduce((s, r) => s + r.clicks, 0),
49 total_impressions: data.reduce((s, r) => s + r.impressions, 0),
50 avg_ctr:
51 data.length > 0
52 ? Math.round(
53 (data.reduce((s, r) => s + r.ctr, 0) / data.length) * 10_000
54 ) / 100
55 : 0,
56 avg_position:
57 data.length > 0
58 ? Math.round(
59 (data.reduce((s, r) => s + r.position, 0) / data.length) *
60 10
61 ) / 10
62 : 0,
63 },
64 };
65 })
66 );
67}

Callers 1

registerAllToolsFunction · 0.90

Calls 5

projectIdSchemaFunction · 0.90
withErrorHandlingFunction · 0.90
resolveProjectIdFunction · 0.90
resolveDateRangeFunction · 0.90
getGscOverviewFunction · 0.90

Tested by

no test coverage detected