@microlink/mcp 2.3.0 → 2.4.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/README.md +2 -2
- package/package.json +2 -2
- package/src/microlink-client.js +59 -4
- package/src/schemas.js +28 -5
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ Each tool is a thin wrapper over a [`microlink.io`](https://github.com/microlink
|
|
|
161
161
|
### Response shape
|
|
162
162
|
|
|
163
163
|
- Each tool returns the library's **direct result** under `structuredContent.data` (and the same value as pretty-printed JSON text). For example `microlink_markdown` → `{ data: "# Title\n..." }`, `microlink_screenshot` → `{ data: { url, type, width, height, size } }`, `microlink_links` → `{ data: ["https://...", ...] }`.
|
|
164
|
-
- On failure the tool sets MCP `isError` and returns `{ error: { message, code?, status?, statusCode?, url?, more? } }
|
|
164
|
+
- On failure the tool sets MCP `isError` and returns `{ error: { message, code?, status?, statusCode?, url?, more?, details? } }`, where `message` carries the specific cause reported by the API. Capability errors that retrying cannot fix (for example `EPROXYNEEDED` or `EINTEGRATION`) also include machine-readable `reason` (`upgrade_required`), `capability`, an `upgrade` object with the plan and pricing URL, and an agent-facing `hint` with the next step. A `429` includes `reason: "quota_exceeded"` and a free-quota `hint`.
|
|
165
165
|
|
|
166
166
|
Parameters labeled `PRO` in the official Microlink docs require a paid plan.
|
|
167
167
|
For compatibility with some MCP clients:
|
|
@@ -522,7 +522,7 @@ The `MICROLINK_API_KEY` environment variable is the recommended approach for mos
|
|
|
522
522
|
|
|
523
523
|
If an API key is present, requests are sent to `https://pro.microlink.io`; otherwise they go to `https://api.microlink.io` (free endpoint).
|
|
524
524
|
|
|
525
|
-
When the free endpoint returns `429`, this MCP adds a clear hint in the tool error message: free daily quota reached
|
|
525
|
+
When the free endpoint returns `429`, this MCP adds a clear hint in the tool error message: free daily quota reached, plus upgrade/API key guidance at [microlink.io/#pricing](https://microlink.io/#pricing).
|
|
526
526
|
|
|
527
527
|
## License
|
|
528
528
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@microlink/mcp",
|
|
3
3
|
"description": "MCP server for Microlink API",
|
|
4
4
|
"homepage": "https://github.com/microlinkhq/microlink",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.4.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js"
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
68
|
"type": "module",
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "de05659e0fe9d49ba25643efbcb9914d5332ca91"
|
|
70
70
|
}
|
package/src/microlink-client.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import createClient, { MicrolinkError } from 'microlink.io'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const UPGRADE_URL = 'https://microlink.io/#pricing'
|
|
4
|
+
|
|
5
|
+
const FREE_QUOTA_EXCEEDED_HINT = `Free daily quota reached. Extend your limit by getting an API key at ${UPGRADE_URL}.`
|
|
6
|
+
|
|
7
|
+
// Actionable guidance for capability errors that retrying cannot fix:
|
|
8
|
+
// what happened, why, and how to continue. `reason` and `capability` are
|
|
9
|
+
// machine-readable so clients can react programmatically; `hint` is the
|
|
10
|
+
// agent-facing next step.
|
|
11
|
+
const ERROR_GUIDANCE = {
|
|
12
|
+
EPROXYNEEDED: {
|
|
13
|
+
reason: 'upgrade_required',
|
|
14
|
+
capability: 'proxy',
|
|
15
|
+
hint: `The target website is behind antibot protection and needs the Microlink proxy network, included in PRO plans. The request is correct: get an API key at ${UPGRADE_URL}, pass it as \`apiKey\` (or set MICROLINK_API_KEY) and repeat the same call.`
|
|
16
|
+
},
|
|
17
|
+
EINTEGRATION: {
|
|
18
|
+
reason: 'upgrade_required',
|
|
19
|
+
capability: 'integration',
|
|
20
|
+
hint: `This capability requires a PRO plan. Get an API key at ${UPGRADE_URL}, pass it as \`apiKey\` (or set MICROLINK_API_KEY) and repeat the same call.`
|
|
21
|
+
}
|
|
22
|
+
}
|
|
5
23
|
|
|
6
24
|
// A single shared client; the per-request apiKey travels in the options bag.
|
|
7
25
|
export const client = createClient()
|
|
@@ -25,13 +43,38 @@ export function asToolResult (value) {
|
|
|
25
43
|
}
|
|
26
44
|
}
|
|
27
45
|
|
|
46
|
+
const isPlainObject = value =>
|
|
47
|
+
value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
48
|
+
|
|
49
|
+
// The API wraps some failures in a generic top-level message ("The request
|
|
50
|
+
// has been not processed…"), while the specific cause travels in `data`
|
|
51
|
+
// (e.g. `data.url`). Only then should the data-derived message lead: a
|
|
52
|
+
// specific description is the real cause and must not be hidden by
|
|
53
|
+
// auxiliary strings in `data`.
|
|
54
|
+
const GENERIC_API_MESSAGE = 'The request has been not processed.'
|
|
55
|
+
|
|
28
56
|
export function asErrorResult (error) {
|
|
29
57
|
const isMql = error instanceof MicrolinkError
|
|
30
58
|
const statusCode = isMql ? error.statusCode : undefined
|
|
59
|
+
const description = isMql ? error.description : undefined
|
|
60
|
+
|
|
61
|
+
const details = isMql && isPlainObject(error.data) ? error.data : undefined
|
|
62
|
+
const detailMessage =
|
|
63
|
+
details &&
|
|
64
|
+
Object.values(details)
|
|
65
|
+
.filter(value => typeof value === 'string')
|
|
66
|
+
.join(' ')
|
|
67
|
+
|
|
68
|
+
const isGenericDescription =
|
|
69
|
+
typeof description === 'string' &&
|
|
70
|
+
description.startsWith(GENERIC_API_MESSAGE)
|
|
31
71
|
|
|
32
72
|
const payload = {
|
|
33
73
|
message:
|
|
34
|
-
(
|
|
74
|
+
(isGenericDescription ? detailMessage : undefined) ||
|
|
75
|
+
description ||
|
|
76
|
+
error?.message ||
|
|
77
|
+
String(error)
|
|
35
78
|
}
|
|
36
79
|
|
|
37
80
|
if (isMql) {
|
|
@@ -40,9 +83,21 @@ export function asErrorResult (error) {
|
|
|
40
83
|
if (statusCode) payload.statusCode = statusCode
|
|
41
84
|
if (error.url) payload.url = error.url
|
|
42
85
|
if (error.more) payload.more = error.more
|
|
86
|
+
if (details) payload.details = details
|
|
43
87
|
}
|
|
44
88
|
|
|
45
|
-
|
|
89
|
+
const guidance = isMql && ERROR_GUIDANCE[error.code]
|
|
90
|
+
if (guidance) {
|
|
91
|
+
payload.reason = guidance.reason
|
|
92
|
+
payload.capability = guidance.capability
|
|
93
|
+
payload.hint = guidance.hint
|
|
94
|
+
payload.upgrade = { plan: 'pro', url: UPGRADE_URL }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (statusCode === 429) {
|
|
98
|
+
payload.reason = 'quota_exceeded'
|
|
99
|
+
payload.hint = FREE_QUOTA_EXCEEDED_HINT
|
|
100
|
+
}
|
|
46
101
|
|
|
47
102
|
return {
|
|
48
103
|
isError: true,
|
package/src/schemas.js
CHANGED
|
@@ -242,28 +242,51 @@ const fullShape = {
|
|
|
242
242
|
// Shared Microlink API query parameters (see microlink.io/docs/api/parameters).
|
|
243
243
|
// Product tools layer their own fields on top; these apply to any URL fetch.
|
|
244
244
|
// `data` is separate: content/collection helpers overwrite it with their field rule.
|
|
245
|
+
// PRO parameters per the Microlink API spec (https://microlink.io/openapi.json):
|
|
246
|
+
// they only take effect with an API key attached to the request.
|
|
247
|
+
const PRO = 'PRO: requires a Microlink API key (Pro plan).'
|
|
248
|
+
|
|
245
249
|
const browserSchema = {
|
|
246
250
|
adblock: booleanSchema.optional(),
|
|
247
251
|
animations: booleanSchema.optional(),
|
|
248
|
-
cacheKey: z
|
|
252
|
+
cacheKey: z
|
|
253
|
+
.string()
|
|
254
|
+
.min(1)
|
|
255
|
+
.optional()
|
|
256
|
+
.describe(`Custom cache key for the request. ${PRO}`),
|
|
249
257
|
click: stringOrStringArraySchema.optional(),
|
|
250
258
|
colorScheme: z.enum(['no-preference', 'light', 'dark']).optional(),
|
|
251
259
|
device: z.string().min(1).optional(),
|
|
252
|
-
filename: z
|
|
260
|
+
filename: z
|
|
261
|
+
.string()
|
|
262
|
+
.min(1)
|
|
263
|
+
.optional()
|
|
264
|
+
.describe(`Custom name for the generated asset. ${PRO}`),
|
|
253
265
|
filter: z.string().min(1).optional(),
|
|
254
266
|
force: booleanSchema.optional(),
|
|
255
267
|
headers: objectLikeSchema(
|
|
256
268
|
z.record(z.string(), z.union([z.string(), z.number(), booleanSchema]))
|
|
257
|
-
)
|
|
269
|
+
)
|
|
270
|
+
.optional()
|
|
271
|
+
.describe(`Custom HTTP headers sent to the target URL. ${PRO}`),
|
|
258
272
|
javascript: booleanSchema.optional(),
|
|
259
273
|
mediaType: z.enum(['screen', 'print']).optional(),
|
|
260
274
|
modules: stringOrStringArraySchema.optional(),
|
|
261
275
|
prerender: z.union([z.literal('auto'), booleanSchema]).optional(),
|
|
262
|
-
proxy: proxySchema
|
|
276
|
+
proxy: proxySchema
|
|
277
|
+
.optional()
|
|
278
|
+
.describe(
|
|
279
|
+
`Proxy rotation to bypass IP rate limits, CAPTCHAs and regional restrictions. ${PRO}`
|
|
280
|
+
),
|
|
263
281
|
retry: z.number().int().nonnegative().optional(),
|
|
264
282
|
scripts: stringOrStringArraySchema.optional(),
|
|
265
283
|
scroll: z.string().min(1).optional(),
|
|
266
|
-
staleTtl: z
|
|
284
|
+
staleTtl: z
|
|
285
|
+
.union([z.string(), z.number(), booleanSchema])
|
|
286
|
+
.optional()
|
|
287
|
+
.describe(
|
|
288
|
+
`Serve stale cached content while refreshing it in the background. ${PRO}`
|
|
289
|
+
),
|
|
267
290
|
styles: stringOrStringArraySchema.optional(),
|
|
268
291
|
timeout: stringOrNumberSchema.optional(),
|
|
269
292
|
ttl: stringOrNumberSchema.optional(),
|