seo360-mcp 1.0.1 → 1.0.3

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 (2) hide show
  1. package/index.js +100 -25
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -5,13 +5,14 @@ import { z } from "zod";
5
5
 
6
6
  const server = new McpServer({
7
7
  name: "seo360-mcp",
8
- version: "1.0.1",
8
+ version: "1.0.3",
9
9
  });
10
10
 
11
11
  const PARAMS_DOC_URL = "https://seo360.pages.dev/dataforseo/params.json";
12
12
  const EXTENSION_STORE_URL = "https://chromewebstore.google.com/detail/seo360-dataforseo-free-no/mpphhakiifalmlkphalklimjfkhkpbmp";
13
+ const OFFICIAL_DATAFORSEO_AI_URL = "https://chat.dataforseo.com/";
13
14
 
14
- // Isolated in-memory store for imported SEO360 presets (keyed by unique task name)
15
+ // Isolated in-memory store for imported SEO360 presets (keyed by unique task name derived from `note`)
15
16
  const presetStore = new Map();
16
17
 
17
18
  // Cached parameter dictionary fetched from Cloudflare
@@ -27,12 +28,12 @@ async function getParamsDictionary() {
27
28
  return cachedParamsDict;
28
29
  }
29
30
  } catch (e) {
30
- // Ignore network errors and fall back to schema-less mode
31
+ // Ignore network errors and fall back to empty dictionary
31
32
  }
32
33
  return {};
33
34
  }
34
35
 
