pagesight 0.1.0
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.
- package/.github/workflows/ci.yml +40 -0
- package/.releaserc.json +10 -0
- package/CLAUDE.md +52 -0
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/biome.json +14 -0
- package/brand.md +275 -0
- package/bun.lock +1239 -0
- package/lefthook.yml +8 -0
- package/package.json +38 -0
- package/src/index.ts +26 -0
- package/src/lib/auth.ts +176 -0
- package/src/lib/crux.ts +131 -0
- package/src/lib/gsc.ts +173 -0
- package/src/lib/psi.ts +90 -0
- package/src/lib/robots.ts +279 -0
- package/src/tools/crux.ts +288 -0
- package/src/tools/inspect.ts +105 -0
- package/src/tools/pagespeed.ts +189 -0
- package/src/tools/performance.ts +167 -0
- package/src/tools/robots.ts +131 -0
- package/src/tools/setup.ts +114 -0
- package/src/tools/sitemaps.ts +112 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type GscSite, type GscSitemap, getSite, getSitemap, listSitemaps, listSites } from "../lib/gsc.js";
|
|
4
|
+
|
|
5
|
+
function formatSites(sites: GscSite[]): string {
|
|
6
|
+
if (sites.length === 0) return "No Search Console properties found.";
|
|
7
|
+
|
|
8
|
+
const lines: string[] = [`=== GSC Properties (${sites.length}) ===`, ""];
|
|
9
|
+
for (const site of sites) {
|
|
10
|
+
lines.push(`${site.siteUrl} (${site.permissionLevel})`);
|
|
11
|
+
}
|
|
12
|
+
return lines.join("\n");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function formatSite(site: GscSite): string {
|
|
16
|
+
return [`=== Site: ${site.siteUrl} ===`, "", `Permission: ${site.permissionLevel}`].join("\n");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function formatSitemapDetail(sm: GscSitemap): string {
|
|
20
|
+
const lines: string[] = [`=== Sitemap: ${sm.path} ===`, ""];
|
|
21
|
+
if (sm.type) lines.push(`Type: ${sm.type}`);
|
|
22
|
+
if (sm.lastSubmitted) lines.push(`Submitted: ${sm.lastSubmitted}`);
|
|
23
|
+
if (sm.lastDownloaded) lines.push(`Downloaded: ${sm.lastDownloaded}`);
|
|
24
|
+
lines.push(`Pending: ${sm.isPending}`);
|
|
25
|
+
lines.push(`Index: ${sm.isSitemapsIndex}`);
|
|
26
|
+
if (sm.warnings) lines.push(`Warnings: ${sm.warnings}`);
|
|
27
|
+
if (sm.errors) lines.push(`Errors: ${sm.errors}`);
|
|
28
|
+
if (sm.contents && sm.contents.length > 0) {
|
|
29
|
+
lines.push("", "Contents:");
|
|
30
|
+
for (const c of sm.contents) {
|
|
31
|
+
lines.push(` ${c.type}: ${c.submitted ?? "?"} submitted, ${c.indexed ?? "?"} indexed`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return lines.join("\n");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function formatSitemaps(siteUrl: string, sitemaps: GscSitemap[]): string {
|
|
38
|
+
if (sitemaps.length === 0) return `No sitemaps found for ${siteUrl}.`;
|
|
39
|
+
|
|
40
|
+
const lines: string[] = [`=== Sitemaps: ${siteUrl} (${sitemaps.length}) ===`, ""];
|
|
41
|
+
|
|
42
|
+
for (const sm of sitemaps) {
|
|
43
|
+
lines.push(`${sm.path}`);
|
|
44
|
+
if (sm.type) lines.push(` Type: ${sm.type}`);
|
|
45
|
+
if (sm.lastSubmitted) lines.push(` Submitted: ${sm.lastSubmitted}`);
|
|
46
|
+
if (sm.lastDownloaded) lines.push(` Downloaded: ${sm.lastDownloaded}`);
|
|
47
|
+
lines.push(` Pending: ${sm.isPending}`);
|
|
48
|
+
lines.push(` Index: ${sm.isSitemapsIndex}`);
|
|
49
|
+
if (sm.warnings) lines.push(` Warnings: ${sm.warnings}`);
|
|
50
|
+
if (sm.errors) lines.push(` Errors: ${sm.errors}`);
|
|
51
|
+
if (sm.contents) {
|
|
52
|
+
for (const c of sm.contents) {
|
|
53
|
+
lines.push(` ${c.type}: ${c.submitted ?? "?"} submitted, ${c.indexed ?? "?"} indexed`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
lines.push("");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return lines.join("\n").trimEnd();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function registerSitemapsTool(server: McpServer): void {
|
|
63
|
+
server.tool(
|
|
64
|
+
"sitemaps",
|
|
65
|
+
"List Search Console properties, get site details, list sitemaps, or get details for a specific sitemap.",
|
|
66
|
+
{
|
|
67
|
+
site_url: z.string().optional().describe("GSC property URL. Omit to list all properties."),
|
|
68
|
+
sitemap_url: z.string().optional().describe("Specific sitemap URL to get details for. Requires site_url."),
|
|
69
|
+
action: z
|
|
70
|
+
.enum(["list_sites", "get_site", "list_sitemaps", "get_sitemap"])
|
|
71
|
+
.optional()
|
|
72
|
+
.describe(
|
|
73
|
+
"Action to perform. Auto-detected: omit site_url → list_sites, site_url only → list_sitemaps, site_url + sitemap_url → get_sitemap.",
|
|
74
|
+
),
|
|
75
|
+
},
|
|
76
|
+
async ({ site_url, sitemap_url, action }) => {
|
|
77
|
+
try {
|
|
78
|
+
// Auto-detect action if not specified
|
|
79
|
+
const resolvedAction = action ?? (sitemap_url ? "get_sitemap" : site_url ? "list_sitemaps" : "list_sites");
|
|
80
|
+
|
|
81
|
+
if (resolvedAction === "list_sites") {
|
|
82
|
+
const sites = await listSites();
|
|
83
|
+
return { content: [{ type: "text", text: formatSites(sites) }] };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!site_url) {
|
|
87
|
+
return { content: [{ type: "text", text: "Error: site_url is required for this action." }] };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (resolvedAction === "get_site") {
|
|
91
|
+
const site = await getSite(site_url);
|
|
92
|
+
return { content: [{ type: "text", text: formatSite(site) }] };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (resolvedAction === "get_sitemap") {
|
|
96
|
+
if (!sitemap_url) {
|
|
97
|
+
return { content: [{ type: "text", text: "Error: sitemap_url is required for get_sitemap." }] };
|
|
98
|
+
}
|
|
99
|
+
const sm = await getSitemap(site_url, sitemap_url);
|
|
100
|
+
return { content: [{ type: "text", text: formatSitemapDetail(sm) }] };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// list_sitemaps (default when site_url provided)
|
|
104
|
+
const sitemaps = await listSitemaps(site_url);
|
|
105
|
+
return { content: [{ type: "text", text: formatSitemaps(site_url, sitemaps) }] };
|
|
106
|
+
} catch (err) {
|
|
107
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
108
|
+
return { content: [{ type: "text", text: `Error: ${msg}` }] };
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
}
|