@itsaakashpatel/seo-webmaster-mcp 0.0.0-stage → 1.1.1

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.
Files changed (213) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE +21 -0
  3. package/README.md +441 -2
  4. package/build/approvals/format.d.ts +29 -0
  5. package/build/approvals/format.js +88 -0
  6. package/build/approvals/gate.d.ts +23 -0
  7. package/build/approvals/gate.js +102 -0
  8. package/build/approvals/groups.d.ts +14 -0
  9. package/build/approvals/groups.js +113 -0
  10. package/build/approvals/session.d.ts +8 -0
  11. package/build/approvals/session.js +23 -0
  12. package/build/cli/args.d.ts +18 -0
  13. package/build/cli/args.js +41 -0
  14. package/build/cli/commands.d.ts +8 -0
  15. package/build/cli/commands.js +64 -0
  16. package/build/cli/engines.d.ts +1 -0
  17. package/build/cli/engines.js +6 -0
  18. package/build/cli/help.d.ts +2 -0
  19. package/build/cli/help.js +29 -0
  20. package/build/cli/install/clients.d.ts +18 -0
  21. package/build/cli/install/clients.js +46 -0
  22. package/build/cli/install/command.d.ts +21 -0
  23. package/build/cli/install/command.js +44 -0
  24. package/build/cli/install/exec.d.ts +3 -0
  25. package/build/cli/install/exec.js +14 -0
  26. package/build/cli/install/flow.d.ts +14 -0
  27. package/build/cli/install/flow.js +114 -0
  28. package/build/cli/install/json-config.d.ts +24 -0
  29. package/build/cli/install/json-config.js +70 -0
  30. package/build/cli/prompter.d.ts +21 -0
  31. package/build/cli/prompter.js +15 -0
  32. package/build/cli/run.d.ts +17 -0
  33. package/build/cli/run.js +48 -0
  34. package/build/cli/screens.d.ts +45 -0
  35. package/build/cli/screens.js +83 -0
  36. package/build/cli/setup/approvals.d.ts +2 -0
  37. package/build/cli/setup/approvals.js +59 -0
  38. package/build/cli/setup/bing.d.ts +2 -0
  39. package/build/cli/setup/bing.js +35 -0
  40. package/build/cli/setup/flow.d.ts +8 -0
  41. package/build/cli/setup/flow.js +91 -0
  42. package/build/cli/setup/google.d.ts +2 -0
  43. package/build/cli/setup/google.js +94 -0
  44. package/build/cli/setup/helpers.d.ts +13 -0
  45. package/build/cli/setup/helpers.js +38 -0
  46. package/build/cli/setup/indexnow.d.ts +3 -0
  47. package/build/cli/setup/indexnow.js +89 -0
  48. package/build/cli/setup/services.d.ts +5 -0
  49. package/build/cli/setup/services.js +62 -0
  50. package/build/cli/setup/text.d.ts +10 -0
  51. package/build/cli/setup/text.js +40 -0
  52. package/build/cli/setup/types.d.ts +35 -0
  53. package/build/cli/setup/types.js +1 -0
  54. package/build/cli/status.d.ts +14 -0
  55. package/build/cli/status.js +54 -0
  56. package/build/cli/terminal.d.ts +6 -0
  57. package/build/cli/terminal.js +134 -0
  58. package/build/config/file.d.ts +29 -0
  59. package/build/config/file.js +58 -0
  60. package/build/config/index.d.ts +24 -0
  61. package/build/config/index.js +72 -0
  62. package/build/config/paths.d.ts +11 -0
  63. package/build/config/paths.js +19 -0
  64. package/build/core/analytics.d.ts +5 -0
  65. package/build/core/analytics.js +18 -0
  66. package/build/core/constants.d.ts +9 -0
  67. package/build/core/constants.js +9 -0
  68. package/build/core/errors.d.ts +18 -0
  69. package/build/core/errors.js +53 -0
  70. package/build/core/filters.d.ts +14 -0
  71. package/build/core/filters.js +42 -0
  72. package/build/core/guards.d.ts +11 -0
  73. package/build/core/guards.js +32 -0
  74. package/build/core/http.d.ts +17 -0
  75. package/build/core/http.js +51 -0
  76. package/build/core/insights/compare.d.ts +32 -0
  77. package/build/core/insights/compare.js +56 -0
  78. package/build/core/insights/crawl.d.ts +9 -0
  79. package/build/core/insights/crawl.js +61 -0
  80. package/build/core/insights/links.d.ts +5 -0
  81. package/build/core/insights/links.js +20 -0
  82. package/build/core/insights/metrics.d.ts +8 -0
  83. package/build/core/insights/metrics.js +15 -0
  84. package/build/core/insights/opportunities.d.ts +15 -0
  85. package/build/core/insights/opportunities.js +40 -0
  86. package/build/core/insights/periods.d.ts +12 -0
  87. package/build/core/insights/periods.js +38 -0
  88. package/build/core/insights/types.d.ts +31 -0
  89. package/build/core/insights/types.js +1 -0
  90. package/build/core/markdown.d.ts +14 -0
  91. package/build/core/markdown.js +28 -0
  92. package/build/core/paging.d.ts +11 -0
  93. package/build/core/paging.js +5 -0
  94. package/build/core/provider.d.ts +15 -0
  95. package/build/core/provider.js +1 -0
  96. package/build/core/rate-limit.d.ts +8 -0
  97. package/build/core/rate-limit.js +19 -0
  98. package/build/core/registry.d.ts +11 -0
  99. package/build/core/registry.js +16 -0
  100. package/build/core/responses.d.ts +13 -0
  101. package/build/core/responses.js +9 -0
  102. package/build/core/secrets.d.ts +2 -0
  103. package/build/core/secrets.js +9 -0
  104. package/build/core/types.d.ts +137 -0
  105. package/build/core/types.js +13 -0
  106. package/build/core/untrusted.d.ts +11 -0
  107. package/build/core/untrusted.js +34 -0
  108. package/build/core/urls.d.ts +16 -0
  109. package/build/core/urls.js +80 -0
  110. package/build/core/validation.d.ts +23 -0
  111. package/build/core/validation.js +100 -0
  112. package/build/index.d.ts +2 -0
  113. package/build/index.js +30 -0
  114. package/build/providers/bing/auth.d.ts +11 -0
  115. package/build/providers/bing/auth.js +87 -0
  116. package/build/providers/bing/mappers.d.ts +18 -0
  117. package/build/providers/bing/mappers.js +87 -0
  118. package/build/providers/bing/operations.d.ts +8 -0
  119. package/build/providers/bing/operations.js +40 -0
  120. package/build/providers/bing/provider.d.ts +16 -0
  121. package/build/providers/bing/provider.js +132 -0
  122. package/build/providers/bing/records.d.ts +11 -0
  123. package/build/providers/bing/records.js +47 -0
  124. package/build/providers/bing/wire.d.ts +86 -0
  125. package/build/providers/bing/wire.js +38 -0
  126. package/build/providers/bing/writes.d.ts +9 -0
  127. package/build/providers/bing/writes.js +31 -0
  128. package/build/providers/google/auth.d.ts +13 -0
  129. package/build/providers/google/auth.js +174 -0
  130. package/build/providers/google/indexing.d.ts +14 -0
  131. package/build/providers/google/indexing.js +89 -0
  132. package/build/providers/google/mappers.d.ts +6 -0
  133. package/build/providers/google/mappers.js +96 -0
  134. package/build/providers/google/probe.d.ts +9 -0
  135. package/build/providers/google/probe.js +42 -0
  136. package/build/providers/google/provider.d.ts +15 -0
  137. package/build/providers/google/provider.js +118 -0
  138. package/build/providers/index.d.ts +4 -0
  139. package/build/providers/index.js +7 -0
  140. package/build/providers/indexnow/probe.d.ts +8 -0
  141. package/build/providers/indexnow/probe.js +17 -0
  142. package/build/providers/indexnow/provider.d.ts +21 -0
  143. package/build/providers/indexnow/provider.js +96 -0
  144. package/build/providers/insights/bing.d.ts +2 -0
  145. package/build/providers/insights/bing.js +73 -0
  146. package/build/providers/insights/google.d.ts +2 -0
  147. package/build/providers/insights/google.js +67 -0
  148. package/build/providers/insights/index.d.ts +5 -0
  149. package/build/providers/insights/index.js +15 -0
  150. package/build/providers/insights/source.d.ts +14 -0
  151. package/build/providers/insights/source.js +1 -0
  152. package/build/server.d.ts +2 -0
  153. package/build/server.js +14 -0
  154. package/build/tools/bing/catalog-crawl.d.ts +2 -0
  155. package/build/tools/bing/catalog-crawl.js +125 -0
  156. package/build/tools/bing/catalog-settings.d.ts +2 -0
  157. package/build/tools/bing/catalog-settings.js +51 -0
  158. package/build/tools/bing/catalog-site.d.ts +2 -0
  159. package/build/tools/bing/catalog-site.js +70 -0
  160. package/build/tools/bing/catalog-traffic.d.ts +2 -0
  161. package/build/tools/bing/catalog-traffic.js +88 -0
  162. package/build/tools/bing/index.d.ts +6 -0
  163. package/build/tools/bing/index.js +26 -0
  164. package/build/tools/bing/inputs.d.ts +21 -0
  165. package/build/tools/bing/inputs.js +34 -0
  166. package/build/tools/bing/read-tool.d.ts +23 -0
  167. package/build/tools/bing/read-tool.js +71 -0
  168. package/build/tools/bing/render.d.ts +8 -0
  169. package/build/tools/bing/render.js +50 -0
  170. package/build/tools/bing/write-tool.d.ts +25 -0
  171. package/build/tools/bing/write-tool.js +127 -0
  172. package/build/tools/bing/writes-settings.d.ts +2 -0
  173. package/build/tools/bing/writes-settings.js +227 -0
  174. package/build/tools/bing/writes-sites.d.ts +2 -0
  175. package/build/tools/bing/writes-sites.js +172 -0
  176. package/build/tools/engine-status.d.ts +14 -0
  177. package/build/tools/engine-status.js +81 -0
  178. package/build/tools/get-sitemap.d.ts +4 -0
  179. package/build/tools/get-sitemap.js +46 -0
  180. package/build/tools/index.d.ts +6 -0
  181. package/build/tools/index.js +43 -0
  182. package/build/tools/insights/bing-crawl-overview.d.ts +2 -0
  183. package/build/tools/insights/bing-crawl-overview.js +46 -0
  184. package/build/tools/insights/bing-link-evidence.d.ts +2 -0
  185. package/build/tools/insights/bing-link-evidence.js +65 -0
  186. package/build/tools/insights/declining-pages.d.ts +2 -0
  187. package/build/tools/insights/declining-pages.js +59 -0
  188. package/build/tools/insights/performance-overview.d.ts +2 -0
  189. package/build/tools/insights/performance-overview.js +39 -0
  190. package/build/tools/insights/report.d.ts +50 -0
  191. package/build/tools/insights/report.js +86 -0
  192. package/build/tools/insights/search-opportunities.d.ts +2 -0
  193. package/build/tools/insights/search-opportunities.js +30 -0
  194. package/build/tools/insights/shared.d.ts +44 -0
  195. package/build/tools/insights/shared.js +90 -0
  196. package/build/tools/inspect-url.d.ts +4 -0
  197. package/build/tools/inspect-url.js +104 -0
  198. package/build/tools/list-sitemaps.d.ts +4 -0
  199. package/build/tools/list-sitemaps.js +37 -0
  200. package/build/tools/list-sites.d.ts +4 -0
  201. package/build/tools/list-sites.js +56 -0
  202. package/build/tools/search-analytics.d.ts +4 -0
  203. package/build/tools/search-analytics.js +108 -0
  204. package/build/tools/shared.d.ts +29 -0
  205. package/build/tools/shared.js +63 -0
  206. package/build/tools/sitemaps.d.ts +2 -0
  207. package/build/tools/sitemaps.js +140 -0
  208. package/build/tools/submit-google.d.ts +4 -0
  209. package/build/tools/submit-google.js +68 -0
  210. package/build/tools/submit-urls.d.ts +4 -0
  211. package/build/tools/submit-urls.js +65 -0
  212. package/package.json +78 -4
  213. package/server.json +58 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ ## 1.1.1