35
- // Strip HTML tags (e.g., <code>2840</code> -> `2840`)
36
+ // Convert <code>...</code> preset value tags into Markdown backticks `...` and strip remaining HTML tags
36
37
  function cleanHtml(str) {
37
38
  if (!str) return "";
38
39
  return String(str).replace(/<\/?code>/g, "`").replace(/<[^>]+>/g, "");
@@ -69,14 +70,19 @@ function buildDataForSeoRequestBody(paramsObj) {
69
70
  return [task];
70
71
  }
71
72
 
72
- // Format parameters alongside descriptions from the Cloudflare parameter dictionary
73
+ // Format parameters strictly using the Cloudflare parameter dictionary; point unknown params to DataForSEO Official AI
73
74
  async function formatParamsWithDescriptions(paramsObj) {
74
75
  const dict = await getParamsDictionary();
75
76
  const lines = [];
76
77
  for (const [key, val] of Object.entries(paramsObj)) {
77
78
  const displayVal = JSON.stringify(val);
78
- const doc = dict[key]?.description ? ` — ${cleanHtml(dict[key].description)}` : "";
79
- lines.push(`- **${key}**: \`${displayVal}\`${doc}`);
79
+ const entry = dict[key];
80
+ if (entry && entry.description) {
81
+ const expectedType = entry.type ? ` [${entry.type}]` : "";
82
+ lines.push(`- **${key}**${expectedType}: \`${displayVal}\` — ${cleanHtml(entry.description)}`);
83
+ } else {
84
+ lines.push(`- **${key}**: \`${displayVal}\` — *(Not listed in SEO360 dictionary; please consult DataForSEO Official AI: ${OFFICIAL_DATAFORSEO_AI_URL})*`);
85
+ }
80
86
  }
81
87
  return lines.join("\n");
82
88
  }
@@ -84,10 +90,10 @@ async function formatParamsWithDescriptions(paramsObj) {
84
90
  // Tool 1: Import SEO360 presets (supports single-endpoint or multi-endpoint JSON arrays)
85
91
  server.tool(
86
92
  "import_seo360_preset",
87
- `Import an SEO360 JSON preset exported from the SEO360 Chrome Extension (supports single or multi-endpoint JSON arrays). Automatically enriches parameters with official descriptions from the SEO360 schema dictionary, lists all configurable parameters, and asks the user which fields they want to modify. NOTE: If the user does not have an SEO360 preset or asks how to get one, provide this official Chrome Web Store link (${EXTENSION_STORE_URL}) and emphasize that NO DataForSEO account or API key is required to use the extension to browse endpoints, customize parameters, and export JSON presets (an API key is only needed later when executing live API calls via MCP).`,
93
+ `Import an authentic SEO360 JSON preset pack exported from the SEO360 Chrome Extension. Each item in the JSON array uses three exact fields: "note" (task name), "api" (specific DataForSEO v3 endpoint path), and "payload" (2D array of [key, value] parameter pairs). Enriches parameters strictly using ${PARAMS_DOC_URL} where backticked/<code> values are official preset options (for undocumented parameters, directs users to ${OFFICIAL_DATAFORSEO_AI_URL}). STRICT ANTI-HALLUCINATION RULE: NEVER invent fake example JSON structures (such as task_name, endpoint, or parameters objects) and NEVER ask users to hand-write presets. If the user does not have a preset, tell them to install the free SEO360 Chrome Extension (${EXTENSION_STORE_URL}) — NO DataForSEO account or API key is required in the extension to browse endpoints, customize parameters, and export presets.`,
88
94
  {
89
- preset_json: z.string().describe("The raw JSON array string exported from the SEO360 Chrome Extension"),
90
- prefix: z.string().optional().describe("Optional prefix to namespace imported tasks and avoid naming collisions with existing presets"),
95
+ preset_json: z.string().describe('The raw JSON array string exported from the SEO360 Chrome Extension, structured as [{"note": "Task Name", "api": "endpoint/path", "payload": [["key", value], ...]}]'),
96
+ prefix: z.string().optional().describe("Optional prefix to namespace imported task names and avoid naming collisions across multiple preset files"),
91
97
  },
92
98
  async ({ preset_json, prefix }) => {
93
99
  try {
@@ -98,19 +104,23 @@ server.tool(
98
104
  content: [
99
105
  {
100
106
  type: "text",
101
- text: `Invalid format: SEO360 preset must be a non-empty JSON array. You can visually build, customize, and export valid presets for free using the SEO360 Chrome Extension (no DataForSEO account or API key required): ${EXTENSION_STORE_URL}`,
107
+ text: `Invalid format: An SEO360 preset pack must be a non-empty JSON array exported from the SEO360 Chrome Extension.\n\nInstall the free extension to visually configure endpoints, customize parameters, and export valid presets (NO DataForSEO account or API key required): ${EXTENSION_STORE_URL}`,
102
108
  },
103
109
  ],
104
110
  };
105
111
  }
106
112
 
107
113
  const importedDetails = [];
114
+ let skippedCount = 0;
108
115
 
109
116
  for (let i = 0; i < items.length; i++) {
110
117
  const item = items[i];
111
- if (!item.api || !item.payload) continue;
118
+ if (!item || typeof item.api !== "string" || !Array.isArray(item.payload)) {
119
+ skippedCount++;
120
+ continue;
121
+ }
112
122
 
113
- const baseName = item.note ? item.note.trim() : `${item.api}_${i + 1}`;
123
+ const baseName = item.note && String(item.note).trim() ? String(item.note).trim() : `${item.api}_${i + 1}`;
114
124
  const taskName = prefix ? `[${prefix}] ${baseName}` : baseName;
115
125
  const paramsObj = payloadPairsToObject(item.payload);
116
126
 
@@ -121,14 +131,30 @@ server.tool(
121
131
  });
122
132
 
123
133
  const formattedParams = await formatParamsWithDescriptions(paramsObj);
124
- importedDetails.push(`### 📦 Task Name: 【${taskName}】\n- **Endpoint**: \`${item.api}\`\n- **Current Parameters & Descriptions**:\n${formattedParams}`);
134
+ importedDetails.push(
135
+ `### 📦 Task Name (\`note\`): 【${taskName}】\n- **Endpoint (\`api\`)**: \`${item.api}\`\n- **Parameters (\`payload\`)** *(values in backticks are available preset options)*:\n${formattedParams}`
136
+ );
137
+ }
138
+
139
+ if (importedDetails.length === 0) {
140
+ return {
141
+ isError: true,
142
+ content: [
143
+ {
144
+ type: "text",
145
+ text: `No valid SEO360 preset tasks found. Authentic SEO360 presets must contain "note" (task name), "api" (endpoint), and "payload" (array of [key, value] pairs).\n\nExport an authentic preset pack using the free SEO360 Chrome Extension (no DataForSEO API key required): ${EXTENSION_STORE_URL}`,
146
+ },
147
+ ],
148
+ };
125
149
  }
126
150
 
151
+ const skippedNotice = skippedCount > 0 ? `\n*(Skipped ${skippedCount} invalid item(s) missing \`api\` or array \`payload\`.)*` : "";
152
+
127
153
  return {
128
154
  content: [
129
155
  {
130
156
  type: "text",
131
- text: `✅ Successfully imported ${importedDetails.length} SEO360 preset task(s)! Total active tasks in memory: ${presetStore.size}.\n\n${importedDetails.join("\n\n---\n\n")}\n\nPresent these parameters clearly to the user and ask which task and parameters they would like to modify before execution.`,
157
+ text: `✅ Successfully imported ${importedDetails.length} SEO360 preset task(s)! Total active tasks in memory: ${presetStore.size}.${skippedNotice}\n\n${importedDetails.join("\n\n---\n\n")}\n\nPresent these tasks, parameter descriptions, and available preset options clearly to the user, and ask which task and parameters they would like to customize before execution.`,
132
158
  },
133
159
  ],
134
160
  };
@@ -138,7 +164,7 @@ server.tool(
138
164
  content: [
139
165
  {
140
166
  type: "text",
141
- text: `Failed to parse JSON: ${err.message}\n\nNeed a valid preset? Build, customize, and export one visually with the free SEO360 Chrome Extension (no DataForSEO API key required): ${EXTENSION_STORE_URL}`,
167
+ text: `Failed to parse JSON: ${err.message}\n\nDo not hand-write preset JSON — export a valid preset pack visually with the free SEO360 Chrome Extension (no DataForSEO API key required): ${EXTENSION_STORE_URL}`,
142
168
  },
143
169
  ],
144
170
  };
@@ -149,9 +175,9 @@ server.tool(
149
175
  // Tool 2: Update any parameters of a specific imported preset task (persists in memory)
150
176
  server.tool(
151
177
  "update_seo360_preset",
152
- "Update or add parameters for a specific imported SEO360 preset task. Strictly preserves the exact JSON data types provided (string, number, boolean, array, or object). Changes persist in memory for the current session without affecting other tasks.",
178
+ `Update or add parameters for a specific imported SEO360 preset task (identified by its task name / \`note\`). Strictly preserves exact JSON data types (string, number, boolean, array, or object). Changes persist in memory for the current session without affecting other tasks. Refer to ${PARAMS_DOC_URL} for parameter usage and preset options (wrapped in <code> tags in the raw JSON); if unknown, refer the user to ${OFFICIAL_DATAFORSEO_AI_URL}.`,
153
179
  {
154
- task_name: z.string().describe("The exact task name of the imported SEO360 preset to update"),
180
+ task_name: z.string().describe("The exact task name (`note`) of the imported SEO360 preset to update"),
155
181
  updates_json: z.string().describe('A JSON object of key-value pairs to update, e.g., {"keyword": "best laptops", "location_code": 2826, "depth": 20}'),
156
182
  },
157
183
  async ({ task_name, updates_json }) => {
@@ -170,6 +196,13 @@ server.tool(
170
196
 
171
197
  try {
172
198
  const updates = JSON.parse(updates_json);
199
+ if (!updates || typeof updates !== "object" || Array.isArray(updates)) {
200
+ return {
201
+ isError: true,
202
+ content: [{ type: "text", text: "Invalid updates_json: Must be a valid JSON object of key-value pairs." }],
203
+ };
204
+ }
205
+
173
206
  for (const [key, newVal] of Object.entries(updates)) {
174
207
  target.params[key] = newVal;
175
208
  }
@@ -179,7 +212,7 @@ server.tool(
179
212
  content: [
180
213
  {
181
214
  type: "text",
182
- text: `✅ Parameters for task 【${task_name}】 have been updated and saved!\n\nUpdated Parameter State:\n${formattedParams}`,
215
+ text: `✅ Parameters for task 【${task_name}】 (\`${target.api}\`) have been updated and saved!\n\nUpdated Parameter State:\n${formattedParams}`,
183
216
  },
184
217
  ],
185
218
  };
@@ -195,7 +228,7 @@ server.tool(
195
228
  // Tool 3: List all currently loaded preset tasks and their parameter states
196
229
  server.tool(
197
230
  "list_seo360_presets",
198
- `List all currently loaded SEO360 preset tasks in memory along with their endpoints and latest parameter configurations. If no presets are loaded, guide the user to install the free SEO360 Chrome Extension (${EXTENSION_STORE_URL}) and clearly note that NO DataForSEO account or API key is needed in the extension to configure parameters and export JSON presets (an API key is only required later when executing live requests).`,
231
+ `List all currently loaded SEO360 preset tasks in memory along with their task names (\`note\`), endpoints (\`api\`), and latest parameter configurations. If no presets are loaded, guide the user to install the free SEO360 Chrome Extension (${EXTENSION_STORE_URL}) — clearly emphasize that NO DataForSEO account or API key is required in the extension to browse endpoints, customize parameters, and export JSON presets. STRICT RULE: NEVER invent or show fake example JSON formats.`,
199
232
  {},
200
233
  async () => {
201
234
  if (presetStore.size === 0) {
@@ -203,7 +236,7 @@ server.tool(
203
236
  content: [
204
237
  {
205
238
  type: "text",
206
- text: `No SEO360 presets have been imported yet.\n\nTo get started, install the free SEO360 Chrome Extension to visually configure DataForSEO endpoints, customize parameters, and export a JSON preset (no DataForSEO account or API key required to configure and export):\n👉 ${EXTENSION_STORE_URL}`,
239
+ text: `No SEO360 presets have been imported yet.\n\nTo get started, install the free SEO360 Chrome Extension to visually configure DataForSEO endpoints, customize parameters, and export a JSON preset pack (**no DataForSEO account or API key required** to configure and export):\n👉 ${EXTENSION_STORE_URL}`,
207
240
  },
208
241
  ],
209
242
  };
@@ -212,6 +245,7 @@ server.tool(
212
245
  for (const [name, data] of presetStore.entries()) {
213
246
  list.push({
214
247
  task_name: name,
248
+ note: data.note,
215
249
  api: data.api,
216
250
  current_params: data.params,
217
251
  });
@@ -225,9 +259,9 @@ server.tool(
225
259
  // Tool 4: Execute a specific preset task against the live DataForSEO API
226
260
  server.tool(
227
261
  "execute_seo360_preset",
228
- `Execute a specific SEO360 preset task against the live DataForSEO API using its latest saved parameters and return real-time results. If no preset has been imported yet, ask the user to import one or install the free SEO360 Chrome Extension (${EXTENSION_STORE_URL}) to configure and export presets (no API key required in the extension).`,
262
+ `Execute a specific SEO360 preset task against the live DataForSEO API using its latest saved parameters and return real-time results. Requires DATAFORSEO_LOGIN and DATAFORSEO_PASSWORD environment variables. If no preset has been imported yet, ask the user to import one exported from the free SEO360 Chrome Extension (${EXTENSION_STORE_URL}) — no API key is required in the extension.`,
229
263
  {
230
- task_name: z.string().describe("The exact task name of the SEO360 preset to execute"),
264
+ task_name: z.string().describe("The exact task name (`note`) of the SEO360 preset to execute"),
231
265
  },
232
266
  async ({ task_name }) => {
233
267
  const target = presetStore.get(task_name);
@@ -248,7 +282,12 @@ server.tool(
248
282
  if (!login || !password) {
249
283
  return {
250
284
  isError: true,
251
- content: [{ type: "text", text: "Missing DATAFORSEO_LOGIN or DATAFORSEO_PASSWORD environment variables. Please configure them in your MCP server settings." }],
285
+ content: [
286
+ {
287
+ type: "text",
288
+ text: "Missing DATAFORSEO_LOGIN or DATAFORSEO_PASSWORD environment variables. Note: You do NOT need an API key to create/export presets in the SEO360 Chrome Extension, but executing live API calls via MCP requires your DataForSEO API credentials in the MCP server configuration.",
289
+ },
290
+ ],
252
291
  };
253
292
  }
254
293
 
@@ -271,7 +310,7 @@ server.tool(
271
310
  content: [
272
311
  {
273
312
  type: "text",
274
- text: `🚀 Task 【${task_name}】 executed successfully!\n- **Endpoint**: \`${url}\`\n- **Payload Sent**: \`${JSON.stringify(requestBody)}\`\n\n### API Response:\n${JSON.stringify(resultData, null, 2)}`,
313
+ text: `🚀 Task 【${task_name}】 executed successfully!\n- **Endpoint (\`api\`)**: \`${url}\`\n- **Payload Sent**: \`${JSON.stringify(requestBody)}\`\n\n### API Response:\n${JSON.stringify(resultData, null, 2)}`,
275
314
  },
276
315
  ],
277
316
  };
@@ -284,5 +323,41 @@ server.tool(
284
323
  }
285
324
  );
286
325
 
326
+ // Tool 5: Look up official parameter documentation & preset options from SEO360's live Cloudflare dictionary
327
+ server.tool(
328
+ "lookup_seo360_param",
329
+ `Look up the official type, description, default value, and available preset options (values wrapped in <code> tags in the raw JSON) for one or more DataForSEO parameters from SEO360's live parameter dictionary (${PARAMS_DOC_URL}). If a parameter is not found in the dictionary, instructs the user to consult the official DataForSEO AI at ${OFFICIAL_DATAFORSEO_AI_URL}.`,
330
+ {
331
+ param_names: z.array(z.string()).describe('List of parameter keys to look up, e.g. ["location_code", "filters", "depth"]'),
332
+ },
333
+ async ({ param_names }) => {
334
+ const dict = await getParamsDictionary();
335
+ const results = [];
336
+
337
+ for (const rawKey of param_names) {
338
+ const key = rawKey.trim();
339
+ const entry = dict[key];
340
+ if (entry) {
341
+ results.push(
342
+ `### 🔹 \`${key}\`\n- **Type**: \`${entry.type || "unknown"}\`\n- **Default**: \`${JSON.stringify(entry.default)}\`\n- **Description & Preset Options** *(backticked values are ready-to-use presets)*: ${cleanHtml(entry.description)}`
343
+ );
344
+ } else {
345
+ results.push(
346
+ `### ❓ \`${key}\`\n- Not found in the SEO360 common parameter dictionary (\`${PARAMS_DOC_URL}\`).\n- Please ask the **DataForSEO Official AI** for exact specification: 👉 ${OFFICIAL_DATAFORSEO_AI_URL}`
347
+ );
348
+ }
349
+ }
350
+
351
+ return {
352
+ content: [
353
+ {
354
+ type: "text",
355
+ text: results.join("\n\n---\n\n"),
356
+ },
357
+ ],
358
+ };
359
+ }
360
+ );
361
+
287
362
  const transport = new StdioServerTransport();
288
363
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seo360-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "SEO360 MCP: Import extension presets, customize parameters, and call DataForSEO APIs with zero hallucination.",
5
5
  "homepage": "https://seo360.pages.dev",
6
6
  "type": "module",