indexnow_generate_key
Generate an API key and verification file for submitting URLs to search engines via IndexNow. Host the file at your domain root to enable instant indexing.
Instructions
Generate an IndexNow API key and the verification file content. You need to host this file at your domain root.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| custom_key | No | Custom API key (optional — a UUID will be generated if not provided) |
Implementation Reference
- src/index.ts:394-413 (handler)The handler for indexnow_generate_key which generates a UUID (or uses custom_key), generates the file content, and formats the output instructions.
async ({ custom_key }) => { const key = custom_key || crypto.randomUUID(); const fileContent = generateApiKeyFile(key); let output = `## IndexNow API Key Generated\n\n`; output += `**Your API Key:** \`${key}\`\n\n`; output += `### Setup Instructions\n\n`; output += `1. Create a file named \`${key}.txt\` in your website's root directory\n`; output += `2. The file should contain only: \`${fileContent}\`\n`; output += `3. Verify it's accessible at: \`https://yourdomain.com/${key}.txt\`\n\n`; output += `### File Content\n\`\`\`\n${fileContent}\n\`\`\`\n\n`; output += `### Quick Setup Commands\n\`\`\`bash\n`; output += `# For static sites\necho "${key}" > public/${key}.txt\n\n`; output += `# For Next.js\necho "${key}" > public/${key}.txt\n\n`; output += `# For WordPress\necho "${key}" > ${key}.txt\n`; output += `# Upload to your WordPress root directory\n\`\`\`\n\n`; output += `### Supported Search Engines\n`; output += `- **Bing** (bing.com)\n`; output += `- **Yandex** (yandex.com)\n`; output += `- **Naver** (naver.com)\n`; - src/index.ts:387-413 (registration)Registration of the indexnow_generate_key tool.
// Tool: Generate IndexNow API key and verification file server.tool( "indexnow_generate_key", "Generate an IndexNow API key and the verification file content. You need to host this file at your domain root.", { custom_key: z.string().optional().describe("Custom API key (optional — a UUID will be generated if not provided)"), }, async ({ custom_key }) => { const key = custom_key || crypto.randomUUID(); const fileContent = generateApiKeyFile(key); let output = `## IndexNow API Key Generated\n\n`; output += `**Your API Key:** \`${key}\`\n\n`; output += `### Setup Instructions\n\n`; output += `1. Create a file named \`${key}.txt\` in your website's root directory\n`; output += `2. The file should contain only: \`${fileContent}\`\n`; output += `3. Verify it's accessible at: \`https://yourdomain.com/${key}.txt\`\n\n`; output += `### File Content\n\`\`\`\n${fileContent}\n\`\`\`\n\n`; output += `### Quick Setup Commands\n\`\`\`bash\n`; output += `# For static sites\necho "${key}" > public/${key}.txt\n\n`; output += `# For Next.js\necho "${key}" > public/${key}.txt\n\n`; output += `# For WordPress\necho "${key}" > ${key}.txt\n`; output += `# Upload to your WordPress root directory\n\`\`\`\n\n`; output += `### Supported Search Engines\n`; output += `- **Bing** (bing.com)\n`; output += `- **Yandex** (yandex.com)\n`; output += `- **Naver** (naver.com)\n`; - src/index.ts:189-191 (helper)Helper function to generate the API key file content.
function generateApiKeyFile(apiKey: string): string { return apiKey; }