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.
@@ -0,0 +1,312 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import readline from 'node:readline';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { fetchRemoteSitemapEntries, generateSecureKey, submitIndexNowBatches, verifyRemoteKeyFile, } from "../lib/indexnow-runtime.js";
7
+ export const SUPPORTED_PROTOCOL_VERSIONS = [
8
+ '2025-06-18',
9
+ '2025-03-26',
10
+ '2024-11-05',
11
+ ];
12
+ export const DEFAULT_PROTOCOL_VERSION = '2025-03-26';
13
+ export const SERVER_INFO = {
14
+ name: 'submitnow',
15
+ version: '2.2.0',
16
+ };
17
+ export const MCP_TOOLS = [
18
+ {
19
+ name: 'indexnow_generate_key',
20
+ description: 'Generate a cryptographically random 48-character hexadecimal IndexNow ownership key locally.',
21
+ inputSchema: {
22
+ type: 'object',
23
+ properties: {},
24
+ additionalProperties: false,
25
+ },
26
+ annotations: {
27
+ title: 'Generate IndexNow Key',
28
+ readOnlyHint: true,
29
+ destructiveHint: false,
30
+ idempotentHint: false,
31
+ openWorldHint: false,
32
+ },
33
+ },
34
+ {
35
+ name: 'indexnow_check_key',
36
+ description: 'Verify a public IndexNow key file for 404s, soft-404 HTML, UTF-8 BOMs, off-host redirects, and exact body match (SSRF-guarded).',
37
+ inputSchema: {
38
+ type: 'object',
39
+ properties: {
40
+ host: {
41
+ type: 'string',
42
+ description: 'Target hostname, e.g. www.example.com',
43
+ },
44
+ key: {
45
+ type: 'string',
46
+ description: 'IndexNow key string (8–128 chars)',
47
+ },
48
+ keyLocation: {
49
+ type: 'string',
50
+ description: 'Optional custom key file URL on the same host',
51
+ },
52
+ },
53
+ required: ['host', 'key'],
54
+ additionalProperties: false,
55
+ },
56
+ annotations: {
57
+ title: 'Check IndexNow Key File',
58
+ readOnlyHint: true,
59
+ destructiveHint: false,
60
+ idempotentHint: true,
61
+ openWorldHint: true,
62
+ },
63
+ },
64
+ {
65
+ name: 'indexnow_fetch_sitemap',
66
+ description: 'Fetch a public XML sitemap, .xml.gz file, or nested sitemapindex with optional lastmod day filtering (SSRF-guarded).',
67
+ inputSchema: {
68
+ type: 'object',
69
+ properties: {
70
+ url: {
71
+ type: 'string',
72
+ description: 'Public http(s) URL to sitemap.xml or sitemap index',
73
+ },
74
+ maxAgeDays: {
75
+ type: 'number',
76
+ description: 'Optional lastmod lookback window in days (e.g. 1, 7, 30)',
77
+ },
78
+ },
79
+ required: ['url'],
80
+ additionalProperties: false,
81
+ },
82
+ annotations: {
83
+ title: 'Fetch XML Sitemap',
84
+ readOnlyHint: true,
85
+ destructiveHint: false,
86
+ idempotentHint: true,
87
+ openWorldHint: true,
88
+ },
89
+ },
90
+ {
91
+ name: 'indexnow_submit_urls',
92
+ description: 'Validate host, protocol, and subdirectory keyLocation scope, then submit same-host URLs (auto-chunked in 10,000-URL batches) to api.indexnow.org or a chosen search engine endpoint.',
93
+ inputSchema: {
94
+ type: 'object',
95
+ properties: {
96
+ urls: {
97
+ type: 'array',
98
+ items: { type: 'string' },
99
+ description: 'List of absolute http(s) URLs belonging to one host',
100
+ },
101
+ key: {
102
+ type: 'string',
103
+ description: 'IndexNow ownership key hosted on the target domain',
104
+ },
105
+ host: {
106
+ type: 'string',
107
+ description: 'Optional hostname override (inferred from urls if omitted)',
108
+ },
109
+ keyLocation: {
110
+ type: 'string',
111
+ description: 'Optional custom key file URL on the same host',
112
+ },
113
+ endpointId: {
114
+ type: 'string',
115
+ enum: ['indexnow', 'bing', 'yandex', 'seznam', 'naver', 'yep'],
116
+ description: 'IndexNow endpoint (defaults to api.indexnow.org)',
117
+ },
118
+ dryRun: {
119
+ type: 'boolean',
120
+ description: 'Validate and preview batches without sending HTTP requests',
121
+ },
122
+ },
123
+ required: ['urls', 'key'],
124
+ additionalProperties: false,
125
+ },
126
+ annotations: {
127
+ title: 'Submit URLs via IndexNow',
128
+ readOnlyHint: false,
129
+ destructiveHint: false,
130
+ idempotentHint: true,
131
+ openWorldHint: true,
132
+ },
133
+ },
134
+ ];
135
+ function negotiateProtocolVersion(requested) {
136
+ if (typeof requested === 'string' &&
137
+ SUPPORTED_PROTOCOL_VERSIONS.includes(requested)) {
138
+ return requested;
139
+ }
140
+ return DEFAULT_PROTOCOL_VERSION;
141
+ }
142
+ async function callTool(name, args) {
143
+ if (name === 'indexnow_generate_key') {
144
+ const key = generateSecureKey();
145
+ return {
146
+ content: [
147
+ {
148
+ type: 'text',
149
+ text: JSON.stringify({ key, fileName: `${key}.txt`, content: key }, null, 2),
150
+ },
151
+ ],
152
+ };
153
+ }
154
+ if (name === 'indexnow_check_key') {
155
+ const result = await verifyRemoteKeyFile({
156
+ host: String(args.host ?? ''),
157
+ key: String(args.key ?? ''),
158
+ keyLocation: typeof args.keyLocation === 'string' ? args.keyLocation : undefined,
159
+ });
160
+ return {
161
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
162
+ isError: !result.ok,
163
+ };
164
+ }
165
+ if (name === 'indexnow_fetch_sitemap') {
166
+ const result = await fetchRemoteSitemapEntries({
167
+ url: String(args.url ?? ''),
168
+ maxAgeDays: typeof args.maxAgeDays === 'number' ? args.maxAgeDays : undefined,
169
+ });
170
+ return {
171
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
172
+ isError: !result.ok,
173
+ };
174
+ }
175
+ if (name === 'indexnow_submit_urls') {
176
+ const urls = Array.isArray(args.urls)
177
+ ? args.urls.map((u) => String(u))
178
+ : [];
179
+ const result = await submitIndexNowBatches({
180
+ urls,
181
+ key: String(args.key ?? ''),
182
+ host: typeof args.host === 'string' ? args.host : undefined,
183
+ keyLocation: typeof args.keyLocation === 'string' ? args.keyLocation : undefined,
184
+ endpointId: typeof args.endpointId === 'string' ? args.endpointId : undefined,
185
+ dryRun: Boolean(args.dryRun),
186
+ });
187
+ return {
188
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
189
+ isError: !result.ok,
190
+ };
191
+ }
192
+ return {
193
+ content: [
194
+ {
195
+ type: 'text',
196
+ text: JSON.stringify({ ok: false, error: `Unknown tool: ${name}` }),
197
+ },
198
+ ],
199
+ isError: true,
200
+ };
201
+ }
202
+ /**
203
+ * Handles one JSON-RPC 2.0 request. Returns null for notifications (requests
204
+ * without an `id`), which must not produce a response on stdio or return HTTP 202.
205
+ */
206
+ export async function handleJsonRpcMessage(message) {
207
+ const hasId = message.id !== undefined;
208
+ const id = message.id ?? null;
209
+ if (message.method.startsWith('notifications/') && !hasId) {
210
+ return null;
211
+ }
212
+ if (message.method === 'initialize') {
213
+ const protocolVersion = negotiateProtocolVersion(message.params?.protocolVersion);
214
+ return {
215
+ jsonrpc: '2.0',
216
+ id,
217
+ result: {
218
+ protocolVersion,
219
+ capabilities: { tools: {} },
220
+ serverInfo: SERVER_INFO,
221
+ },
222
+ };
223
+ }
224
+ if (message.method === 'ping') {
225
+ return { jsonrpc: '2.0', id, result: {} };
226
+ }
227
+ if (message.method === 'tools/list') {
228
+ return {
229
+ jsonrpc: '2.0',
230
+ id,
231
+ result: { tools: MCP_TOOLS },
232
+ };
233
+ }
234
+ if (message.method === 'tools/call') {
235
+ const params = message.params ?? {};
236
+ const toolName = typeof params.name === 'string' ? params.name : '';
237
+ const toolArgs = params.arguments && typeof params.arguments === 'object'
238
+ ? params.arguments
239
+ : {};
240
+ const result = await callTool(toolName, toolArgs);
241
+ return { jsonrpc: '2.0', id, result };
242
+ }
243
+ if (!hasId) {
244
+ return null;
245
+ }
246
+ return {
247
+ jsonrpc: '2.0',
248
+ id,
249
+ error: {
250
+ code: -32601,
251
+ message: `Method not found: ${message.method}`,
252
+ },
253
+ };
254
+ }
255
+ function isExecutedDirectly() {
256
+ const entry = process.argv[1];
257
+ if (!entry)
258
+ return false;
259
+ try {
260
+ const resolvedEntry = fs.realpathSync(entry);
261
+ return import.meta.url === pathToFileURL(resolvedEntry).href;
262
+ }
263
+ catch {
264
+ return import.meta.url === pathToFileURL(path.resolve(entry)).href;
265
+ }
266
+ }
267
+ function startStdioServer() {
268
+ const rl = readline.createInterface({
269
+ input: process.stdin,
270
+ crlfDelay: Infinity,
271
+ });
272
+ rl.on('line', (line) => {
273
+ const trimmed = line.trim();
274
+ if (!trimmed)
275
+ return;
276
+ let parsed;
277
+ try {
278
+ parsed = JSON.parse(trimmed);
279
+ }
280
+ catch {
281
+ const parseError = {
282
+ jsonrpc: '2.0',
283
+ id: null,
284
+ error: { code: -32700, message: 'Parse error' },
285
+ };
286
+ process.stdout.write(`${JSON.stringify(parseError)}\n`);
287
+ return;
288
+ }
289
+ void handleJsonRpcMessage(parsed)
290
+ .then((response) => {
291
+ if (response) {
292
+ process.stdout.write(`${JSON.stringify(response)}\n`);
293
+ }
294
+ })
295
+ .catch((error) => {
296
+ if (parsed.id !== undefined) {
297
+ const internalError = {
298
+ jsonrpc: '2.0',
299
+ id: parsed.id,
300
+ error: {
301
+ code: -32603,
302
+ message: error instanceof Error ? error.message : 'Internal server error',
303
+ },
304
+ };
305
+ process.stdout.write(`${JSON.stringify(internalError)}\n`);
306
+ }
307
+ });
308
+ });
309
+ }
310
+ if (isExecutedDirectly()) {
311
+ startStdioServer();
312
+ }
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "submitnow-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.2.0",
4
+ "description": "Zero-dependency IndexNow & AI Search (Bing, ChatGPT Search, Copilot) MCP server and CLI from submitnow.dev",
5
+ "mcpName": "io.github.overstarry/submitnow",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "homepage": "https://www.submitnow.dev",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/overstarry/submitnow.git",
12
+ "directory": "packages/mcp"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/overstarry/submitnow/issues"
16
+ },
17
+ "keywords": [
18
+ "mcp",
19
+ "model-context-protocol",
20
+ "mcp-server",
21
+ "indexnow",
22
+ "bing",
23
+ "chatgpt-search",
24
+ "copilot",
25
+ "seo",
26
+ "sitemap",
27
+ "submitnow"
28
+ ],
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
32
+ "bin": {
33
+ "submitnow-mcp": "./dist/mcp/server.js",
34
+ "submitnow": "./dist/cli/submitnow.js"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "LICENSE"
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "registry": "https://registry.npmjs.org/"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc -p tsconfig.json && node -e \"const fs=require('node:fs');for(const f of ['dist/mcp/server.js','dist/cli/submitnow.js'])fs.chmodSync(f,0o755);\""
47
+ }
48
+ }