submitnow-mcp 0.0.0-stage → 2.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ming_jiang
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,54 @@
1
- # Temporary Holding Version
1
+ # submitnow-mcp
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
+ Zero-dependency **Model Context Protocol (MCP)** server and CLI from [submitnow](https://www.submitnow.dev) for submitting URLs via **IndexNow** to **Bing** (powering **Microsoft Copilot** and **ChatGPT Search**), **Yandex**, **Seznam.cz**, **Naver**, and **Yep**.
4
+
5
+ - **Zero runtime dependencies** (pure Node.js built-ins, Node 20+)
6
+ - **Zero account & zero server storage**
7
+ - **SSRF-guarded** public key verification and sitemap / nested `<sitemapindex>` / `.xml.gz` fetching
8
+ - **Automatic batching** for lists over 10,000 same-host URLs + subdirectory `keyLocation` scope validation
9
+
10
+ ## Option 1: Hosted Streamable HTTP MCP (No Install)
11
+
12
+ Connect directly to the hosted stateless endpoint at `https://www.submitnow.dev/mcp`:
13
+
14
+ ```bash
15
+ claude mcp add --transport http submitnow https://www.submitnow.dev/mcp
16
+ ```
17
+
18
+ ## Option 2: Local stdio MCP via `npx` (No Hosted Rate Limits)
19
+
20
+ Add to Claude Code, Cursor, Windsurf, or Antigravity:
21
+
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "submitnow": {
26
+ "command": "npx",
27
+ "args": ["-y", "submitnow-mcp"]
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ ## Exposed MCP Tools
34
+
35
+ | Tool | Description |
36
+ | :--- | :--- |
37
+ | `indexnow_generate_key` | Generate a cryptographically random 48-character hex IndexNow key locally. |
38
+ | `indexnow_check_key` | Verify a public `<key>.txt` file for 404s, soft-404 HTML, UTF-8 BOMs, off-host redirects, and exact body match. |
39
+ | `indexnow_fetch_sitemap` | Fetch a public `sitemap.xml`, `.xml.gz`, or nested `<sitemapindex>` with optional `lastmod` day filtering (`maxAgeDays`). |
40
+ | `indexnow_submit_urls` | Validate host, protocol, and subdirectory `keyLocation` scope, then submit same-host URLs (auto-chunked in 10,000-URL batches) with optional `dryRun`. |
41
+
42
+ ## CLI Usage
43
+
44
+ ```bash
45
+ npx -y -p submitnow-mcp submitnow generate-key --write
46
+ npx -y -p submitnow-mcp submitnow check-key --host www.example.com --key "$INDEXNOW_KEY"
47
+ npx -y -p submitnow-mcp submitnow submit --sitemap https://www.example.com/sitemap.xml --lastmod-days 7 --key "$INDEXNOW_KEY" --dry-run
48
+ ```
49
+
50
+ ## Links
51
+
52
+ - Web Workbench: https://www.submitnow.dev
53
+ - Documentation: https://www.submitnow.dev/docs/integrations/cli-and-mcp
54
+ - Source Code (MIT): https://github.com/overstarry/submitnow
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env node
2
+ import fsSync from 'node:fs';
3
+ import fs from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { fetchRemoteSitemapEntries, generateSecureKey, submitIndexNowBatches, verifyRemoteKeyFile, } from "../lib/indexnow-runtime.js";
7
+ export function parseCliArgs(argv) {
8
+ const [command = 'help', ...rest] = argv;
9
+ const flags = {};
10
+ const urls = [];
11
+ let collectingUrls = false;
12
+ for (let i = 0; i < rest.length; i += 1) {
13
+ const token = rest[i];
14
+ if (token === '--urls') {
15
+ collectingUrls = true;
16
+ continue;
17
+ }
18
+ if (token.startsWith('--')) {
19
+ collectingUrls = false;
20
+ const eqIndex = token.indexOf('=');
21
+ if (eqIndex !== -1) {
22
+ flags[token.slice(2, eqIndex)] = token.slice(eqIndex + 1);
23
+ }
24
+ else {
25
+ const key = token.slice(2);
26
+ const next = rest[i + 1];
27
+ if (next && !next.startsWith('--')) {
28
+ flags[key] = next;
29
+ i += 1;
30
+ }
31
+ else {
32
+ flags[key] = true;
33
+ }
34
+ }
35
+ continue;
36
+ }
37
+ if (collectingUrls) {
38
+ urls.push(token);
39
+ }
40
+ }
41
+ return { command, flags, urls };
42
+ }
43
+ function getStringFlag(flags, name) {
44
+ const value = flags[name];
45
+ return typeof value === 'string' ? value : undefined;
46
+ }
47
+ const HELP_TEXT = `submitnow CLI — Zero-dependency IndexNow command-line tool
48
+
49
+ Usage:
50
+ node cli/submitnow.ts <command> [options]
51
+
52
+ Commands:
53
+ generate-key [--write] [--dir <path>]
54
+ Generate a 48-char hex IndexNow key (optionally write <key>.txt).
55
+
56
+ check-key --host <host> --key <key> [--key-location <url>]
57
+ Verify a public IndexNow key file with SSRF guards and full diagnostics.
58
+
59
+ fetch-sitemap --url <sitemapUrl> [--lastmod-days <n>] [--json]
60
+ Fetch a sitemap.xml, .xml.gz, or nested sitemap index and list URLs.
61
+
62
+ submit [--key <key>] [--host <host>] [--key-location <url>]
63
+ [--endpoint indexnow|bing|yandex|seznam|naver|yep]
64
+ [--urls <url1> <url2>...] [--file <path>]
65
+ [--sitemap <sitemapUrl> [--lastmod-days <n>]]
66
+ [--dry-run] [--json]
67
+ Validate and submit URLs (auto-chunks lists > 10,000). Falls back to
68
+ INDEXNOW_KEY environment variable when --key is omitted.
69
+ `;
70
+ export async function runCli(argv) {
71
+ const { command, flags, urls } = parseCliArgs(argv);
72
+ if (command === 'help' || command === '--help' || command === '-h' || flags.help) {
73
+ process.stdout.write(HELP_TEXT);
74
+ return 0;
75
+ }
76
+ if (command === 'generate-key') {
77
+ const key = generateSecureKey();
78
+ if (flags.write) {
79
+ const targetDir = getStringFlag(flags, 'dir') ?? process.cwd();
80
+ const targetFile = path.join(targetDir, `${key}.txt`);
81
+ await fs.writeFile(targetFile, key, 'utf-8');
82
+ process.stdout.write(JSON.stringify({ key, file: targetFile }, null, 2) + '\n');
83
+ }
84
+ else {
85
+ process.stdout.write(`${key}\n`);
86
+ }
87
+ return 0;
88
+ }
89
+ if (command === 'check-key') {
90
+ const host = getStringFlag(flags, 'host') ?? '';
91
+ const key = getStringFlag(flags, 'key') ?? process.env.INDEXNOW_KEY ?? '';
92
+ const keyLocation = getStringFlag(flags, 'key-location');
93
+ const result = await verifyRemoteKeyFile({ host, key, keyLocation });
94
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
95
+ return result.ok && result.valid ? 0 : 1;
96
+ }
97
+ if (command === 'fetch-sitemap') {
98
+ const url = getStringFlag(flags, 'url') ?? '';
99
+ const lastmodStr = getStringFlag(flags, 'lastmod-days');
100
+ const maxAgeDays = lastmodStr ? Number(lastmodStr) : null;
101
+ const result = await fetchRemoteSitemapEntries({ url, maxAgeDays });
102
+ if (!result.ok) {
103
+ process.stderr.write(JSON.stringify(result, null, 2) + '\n');
104
+ return 1;
105
+ }
106
+ if (flags.json) {
107
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
108
+ }
109
+ else {
110
+ for (const entry of result.entries) {
111
+ process.stdout.write(`${entry.url}\n`);
112
+ }
113
+ }
114
+ return 0;
115
+ }
116
+ if (command === 'submit') {
117
+ const key = getStringFlag(flags, 'key') ?? process.env.INDEXNOW_KEY ?? '';
118
+ const host = getStringFlag(flags, 'host');
119
+ const keyLocation = getStringFlag(flags, 'key-location');
120
+ const endpointId = getStringFlag(flags, 'endpoint');
121
+ const filePath = getStringFlag(flags, 'file');
122
+ const sitemapUrl = getStringFlag(flags, 'sitemap');
123
+ const lastmodStr = getStringFlag(flags, 'lastmod-days');
124
+ const dryRun = Boolean(flags['dry-run']);
125
+ const collected = [...urls];
126
+ if (filePath) {
127
+ const content = await fs.readFile(filePath, 'utf-8');
128
+ collected.push(content);
129
+ }
130
+ if (sitemapUrl) {
131
+ const maxAgeDays = lastmodStr ? Number(lastmodStr) : null;
132
+ const fetched = await fetchRemoteSitemapEntries({
133
+ url: sitemapUrl,
134
+ maxAgeDays,
135
+ });
136
+ if (!fetched.ok) {
137
+ process.stderr.write(JSON.stringify(fetched, null, 2) + '\n');
138
+ return 1;
139
+ }
140
+ collected.push(...fetched.entries.map((entry) => entry.url));
141
+ }
142
+ const result = await submitIndexNowBatches({
143
+ urls: collected,
144
+ key,
145
+ host,
146
+ keyLocation,
147
+ endpointId,
148
+ dryRun,
149
+ });
150
+ const output = JSON.stringify(result, null, 2) + '\n';
151
+ if (result.ok) {
152
+ process.stdout.write(output);
153
+ return 0;
154
+ }
155
+ process.stderr.write(output);
156
+ return 1;
157
+ }
158
+ process.stderr.write(`Unknown command: ${command}\n\n${HELP_TEXT}`);
159
+ return 1;
160
+ }
161
+ function isExecutedDirectly() {
162
+ const entry = process.argv[1];
163
+ if (!entry)
164
+ return false;
165
+ try {
166
+ const resolvedEntry = fsSync.realpathSync(entry);
167
+ return import.meta.url === pathToFileURL(resolvedEntry).href;
168
+ }
169
+ catch {
170
+ return import.meta.url === pathToFileURL(path.resolve(entry)).href;
171
+ }
172
+ }
173
+ if (isExecutedDirectly()) {
174
+ runCli(process.argv.slice(2))
175
+ .then((code) => {
176
+ process.exitCode = code;
177
+ })
178
+ .catch((error) => {
179
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
180
+ process.exitCode = 1;
181
+ });
182
+ }
@@ -0,0 +1,83 @@
1
+ export const INDEXNOW_ENDPOINTS = [
2
+ {
3
+ id: 'indexnow',
4
+ name: 'IndexNow API (api.indexnow.org)',
5
+ url: 'https://api.indexnow.org/indexnow',
6
+ recommended: true,
7
+ },
8
+ {
9
+ id: 'bing',
10
+ name: 'Bing (www.bing.com)',
11
+ url: 'https://www.bing.com/indexnow',
12
+ },
13
+ {
14
+ id: 'yandex',
15
+ name: 'Yandex (yandex.com)',
16
+ url: 'https://yandex.com/indexnow',
17
+ },
18
+ {
19
+ id: 'seznam',
20
+ name: 'Seznam.cz (search.seznam.cz)',
21
+ url: 'https://search.seznam.cz/indexnow',
22
+ },
23
+ {
24
+ id: 'naver',
25
+ name: 'Naver (searchadvisor.naver.com)',
26
+ url: 'https://searchadvisor.naver.com/indexnow',
27
+ },
28
+ {
29
+ id: 'yep',
30
+ name: 'Yep (indexnow.yep.com)',
31
+ url: 'https://indexnow.yep.com/indexnow',
32
+ },
33
+ ];
34
+ export const DEFAULT_ENDPOINT_ID = 'indexnow';
35
+ export function resolveIndexNowEndpoint(rawId) {
36
+ const matched = INDEXNOW_ENDPOINTS.find((item) => item.id === rawId);
37
+ return matched ?? INDEXNOW_ENDPOINTS[0];
38
+ }
39
+ export function getKeyLocationDirectoryPrefix(keyLocationUrl) {
40
+ const pathname = keyLocationUrl.pathname || '/';
41
+ const lastSlash = pathname.lastIndexOf('/');
42
+ if (lastSlash <= 0)
43
+ return '/';
44
+ return pathname.slice(0, lastSlash + 1);
45
+ }
46
+ /**
47
+ * Per IndexNow specification, a key file in a subdirectory (e.g.
48
+ * https://example.com/blog/key.txt) only authorizes URLs under that exact
49
+ * directory prefix (/blog/) on the same host and protocol.
50
+ */
51
+ export function validateKeyLocationScope(keyLocationUrl, host, urls) {
52
+ const directoryPrefix = getKeyLocationDirectoryPrefix(keyLocationUrl);
53
+ if (keyLocationUrl.hostname !== host) {
54
+ return { valid: false, reason: 'host_mismatch', directoryPrefix };
55
+ }
56
+ for (const target of urls) {
57
+ if (target.hostname !== host) {
58
+ return {
59
+ valid: false,
60
+ reason: 'host_mismatch',
61
+ directoryPrefix,
62
+ invalidUrl: target.toString(),
63
+ };
64
+ }
65
+ if (target.protocol !== keyLocationUrl.protocol) {
66
+ return {
67
+ valid: false,
68
+ reason: 'protocol_mismatch',
69
+ directoryPrefix,
70
+ invalidUrl: target.toString(),
71
+ };
72
+ }
73
+ if (directoryPrefix !== '/' && !target.pathname.startsWith(directoryPrefix)) {
74
+ return {
75
+ valid: false,
76
+ reason: 'subdirectory_mismatch',
77
+ directoryPrefix,
78
+ invalidUrl: target.toString(),
79
+ };
80
+ }
81
+ }
82
+ return { valid: true, directoryPrefix };
83
+ }