4
+
5
+ ### Changed
6
+ - The README has a new title and intro, an npm badge, and a table that describes each Bing tool.
7
+ - The npm description and keywords help users find the package.
8
+ - The README no longer has the release and local build sections.
9
+ - The `publish` workflow no longer publishes to npm. The maintainer publishes by hand.
10
+
11
+ ## 1.1.0
12
+
13
+ ### Added
14
+ - 61 Bing tools: 35 read and 26 write. They cover the operations of the Bing Webmaster API.
15
+ - 5 insight tools: `get_performance_overview`, `find_search_opportunities`,
16
+ `find_declining_pages`, `bing_get_crawl_overview` and `bing_get_link_evidence`.
17
+
18
+ - The `setup` command. It configures Google, Bing and IndexNow with hidden key prompts, tests each key
19
+ with a read call, and saves the keys in a configuration file with mode 600.
20
+ - The `install` command. It adds the server to Claude Code, Claude Desktop or Cursor. It shows the
21
+ change first, asks for `y`, and writes a backup of a JSON file.
22
+ - The `status` command, `--help` and `--version`. A start without a command still starts the server
23
+ when stdin is not a terminal.
24
+ - A configuration file. An environment variable has priority over it.
25
+ - Approval groups: `read`, `submit`, `visibility` and `access`. Before a risky call, the server shows an
26
+ approval dialog, with the choices `once` and `session`. The user can choose "run without asking" in
27
+ `setup`. A client without dialogs runs the call, and the first risky result has a warning.
28
+ - `_meta["anthropic/requiresUserInteraction"]` on the `visibility` and `access` tools.
29
+ - `engine_status` shows whether the client supports approval dialogs and the approval choices.
30
+
31
+ ### Fixed
32
+ - Bing calls use the correct API address, and a rejected key gives a clear message.
33
+ - `list_sites` shows `Unknown` when Bing sends no role. It showed `SiteOwner`.
34
+
35
+ ### Changed
36
+ - The server lists the 61 Bing operation tools only when Bing has a key at the start. It lists 13 tools
37
+ without a key and 74 with a key. Before, it always listed all tools.
38
+ - Providers read keys through one configuration module, not from `process.env`.
39
+ - `submit_urls_google` is marked destructive, because `URL_DELETED` removes pages.
40
+ - The server removes the Bing API key from every response before it reads it.
41
+
42
+ ## 1.0.0
43
+
44
+ - First version, with 8 tools. It was not published.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aakash Patel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,442 @@
1
- # Temporary Holding Version
1
+ # SEO Webmaster MCP: Google Search Console, Bing Webmaster Tools and IndexNow MCP Server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@itsaakashpatel/seo-webmaster-mcp?logo=npm&label=npm&color=CB3837)](https://www.npmjs.com/package/@itsaakashpatel/seo-webmaster-mcp)
4
+ [![MCP](https://img.shields.io/badge/Model%20Context%20Protocol-Compatible-blue.svg)](https://modelcontextprotocol.io/)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://www.typescriptlang.org/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ `seo-webmaster-mcp` is an open-source **SEO MCP server**. It connects **Claude Desktop**, **Claude Code**, **Cursor**, **Windsurf**, **Cline**, **Zed** and other AI agents to your search data. One server covers **Google Search Console (GSC)**, the **Google Indexing API**, the **Bing Webmaster Tools API** and **IndexNow**.
9
+
10
+ Ask your AI assistant about clicks, queries and rankings, inspect URLs, check sitemaps, find declining pages, and submit URLs for indexing. You do not need to open a dashboard.
11
+
12
+ ### What you can do with this MCP server
13
+
14
+ - **Google Search Console MCP:** search analytics by query, page, country and device, URL inspection and sitemaps.
15
+ - **Bing Webmaster Tools MCP:** 61 tools for the Bing Webmaster API: traffic, crawl stats, crawl issues, backlinks, URL submission, sitemaps and site settings.
16
+ - **SEO insights for both engines:** performance overview, search opportunities (low CTR and positions 11 to 20) and declining pages.
17
+ - **Instant indexing:** IndexNow for Bing, Yandex, Seznam and Naver, plus the Google Indexing API.
18
+ - **Safe by default:** risky changes ask for your approval before they run.
19
+ - **Setup in one command:** `npx -y @itsaakashpatel/seo-webmaster-mcp setup` asks for your keys and adds the server to your AI client.
20
+
21
+ ---
22
+
23
+ ## 🚀 Quickstart: Install the SEO MCP Server in 2 Minutes
24
+
25
+ You do **not** need to configure all engines. **All engines are completely optional!**
26
+ - If you only have Google Search Console, only configure Google.
27
+ - If you only have Bing Webmaster Tools, only configure Bing.
28
+ - If you want instant indexing without API keys, you can use IndexNow.
29
+ - If you configure nothing, start the server and ask your AI: *"Check engine status"* to see step-by-step setup guides!
30
+
31
+ ### Option A: Run the setup (Recommended)
32
+
33
+ One command configures Google, Bing and IndexNow. You do not need a `.env` file.
34
+
35
+ ```bash
36
+ npx -y @itsaakashpatel/seo-webmaster-mcp setup
37
+ ```
38
+
39
+ The setup asks for each key in a hidden prompt, tests the key with a read call, and shows a summary before it writes anything. Then it offers to add the server to Claude Code, Claude Desktop or Cursor. Restart your client after the setup.
40
+
41
+ | Command | Result |
42
+ | --- | --- |
43
+ | `setup` | Sets up the engines and the approval choices. Needs a terminal. |
44
+ | `install` | Adds the server to Claude Code, Claude Desktop or Cursor. It shows the change and waits for `y`. |
45
+ | `status` | Shows the engines, the approval choices and the path of the configuration file. Never a key. |
46
+ | `serve` | Starts the MCP server. This is the default when a client starts the command. |
47
+ | `--help`, `--version` | Show the help text or the version. |
48
+
49
+ The setup saves the keys as **plain text** in `$XDG_CONFIG_HOME/seo-webmaster-mcp/config.json`, or in `~/.config/seo-webmaster-mcp/config.json` (on Windows: `%APPDATA%\seo-webmaster-mcp\config.json`). The file has mode 600 and its folder has mode 700. The setup stores the path of your Google key file, not its content. An environment variable that has a value has priority over the file. `status` shows each value that an environment variable overrides.
50
+
51
+ ### Option B: Set environment variables in the client configuration
52
+
53
+ Use this option if you do not want a configuration file. No cloning is required. Your MCP client downloads and runs the latest version automatically.
54
+
55
+ #### 1. Claude Desktop
56
+ Add to your `claude_desktop_config.json`:
57
+ - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
58
+ - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "seo-webmaster": {
64
+ "command": "npx",
65
+ "args": ["-y", "@itsaakashpatel/seo-webmaster-mcp"],
66
+ "env": {
67
+ "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/gsc-key.json",
68
+ "BING_WEBMASTER_API_KEY": "your_bing_api_key",
69
+ "INDEXNOW_KEY": "your_indexnow_key"
70
+ }
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ #### 2. Cursor
77
+ Add to `.cursor/mcp.json` (project-level) or **Cursor Settings → Features → MCP Servers**:
78
+
79
+ ```json
80
+ {
81
+ "mcpServers": {
82
+ "seo-webmaster": {
83
+ "command": "npx",
84
+ "args": ["-y", "@itsaakashpatel/seo-webmaster-mcp"],
85
+ "env": {
86
+ "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/gsc-key.json",
87
+ "BING_WEBMASTER_API_KEY": "your_bing_api_key",
88
+ "INDEXNOW_KEY": "your_indexnow_key"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ #### 3. Claude Code CLI
96
+ Run this command. Add one `--env` flag for each engine that you use.
97
+
98
+ ```bash
99
+ claude mcp add seo-webmaster \
100
+ --env BING_WEBMASTER_API_KEY=your_bing_api_key \
101
+ -- npx -y @itsaakashpatel/seo-webmaster-mcp
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 🛠️ Step-by-Step Setup Guide
107
+
108
+ ### 1. Google Search Console MCP Setup (GSC and Google Indexing API)
109
+
110
+ > [!TIP]
111
+ > Both Search Console and Indexing API use the **exact same** service account credentials.
112
+
113
+ 1. **Create a Cloud Project**: Go to [Google Cloud Console](https://console.cloud.google.com/) and create a project (e.g. `my-seo-tools`).
114
+ 2. **Enable APIs**:
115
+ - In **APIs & Services → Library**, search for **Google Search Console API** and click **Enable**.
116
+ - *(Optional for instant Google push)* Search for **Indexing API** (`indexing.googleapis.com`) and click **Enable**.
117
+ 3. **Create Service Account**:
118
+ - Go to **APIs & Services → Credentials → Create Credentials → Service Account**.
119
+ - Name it (e.g. `gsc-reader`), click **Create and Continue**, then **Done**.
120
+ 4. **Generate JSON Key File**:
121
+ - Click on the created service account email.
122
+ - Go to the **Keys** tab → **Add Key → Create new key → JSON**.
123
+ - Save the downloaded file somewhere safe on your computer (e.g., `~/.config/gcloud/gsc-key.json`).
124
+ 5. **Grant Property Access in Search Console**:
125
+ - Copy the service account's email address (e.g. `gsc-reader@my-seo-tools.iam.gserviceaccount.com`).
126
+ - Open [Google Search Console](https://search.google.com/search-console).
127
+ - Select your property → **Settings** (bottom left) → **Users and permissions** → **Add user**.
128
+ - Paste the service account email:
129
+ - For read-only search analytics: select **Restricted** or **Full**.
130
+ - If using Google Indexing API: select **Owner** (required by Google to publish indexing requests).
131
+ 6. **Give the key to the server**:
132
+ - Run `npx -y @itsaakashpatel/seo-webmaster-mcp setup` and give the path of your JSON file. Or set `GOOGLE_APPLICATION_CREDENTIALS` to the absolute path of your downloaded JSON file.
133
+ - Alternatively, you can paste the raw JSON string or base64 into `GOOGLE_SERVICE_ACCOUNT_KEY`.
134
+
135
+ ---
136
+
137
+ ### 2. Bing Webmaster Tools MCP Setup (Bing Webmaster API Key)
138
+
139
+ 1. Sign in to [Bing Webmaster Tools](https://www.bing.com/webmasters) and ensure your site is verified.
140
+ 2. Click the **Settings** gear icon (top right) → **API Access** → **API Key**.
141
+ 3. Generate an API Key and copy it.
142
+ 4. Run `npx -y @itsaakashpatel/seo-webmaster-mcp setup` and paste the key. Or set the `BING_WEBMASTER_API_KEY` environment variable in your MCP configuration.
143
+
144
+ ---
145
+
146
+ ### 3. IndexNow MCP Setup (Instant Indexing for Bing, Yandex, Seznam and Naver)
147
+
148
+ IndexNow allows search engines to instantly discover updated, new, or deleted URLs without waiting for crawlers.
149
+
150
+ 1. **Generate a Key**: Create a random 32-character hexadecimal key (or use [Bing's Key Generator](https://www.bing.com/indexnow)).
151
+ 2. **Host the Verification File**:
152
+ - Place a text file named `<your-key>.txt` containing only the key at your website root:
153
+ `https://example.com/<your-key>.txt`
154
+ - Confirm it opens in your browser and displays only the key string.
155
+ 3. **Give the key to the server**:
156
+ - Run the setup and choose IndexNow. It can create a key and write the key file for you. Or set `INDEXNOW_KEY` to your key string.
157
+ - *(Optional)* If your key file is hosted in a subfolder or custom URL, set `INDEXNOW_KEY_LOCATION` to the full URL (e.g. `https://example.com/assets/my-key.txt`).
158
+
159
+ ---
160
+
161
+ ## 🧰 Available SEO MCP Tools
162
+
163
+ | Tool | Engine | Description |
164
+ |---|:---:|---|
165
+ | [`engine_status`](#1-engine_status) | All | Check connection and configuration health across all 4 search engine providers with setup tips. |
166
+ | [`list_sites`](#2-list_sites) | Google & Bing | List all verified website properties with user permissions/roles. |
167
+ | [`search_analytics`](#3-search_analytics) | Google & Bing | Query clicks, impressions, CTR, and average position grouped by query, page, country, device, and date. |
168
+ | [`inspect_url`](#4-inspect_url) | Google & Bing | Inspect live URL index status, crawl dates, canonical tags, mobile usability, and rich results schema. |
169
+ | [`list_sitemaps`](#5-list_sitemaps) | Google & Bing | List submitted sitemaps, error/warning counts, crawl timestamps, and indexed URL breakdown. |
170
+ | [`get_sitemap`](#6-get_sitemap) | Google & Bing | Retrieve deep indexing statistics for a specific sitemap feed. |
171
+ | [`submit_urls_indexnow`](#7-submit_urls_indexnow) | IndexNow | Instantly notify Bing, Yandex, and partner engines about up to 10,000 published/updated/deleted URLs. |
172
+ | [`submit_urls_google`](#8-submit_urls_google) | Google Indexing | Push up to 200 URLs/day to Google via the Indexing API (`URL_UPDATED` or `URL_DELETED`). |
173
+
174
+ <details>
175
+ <summary><strong>Detailed Parameter Reference</strong></summary>
176
+
177
+ ### 1. `engine_status`
178
+ No parameters required.
179
+
180
+ ### 2. `list_sites`
181
+ | Parameter | Type | Required | Description |
182
+ |---|---|---|---|
183
+ | `engine` | string | No | Filter by engine: `all`, `google`, or `bing` (default: `all`) |
184
+
185
+ ### 3. `search_analytics`
186
+ | Parameter | Type | Required | Description |
187
+ |---|---|---|---|
188
+ | `siteUrl` | string | **Yes** | Site URL as verified in Search Console (e.g. `https://example.com/` or `sc-domain:example.com`) |
189
+ | `startDate` | string | **Yes** | Start date in `YYYY-MM-DD` format |
190
+ | `endDate` | string | **Yes** | End date in `YYYY-MM-DD` format |
191
+ | `engine` | string | No | Provider: `google` or `bing` (default: `google`) |
192
+ | `dimensions` | string | No | Comma-separated: `query`, `page`, `country`, `device`, `searchAppearance`, `date` (default: `query`) |
193
+ | `rowLimit` | number | No | Max rows to return (default: `100`, max: `25000`) |
194
+ | `searchType` | string | No | Vertical: `web`, `image`, `video`, `news`, `discover`, `googleNews` (default: `web`) |
195
+ | `dataState` | string | No | `all` (includes fresh data) or `final` (default: `all`) |
196
+ | `queryFilter` | string | No | Filter queries: `text` (contains), `!text`, `exact:keyword`, `!exact:keyword`, `regex:pattern`, or `!regex:pattern` ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)) |
197
+ | `pageFilter` | string | No | Filter page URLs: same syntax as `queryFilter` |
198
+ | `countryFilter` | string | No | ISO 3166-1 alpha-3 code (e.g. `USA`, `GBR`, `DEU`, `IND`) |
199
+ | `deviceFilter` | string | No | `DESKTOP`, `MOBILE`, or `TABLET` |
200
+ | `startRow` | number | No | Pagination row offset (default: `0`) |
201
+
202
+ ### 4. `inspect_url`
203
+ | Parameter | Type | Required | Description |
204
+ |---|---|---|---|
205
+ | `siteUrl` | string | **Yes** | Site URL as verified in Search Console |
206
+ | `inspectionUrl` | string | **Yes** | Fully qualified URL to inspect |
207
+ | `engine` | string | No | `google` or `bing` (default: `google`) |
208
+ | `languageCode` | string | No | Language code for localized messages (default: `en-US`) |
209
+
210
+ ### 5. `list_sitemaps`
211
+ | Parameter | Type | Required | Description |
212
+ |---|---|---|---|
213
+ | `siteUrl` | string | **Yes** | Site URL as verified in Search Console |
214
+ | `engine` | string | No | `google` or `bing` (default: `google`) |
215
+
216
+ ### 6. `get_sitemap`
217
+ | Parameter | Type | Required | Description |
218
+ |---|---|---|---|
219
+ | `siteUrl` | string | **Yes** | Site URL as verified in Search Console |
220
+ | `feedpath` | string | **Yes** | Full URL or path to the sitemap feed |
221
+ | `engine` | string | No | `google` or `bing` (default: `google`) |
222
+
223
+ ### 7. `submit_urls_indexnow`
224
+ | Parameter | Type | Required | Description |
225
+ |---|---|---|---|
226
+ | `host` | string | **Yes** | Domain name without protocol (e.g. `example.com`) |
227
+ | `urls` | string | **Yes** | Comma/newline-separated list of full URLs (or JSON array) |
228
+ | `key` | string | No | IndexNow key (optional if `INDEXNOW_KEY` env var is set) |
229
+ | `keyLocation` | string | No | Full URL to key file if hosted in custom location |
230
+
231
+ ### 8. `submit_urls_google`
232
+ | Parameter | Type | Required | Description |
233
+ |---|---|---|---|
234
+ | `urls` | string | **Yes** | Comma/newline-separated full https URLs (or JSON array). Max 200 per call |
235
+ | `type` | string | No | `URL_UPDATED` (new/changed) or `URL_DELETED` (removed). Default: `URL_UPDATED` |
236
+
237
+ > **Google Indexing API note**: Only pages containing `JobPosting` or `BroadcastEvent` (in `VideoObject`) structured data are supported by Google. Default daily quota is 200 requests.
238
+
239
+ </details>
240
+
241
+ ### SEO Insight Tools for Google Search Console and Bing
242
+
243
+ | Tool | Engine | Description |
244
+ |---|:---:|---|
245
+ | `get_performance_overview` | Google & Bing | Compare two periods: totals, and the queries and pages that changed, disappeared or appeared. |
246
+ | `find_search_opportunities` | Google & Bing | Find page-one results with a low CTR, and results at positions 11 to 20. |
247
+ | `find_declining_pages` | Google & Bing | Find pages that lost clicks, with the queries behind the loss. |
248
+ | `bing_get_crawl_overview` | Bing | Compare crawl results between two periods and group the crawl issues. |
249
+ | `bing_get_link_evidence` | Bing | Group inbound links by domain and anchor text. |
250
+
251
+ ### Bing Webmaster Tools API Tools
252
+
253
+ The 61 `bing_` operation tools cover the operations of the Bing Webmaster API. They need only `BING_WEBMASTER_API_KEY`. The full contract is in [`specs/bing-tools.md`](specs/bing-tools.md).
254
+
255
+ #### Read tools (35)
256
+
257
+ | Tool | What it does |
258
+ | --- | --- |
259
+ | `bing_get_sites` | List Bing sites with verification state and the codes that verify a site. Use list_sites for Google and Bing together. |
260
+ | `bing_get_site_roles` | List the users who have access to a site. |
261
+ | `bing_get_site_moves` | List site move requests. Bing returned HTTP 404 for this method in December 2026. |
262
+ | `bing_get_feed_details` | Get the entries of one sitemap or feed. Use get_sitemap for a short summary. |
263
+ | `bing_get_url_submission_quota` | Get the daily and monthly URL submission quota. |
264
+ | `bing_get_content_submission_quota` | Get the daily and monthly content submission quota. |
265
+ | `bing_get_fetched_urls` | List the URLs that you asked Bing to fetch. |
266
+ | `bing_get_fetched_url_details` | Get the headers and document that Bing fetched. The content is untrusted and long documents are cut. |
267
+ | `bing_get_query_stats` | Weekly clicks, impressions and position for each query. Use search_analytics for totals over a date range. |
268
+ | `bing_get_query_traffic_stats` | Daily clicks and impressions for one query. |
269
+ | `bing_get_query_page_stats` | Weekly statistics of the pages that rank for one query. |
270
+ | `bing_get_query_page_detail_stats` | Detailed statistics for one query on one page. |
271
+ | `bing_get_page_stats` | Weekly clicks, impressions and position for each page. The query field holds the page URL. |
272
+ | `bing_get_page_query_stats` | Weekly statistics of the queries for one page. |
273
+ | `bing_get_rank_and_traffic_stats` | Daily clicks and impressions for the site. |
274
+ | `bing_get_keyword` | Impressions of one keyword in a market and date range. |
275
+ | `bing_get_keyword_stats` | Weekly impressions of one keyword in a market. |
276
+ | `bing_get_related_keywords` | Keywords related to one keyword, with impressions. |
277
+ | `bing_get_crawl_stats` | Daily crawl counts, pages in the index and inbound links. |
278
+ | `bing_get_crawl_issues` | URLs that have crawl issues. |
279
+ | `bing_get_crawl_settings` | The crawl rate for each hour and the crawl boost state. |
280
+ | `bing_get_link_counts` | Pages of the site with their inbound link counts. Bing makes the result pages. |
281
+ | `bing_get_url_links` | Inbound links and anchor texts for one URL. Bing makes the result pages. |
282
+ | `bing_get_connected_pages` | Pages connected to the site. |
283
+ | `bing_get_deep_link_blocks` | Blocked deep links. |
284
+ | `bing_get_url_info` | Index data for one URL: discovery date, last crawl and size. |
285
+ | `bing_get_url_traffic_info` | Clicks and impressions for one URL. |
286
+ | `bing_get_children_url_info` | Index data for the URLs below one URL, with filters. |
287
+ | `bing_get_children_url_traffic_info` | Clicks and impressions for the URLs below one URL. |
288
+ | `bing_get_blocked_urls` | URLs that are blocked from Bing results. |
289
+ | `bing_get_page_preview_blocks` | Active page preview blocks. |
290
+ | `bing_get_country_region_settings` | Country and region targeting settings. |
291
+ | `bing_get_query_parameters` | URL query parameters that Bing handles for the site. |
292
+ | `bing_get_deep_link` | Deprecated: deep links for one URL. Bing returned HTTP 404 for this method in December 2026. |
293
+ | `bing_get_deep_link_algo_urls` | Deprecated: URLs with deep links. Bing returned HTTP 404 for this method in December 2026. |
294
+
295
+ #### Add and submit tools (8)
296
+
297
+ | Tool | What it does |
298
+ | --- | --- |
299
+ | `bing_add_site` | Add a site to the Bing account. Verify it after with bing_verify_site. |
300
+ | `bing_verify_site` | Ask Bing to verify a site. First place the code that bing_get_sites returns. |
301
+ | `bing_submit_url` | Submit one URL to Bing. Uses the daily quota. |
302
+ | `bing_submit_url_batch` | Submit up to 500 URLs to Bing. Uses the daily quota. |
303
+ | `bing_submit_content` | Submit the content of a page to Bing. Uses the daily quota. |
304
+ | `bing_submit_feed` | Submit a sitemap or feed to Bing. |
305
+ | `bing_fetch_url` | Ask Bing to fetch a URL. Read the result with bing_get_fetched_url_details. |
306
+ | `bing_add_connected_page` | Connect a page, for example a social profile, to the site. |
307
+
308
+ #### Change and remove tools (18)
309
+
310
+ These tools need `confirmSiteUrl`.
311
+
312
+ | Tool | What it does |
313
+ | --- | --- |
314
+ | `bing_add_site_role` | Give a user access to a site. This changes who controls the site. |
315
+ | `bing_remove_site` | Remove a site from the Bing account. |
316
+ | `bing_remove_site_role` | Remove the access of a user. See bing_get_site_roles first. |
317
+ | `bing_submit_site_move` | Tell Bing that a site or directory moved. This changes how Bing shows it. |
318
+ | `bing_remove_feed` | Remove a sitemap or feed from Bing. |
319
+ | `bing_update_crawl_settings` | Change the crawl rate or crawl boost. A low rate slows how Bing reads the site. |
320
+ | `bing_add_deep_link_block` | Block a deep link from Bing results. |
321
+ | `bing_remove_deep_link_block` | Remove a deep link block. |
322
+ | `bing_update_deep_link` | Deprecated: set the weight of a deep link. Bing can reject this call. |
323
+ | `bing_add_blocked_url` | Block a page or directory from Bing results. This removes content from results. |
324
+ | `bing_remove_blocked_url` | Remove a URL block. |
325
+ | `bing_add_page_preview_block` | Stop Bing from showing a preview of a page. |
326
+ | `bing_remove_page_preview_block` | Remove a page preview block. |
327
+ | `bing_add_country_region_settings` | Target a URL at a country. This changes where Bing shows it. |
328
+ | `bing_remove_country_region_settings` | Remove a country setting. |
329
+ | `bing_add_query_parameter` | Tell Bing to ignore a URL query parameter. This can change which URLs it keeps. |
330
+ | `bing_remove_query_parameter` | Remove a URL query parameter rule. |
331
+ | `bing_set_query_parameter_state` | Turn a URL query parameter rule on or off. |
332
+
333
+ The server lists the 61 `bing_` tools only when Bing has a key at the start. Without a Bing key, the server lists 13 tools. With a key, it lists 74. After you set a key, restart your client.
334
+
335
+ > [!WARNING]
336
+ > Some of these tools can remove your site from Bing, block pages or give another user access.
337
+ > - Each change or remove tool needs `confirmSiteUrl`, and your MCP client sees it as destructive.
338
+ > - Before a risky call, the server shows an approval dialog (see "Approvals").
339
+ > - Do not set your client to approve these tools automatically.
340
+ > - Search queries, link text and fetched pages come from other people. They can contain instructions that try to mislead an agent.
341
+
342
+ ### Approvals
343
+
344
+ Each tool is in one approval group. Before a risky call, the server asks you in a dialog, unless you chose "run without asking" in `setup`.
345
+
346
+ | Group | Tools | Risk |
347
+ | --- | :---: | --- |
348
+ | `read` | 46 | Reads search data of your sites. It never asks. |
349
+ | `submit` | 10 | Sends URLs, content and sitemaps to search engines, and adds sites. Uses daily quota. |
350
+ | `visibility` | 14 | Can remove pages or the whole site from search results, and slow the crawl. |
351
+ | `access` | 4 | Can remove or move a site, or give or remove the access of other people. |
352
+
353
+ - The default for `submit`, `visibility` and `access` is "ask first". Only the configuration file of your user holds this choice. No argument and no environment variable changes it.
354
+ - The dialog shows the tool, the risk, the site and the values of the call, written by the server. It shows no secret. You can accept for one call (`once`) or for the same group on the same site until the server stops (`session`). The `access` group never offers `session`.
355
+ - A decline or a cancel sends nothing. The dialog waits 10 minutes at most.
356
+ - `submit_urls_google` with `URL_DELETED` uses the rules of `visibility`.
357
+ - A client that cannot show dialogs (no form `elicitation` support) runs the call. The tool prompt of the client is then the only approval, and the first risky result of the session starts with a warning. `engine_status` shows whether your client supports dialogs. The `visibility` and `access` tools also ask Claude Code at each call through `_meta["anthropic/requiresUserInteraction"]`.
358
+ - Approvals are not a sandbox. An agent with shell access can change the configuration file. A client that approves tools automatically removes the client prompt.
359
+
360
+ A successful write means that Bing accepted the request. It does not mean that Bing applied it.
361
+
362
+ Bing returned HTTP 404 for `bing_get_site_moves`, `bing_get_deep_link` and `bing_get_deep_link_algo_urls` in December 2026.
363
+
364
+ ---
365
+
366
+ ## 💬 Example Prompts for Claude, Cursor and Other AI Agents
367
+
368
+ Once configured in Claude or Cursor, you can interact with your search data in plain English:
369
+
370
+ - *"Check search engine provider status to see what is connected."*
371
+ - *"List all my verified websites across Google and Bing."*
372
+ - *"Which pages lost Bing clicks in the last 8 weeks, and for which queries?"*
373
+ - *"Group the current Bing crawl issues for my site."*
374
+ - *"Show me the top 20 queries for my site on Google over the last 28 days."*
375
+ - *"Find pages that get high impressions but low click-through rates (CTR < 2%)."*
376
+ - *"Inspect https://example.com/blog/latest-post and tell me if it has any schema errors or mobile usability issues."*
377
+ - *"Check all submitted sitemaps for my site and report indexing health."*
378
+ - *"I just published 5 new blog posts: [URL list]. Submit them to IndexNow immediately."*
379
+ - *"Notify Google that these 2 job postings were updated via the Indexing API."*
380
+
381
+ ---
382
+
383
+ ## ❓ Troubleshooting & FAQs
384
+
385
+ ### 1. `Permission error (403): User does not have sufficient permission`
386
+ - **Cause:** The service account has not been added as a user to your property in Google Search Console.
387
+ - **Fix:** In Google Search Console, go to **Settings → Users and permissions → Add user** and paste the exact email of your service account.
388
+
389
+ ### 2. `Site URL not found`
390
+ - **Cause:** Search Console differentiates between domain properties (`sc-domain:example.com`) and URL prefix properties (`https://example.com/`).
391
+ - **Fix:** Run the `list_sites` tool first to view the exact property string format for your website.
392
+
393
+ ### 3. `Bing Webmaster API rejected the API key`
394
+ - **Cause:** Missing or invalid Bing API key (`BING_WEBMASTER_API_KEY` or the key in the configuration file).
395
+ - **Fix:** Re-generate your API key in Bing Webmaster Tools (Settings → API Access → API Key) and ensure there are no leading/trailing spaces in your config.
396
+
397
+ ### 4. The `bing_` tools are not in the tool list
398
+ - **Cause:** The server lists the 61 `bing_` tools only when Bing has a key at the start.
399
+ - **Fix:** Run the setup, or set `BING_WEBMASTER_API_KEY`. Then restart your client. `seo-webmaster-mcp status` shows whether the server finds a key.
400
+
401
+ ### 5. `The user did not approve <tool>` or `The user rejected <tool>`
402
+ - **Cause:** You declined or cancelled the approval dialog, or the dialog got no answer in 10 minutes. The server sent nothing.
403
+ - **Fix:** Ask for the call again. To skip the dialog for a group, run the setup and choose Approvals.
404
+
405
+ ### 6. `Bing URL inspection returns UNKNOWN`
406
+ - **Explanation:** Unlike Google, the Bing Webmaster Tools API does not offer URL-level live inspection. The server returns coarse crawl stats if available, and transparently marks inspection verdict as `UNKNOWN` rather than fabricating data.
407
+
408
+ ---
409
+
410
+ ## 💻 Local Development & Contributing
411
+
412
+ Contributions are welcome! Please ensure all pull requests follow the project standards.
413
+
414
+ ```bash
415
+ # Clone the repository
416
+ git clone https://github.com/itsaakashpatel/seo-webmaster-mcp.git
417
+ cd seo-webmaster-mcp
418
+
419
+ # Install dependencies
420
+ npm install
421
+
422
+ # Compile TypeScript
423
+ npm run build
424
+
425
+ # Run unit tests
426
+ npm test
427
+
428
+ # Run linter (oxlint)
429
+ npm run lint
430
+
431
+ # Check code formatting (oxfmt)
432
+ npm run format:check
433
+ ```
434
+
435
+ ### Pull Requests
436
+ When opening a pull request, please use the template located at [`.github/pull_request_template.md`](.github/pull_request_template.md) and adhere to the guidelines in [`AGENTS.md`](AGENTS.md).
437
+
438
+ ---
439
+
440
+ ## 📄 License
441
+
442
+ MIT © [Aakash Patel](https://github.com/itsaakashpatel)
@@ -0,0 +1,29 @@
1
+ import { type ApprovalGroup } from "./groups.js";
2
+ export declare const MAX_VALUE_CHARS = 200;
3
+ export declare const MAX_LISTED_ITEMS = 10;
4
+ /** One line of at most 200 characters. A cut value ends with `…`. */
5
+ export declare function cleanValue(text: string): string;
6
+ /** A list shows its count and its first 10 items. */
7
+ export declare function formatDialogValue(value: unknown): string;
8
+ /** The inputs that the dialog shows, in the order of the call. */
9
+ export declare function visibleFields(args: Readonly<Record<string, unknown>>): Array<[string, unknown]>;
10
+ export interface DialogContent {
11
+ readonly tool: string;
12
+ readonly group: ApprovalGroup;
13
+ readonly siteLabel: string;
14
+ readonly fields: ReadonlyArray<readonly [string, unknown]>;
15
+ readonly before?: Record<string, unknown>;
16
+ readonly after?: Record<string, unknown>;
17
+ }
18
+ /** The server writes all of this text. The agent adds no text of its own. */
19
+ export declare function renderDialogMessage(content: DialogContent): string;
20
+ /** The site key of a session approval: without a trailing slash, in lowercase. */
21
+ export declare function normalizeSite(siteUrl: string): string;
22
+ export interface SiteInfo {
23
+ readonly label: string;
24
+ /** Empty when the call has more than one site. Then the dialog offers no session choice. */
25
+ readonly sessionKey: string | undefined;
26
+ }
27
+ export declare function siteOfSiteUrl(siteUrl: string): SiteInfo;
28
+ /** A tool without `siteUrl` uses the host of its URLs. */
29
+ export declare function siteOfUrls(urls: readonly string[]): SiteInfo;
@@ -0,0 +1,88 @@
1
+ import { SERVER_NAME } from "../core/constants.js";
2
+ import { isRecord } from "../core/guards.js";
3
+ import { parseHttpUrl } from "../core/urls.js";
4
+ import { GROUP_RISK } from "./groups.js";
5
+ export const MAX_VALUE_CHARS = 200;
6
+ export const MAX_LISTED_ITEMS = 10;
7
+ /** Inputs that never appear in a dialog: secrets and confirmation flags. */
8
+ const HIDDEN_INPUTS = new Set([
9
+ "authenticationCode",
10
+ "key",
11
+ "confirmSiteUrl",
12
+ "confirmFullSiteRemoval",
13
+ ]);
14
+ // Control characters, line breaks, and characters that hide or reorder text. Code points are
15
+ // compared as numbers, so no invisible character appears in this file.
16
+ const UNSAFE_RANGES = [
17
+ [0x0000, 0x001f],
18
+ [0x007f, 0x009f],
19
+ [0x200b, 0x200f],
20
+ [0x2028, 0x202e],
21
+ [0x2066, 0x2069],
22
+ [0xfeff, 0xfeff],
23
+ ];
24
+ function isSafeChar(char) {
25
+ const point = char.codePointAt(0) ?? 0;
26
+ return !UNSAFE_RANGES.some(([low, high]) => point >= low && point <= high);
27
+ }
28
+ /** One line of at most 200 characters. A cut value ends with `…`. */
29
+ export function cleanValue(text) {
30
+ const clean = Array.from(text).filter(isSafeChar).join("");
31
+ return clean.length <= MAX_VALUE_CHARS ? clean : `${clean.slice(0, MAX_VALUE_CHARS - 1)}…`;
32
+ }
33
+ function formatScalar(value) {
34
+ if (typeof value === "string") {
35
+ return cleanValue(value);
36
+ }
37
+ if (value === null || value === undefined) {
38
+ return "-";
39
+ }
40
+ return cleanValue(typeof value === "object" ? JSON.stringify(value) : String(value));
41
+ }
42
+ /** A list shows its count and its first 10 items. */
43
+ export function formatDialogValue(value) {
44
+ if (!Array.isArray(value)) {
45
+ return formatScalar(value);
46
+ }
47
+ const shown = value.slice(0, MAX_LISTED_ITEMS).map(formatScalar).join(", ");
48
+ const more = value.length > MAX_LISTED_ITEMS ? `, first ${MAX_LISTED_ITEMS}` : "";
49
+ return `${value.length} items${more}: ${shown}`;
50
+ }
51
+ /** The inputs that the dialog shows, in the order of the call. */
52
+ export function visibleFields(args) {
53
+ return Object.entries(args).filter(([name, value]) => !HIDDEN_INPUTS.has(name) && value !== undefined && name !== "siteUrl");
54
+ }
55
+ function changeLines(label, values) {
56
+ if (!isRecord(values)) {
57
+ return [];
58
+ }
59
+ return [`${label}: ${formatDialogValue(values)}`];
60
+ }
61
+ /** The server writes all of this text. The agent adds no text of its own. */
62
+ export function renderDialogMessage(content) {
63
+ return [
64
+ `${SERVER_NAME} wants to run ${content.tool}`,
65
+ `Risk: ${GROUP_RISK[content.group]}`,
66
+ `Site: ${cleanValue(content.siteLabel)}`,
67
+ ...content.fields.map(([name, value]) => `${cleanValue(name)}: ${formatDialogValue(value)}`),
68
+ ...changeLines("Before", content.before),
69
+ ...changeLines("After", content.after),
70
+ ].join("\n");
71
+ }
72
+ /** The site key of a session approval: without a trailing slash, in lowercase. */
73
+ export function normalizeSite(siteUrl) {
74
+ return siteUrl.trim().replace(/\/+$/, "").toLowerCase();
75
+ }
76
+ export function siteOfSiteUrl(siteUrl) {
77
+ return { label: siteUrl, sessionKey: normalizeSite(siteUrl) };
78
+ }
79
+ /** A tool without `siteUrl` uses the host of its URLs. */
80
+ export function siteOfUrls(urls) {
81
+ const hosts = [
82
+ ...new Set(urls.flatMap((url) => parseHttpUrl(url)?.hostname.toLowerCase() ?? [])),
83
+ ];
84
+ const [only] = hosts;
85
+ return only !== undefined && hosts.length === 1
86
+ ? { label: only, sessionKey: only }
87
+ : { label: hosts.join(", ") || "unknown", sessionKey: undefined };
88
+ }
@@ -0,0 +1,23 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { ToolResult } from "../core/responses.js";
3
+ import { type DialogContent } from "./format.js";
4
+ export declare const DIALOG_TIMEOUT_MS: number;
5
+ export declare const NO_DIALOG_NOTICE = "This client cannot show approval dialogs. The server did not ask you before this change.";
6
+ export interface ApprovalRequest extends DialogContent {
7
+ /** The site of the call, in the form of a session key. Empty when there is no single site. */
8
+ readonly sessionKey: string | undefined;
9
+ readonly signal?: AbortSignal;
10
+ }
11
+ export interface ApprovalOutcome {
12
+ /** Text for the start of the result. */
13
+ readonly notice?: string;
14
+ }
15
+ /** True when the client sent the `elicitation` capability with form mode. */
16
+ export declare function clientSupportsDialogs(server: McpServer): boolean;
17
+ /**
18
+ * Decides before the server sends any request. It returns when the call may run. It throws an
19
+ * `ApprovalError` when the user declines, cancels, or does not answer in 10 minutes.
20
+ */
21
+ export declare function requireApproval(server: McpServer, request: ApprovalRequest): Promise<ApprovalOutcome>;
22
+ /** Adds the notice to the first text block of a result. */
23
+ export declare function prependNotice(result: ToolResult, outcome: ApprovalOutcome): ToolResult;