@layervai/qurl-mcp 0.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/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/client.d.ts +278 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +156 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/audit-links.d.ts +7 -0
- package/dist/prompts/audit-links.d.ts.map +1 -0
- package/dist/prompts/audit-links.js +31 -0
- package/dist/prompts/audit-links.js.map +1 -0
- package/dist/prompts/rotate-access.d.ts +18 -0
- package/dist/prompts/rotate-access.d.ts.map +1 -0
- package/dist/prompts/rotate-access.js +41 -0
- package/dist/prompts/rotate-access.js.map +1 -0
- package/dist/prompts/secure-a-service.d.ts +38 -0
- package/dist/prompts/secure-a-service.d.ts.map +1 -0
- package/dist/prompts/secure-a-service.js +141 -0
- package/dist/prompts/secure-a-service.js.map +1 -0
- package/dist/resources/_shared.d.ts +31 -0
- package/dist/resources/_shared.d.ts.map +1 -0
- package/dist/resources/_shared.js +42 -0
- package/dist/resources/_shared.js.map +1 -0
- package/dist/resources/links.d.ts +15 -0
- package/dist/resources/links.d.ts.map +1 -0
- package/dist/resources/links.js +22 -0
- package/dist/resources/links.js.map +1 -0
- package/dist/resources/usage.d.ts +15 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +18 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/server.d.ts +37 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +58 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/_shared.d.ts +78 -0
- package/dist/tools/_shared.d.ts.map +1 -0
- package/dist/tools/_shared.js +80 -0
- package/dist/tools/_shared.js.map +1 -0
- package/dist/tools/batch-create.d.ts +426 -0
- package/dist/tools/batch-create.d.ts.map +1 -0
- package/dist/tools/batch-create.js +81 -0
- package/dist/tools/batch-create.js.map +1 -0
- package/dist/tools/create-qurl.d.ts +316 -0
- package/dist/tools/create-qurl.d.ts.map +1 -0
- package/dist/tools/create-qurl.js +106 -0
- package/dist/tools/create-qurl.js.map +1 -0
- package/dist/tools/delete-qurl.d.ts +55 -0
- package/dist/tools/delete-qurl.d.ts.map +1 -0
- package/dist/tools/delete-qurl.js +76 -0
- package/dist/tools/delete-qurl.js.map +1 -0
- package/dist/tools/extend-qurl.d.ts +238 -0
- package/dist/tools/extend-qurl.d.ts.map +1 -0
- package/dist/tools/extend-qurl.js +45 -0
- package/dist/tools/extend-qurl.js.map +1 -0
- package/dist/tools/get-qurl.d.ts +231 -0
- package/dist/tools/get-qurl.d.ts.map +1 -0
- package/dist/tools/get-qurl.js +39 -0
- package/dist/tools/get-qurl.js.map +1 -0
- package/dist/tools/list-qurls.d.ts +395 -0
- package/dist/tools/list-qurls.d.ts.map +1 -0
- package/dist/tools/list-qurls.js +72 -0
- package/dist/tools/list-qurls.js.map +1 -0
- package/dist/tools/mint-link.d.ts +384 -0
- package/dist/tools/mint-link.d.ts.map +1 -0
- package/dist/tools/mint-link.js +75 -0
- package/dist/tools/mint-link.js.map +1 -0
- package/dist/tools/output-schemas.d.ts +1261 -0
- package/dist/tools/output-schemas.d.ts.map +1 -0
- package/dist/tools/output-schemas.js +173 -0
- package/dist/tools/output-schemas.js.map +1 -0
- package/dist/tools/resolve-qurl.d.ts +72 -0
- package/dist/tools/resolve-qurl.d.ts.map +1 -0
- package/dist/tools/resolve-qurl.js +42 -0
- package/dist/tools/resolve-qurl.js.map +1 -0
- package/dist/tools/update-qurl.d.ts +330 -0
- package/dist/tools/update-qurl.d.ts.map +1 -0
- package/dist/tools/update-qurl.js +96 -0
- package/dist/tools/update-qurl.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-links.js","sourceRoot":"","sources":["../../src/prompts/audit-links.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,2GAA2G;QAC7G,OAAO,EAAE,GAAoB,EAAE;YAC7B,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE;gCACJ,iDAAiD;gCACjD,EAAE;gCACF,uDAAuD;gCACvD,kCAAkC;gCAClC,uEAAuE;gCACvE,wDAAwD;gCACxD,8DAA8D;gCAC9D,sFAAsF;gCACtF,6IAA6I;gCAC7I,oIAAoI;6BACrI,CAAC,IAAI,CAAC,IAAI,CAAC;yBACb;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { GetPromptResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
export declare const rotateAccessArgs: {
|
|
4
|
+
resource_id: z.ZodString;
|
|
5
|
+
expires_in: z.ZodOptional<z.ZodString>;
|
|
6
|
+
};
|
|
7
|
+
type RotateAccessInput = z.infer<z.ZodObject<typeof rotateAccessArgs>>;
|
|
8
|
+
export declare function rotateAccessPrompt(): {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
args: {
|
|
12
|
+
resource_id: z.ZodString;
|
|
13
|
+
expires_in: z.ZodOptional<z.ZodString>;
|
|
14
|
+
};
|
|
15
|
+
handler: (args: RotateAccessInput) => GetPromptResult;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=rotate-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotate-access.d.ts","sourceRoot":"","sources":["../../src/prompts/rotate-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,eAAO,MAAM,gBAAgB;;;CAM5B,CAAC;AAEF,KAAK,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC;AAEvE,wBAAgB,kBAAkB;;;;;;;oBAMd,iBAAiB,KAAG,eAAe;EA2BtD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const rotateAccessArgs = {
|
|
3
|
+
resource_id: z.string().describe("The resource ID of the qURL to rotate"),
|
|
4
|
+
expires_in: z
|
|
5
|
+
.string()
|
|
6
|
+
.optional()
|
|
7
|
+
.describe('New expiration duration for the replacement qURL (e.g., "24h", "7d")'),
|
|
8
|
+
};
|
|
9
|
+
export function rotateAccessPrompt() {
|
|
10
|
+
return {
|
|
11
|
+
name: "rotate-access",
|
|
12
|
+
description: "Rotate a qURL by revoking the existing link and creating a fresh one with the same target.",
|
|
13
|
+
args: rotateAccessArgs,
|
|
14
|
+
handler: (args) => {
|
|
15
|
+
const expiry = args.expires_in ?? "24h";
|
|
16
|
+
return {
|
|
17
|
+
messages: [
|
|
18
|
+
{
|
|
19
|
+
role: "user",
|
|
20
|
+
content: {
|
|
21
|
+
type: "text",
|
|
22
|
+
text: [
|
|
23
|
+
`Rotate access for qURL ${args.resource_id}. Follow these steps:`,
|
|
24
|
+
"",
|
|
25
|
+
`1. Use the get_qurl tool to fetch the current details for resource_id "${args.resource_id}".`,
|
|
26
|
+
"2. Note the target_url, tags, and description from the existing qURL — you will restore them on the new resource.",
|
|
27
|
+
`3. Use the delete_qurl tool to revoke the old qURL "${args.resource_id}".`,
|
|
28
|
+
`4. Use the create_qurl tool to create a new qURL with the same target_url, with expires_in set to "${expiry}". (tags and description live on the resource and are not accepted by create_qurl — they will be applied in the next step via update_qurl.)`,
|
|
29
|
+
"5. If the original had tags or a description, use the update_qurl tool on the new resource_id to restore them.",
|
|
30
|
+
"6. Confirm the rotation was successful and provide the new qurl_link from the create_qurl response.",
|
|
31
|
+
"",
|
|
32
|
+
"Tip: If you only need a fresh access link (not a full rotation), use the mint_link tool instead.",
|
|
33
|
+
].join("\n"),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=rotate-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotate-access.js","sourceRoot":"","sources":["../../src/prompts/rotate-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IACzE,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,sEAAsE,CAAC;CACpF,CAAC;AAIF,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,4FAA4F;QAC9F,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,CAAC,IAAuB,EAAmB,EAAE;YACpD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC;YAExC,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE;gCACJ,0BAA0B,IAAI,CAAC,WAAW,uBAAuB;gCACjE,EAAE;gCACF,0EAA0E,IAAI,CAAC,WAAW,IAAI;gCAC9F,mHAAmH;gCACnH,uDAAuD,IAAI,CAAC,WAAW,IAAI;gCAC3E,sGAAsG,MAAM,6IAA6I;gCACzP,gHAAgH;gCAChH,qGAAqG;gCACrG,EAAE;gCACF,kGAAkG;6BACnG,CAAC,IAAI,CAAC,IAAI,CAAC;yBACb;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { GetPromptResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
export declare const secureAServiceArgs: {
|
|
4
|
+
target_url: z.ZodString;
|
|
5
|
+
label: z.ZodOptional<z.ZodString>;
|
|
6
|
+
description: z.ZodOptional<z.ZodString>;
|
|
7
|
+
expires_in: z.ZodOptional<z.ZodString>;
|
|
8
|
+
one_time_use: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
9
|
+
max_sessions: z.ZodOptional<z.ZodString>;
|
|
10
|
+
session_duration: z.ZodOptional<z.ZodString>;
|
|
11
|
+
ip_allowlist: z.ZodOptional<z.ZodString>;
|
|
12
|
+
ip_denylist: z.ZodOptional<z.ZodString>;
|
|
13
|
+
geo_allowlist: z.ZodOptional<z.ZodString>;
|
|
14
|
+
geo_denylist: z.ZodOptional<z.ZodString>;
|
|
15
|
+
block_ai_agents: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
16
|
+
};
|
|
17
|
+
type SecureAServiceInput = z.infer<z.ZodObject<typeof secureAServiceArgs>>;
|
|
18
|
+
export declare function secureAServicePrompt(): {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
args: {
|
|
22
|
+
target_url: z.ZodString;
|
|
23
|
+
label: z.ZodOptional<z.ZodString>;
|
|
24
|
+
description: z.ZodOptional<z.ZodString>;
|
|
25
|
+
expires_in: z.ZodOptional<z.ZodString>;
|
|
26
|
+
one_time_use: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
27
|
+
max_sessions: z.ZodOptional<z.ZodString>;
|
|
28
|
+
session_duration: z.ZodOptional<z.ZodString>;
|
|
29
|
+
ip_allowlist: z.ZodOptional<z.ZodString>;
|
|
30
|
+
ip_denylist: z.ZodOptional<z.ZodString>;
|
|
31
|
+
geo_allowlist: z.ZodOptional<z.ZodString>;
|
|
32
|
+
geo_denylist: z.ZodOptional<z.ZodString>;
|
|
33
|
+
block_ai_agents: z.ZodOptional<z.ZodEnum<["true", "false"]>>;
|
|
34
|
+
};
|
|
35
|
+
handler: (args: SecureAServiceInput) => GetPromptResult;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=secure-a-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-a-service.d.ts","sourceRoot":"","sources":["../../src/prompts/secure-a-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;CA+C9B,CAAC;AAEF,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;AAY3E,wBAAgB,oBAAoB;;;;;;;;;;;;;;;;;oBAOhB,mBAAmB,KAAG,eAAe;EA4ExD"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const secureAServiceArgs = {
|
|
3
|
+
target_url: z.string().describe("The URL of the service to protect with qURL"),
|
|
4
|
+
label: z
|
|
5
|
+
.string()
|
|
6
|
+
.optional()
|
|
7
|
+
.describe("Human-readable label identifying who this qURL is for"),
|
|
8
|
+
description: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Human-readable description of what this service is"),
|
|
12
|
+
expires_in: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('How long the link should be valid (e.g., "1h", "24h", "7d")'),
|
|
16
|
+
one_time_use: z
|
|
17
|
+
.enum(["true", "false"])
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Whether the link should be single-use"),
|
|
20
|
+
max_sessions: z
|
|
21
|
+
.string()
|
|
22
|
+
.regex(/^[1-9]\d*$/, "Must be a positive integer")
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Maximum number of concurrent sessions (e.g., \"1\", \"5\")"),
|
|
25
|
+
session_duration: z
|
|
26
|
+
.string()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('How long access lasts after clicking (e.g., "1h")'),
|
|
29
|
+
ip_allowlist: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Comma-separated IP addresses or CIDR ranges allowed to access (e.g., \"10.0.0.0/8,192.168.1.1\")"),
|
|
33
|
+
ip_denylist: z
|
|
34
|
+
.string()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Comma-separated IP addresses or CIDR ranges to block"),
|
|
37
|
+
geo_allowlist: z
|
|
38
|
+
.string()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Comma-separated ISO 3166-1 alpha-2 country codes allowed (e.g., \"US,CA,GB\")"),
|
|
41
|
+
geo_denylist: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Comma-separated country codes to block (e.g., \"CN,RU\")"),
|
|
45
|
+
block_ai_agents: z
|
|
46
|
+
.enum(["true", "false"])
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("Block all recognized AI agents (bots, scrapers, LLM crawlers)"),
|
|
49
|
+
};
|
|
50
|
+
/** Split comma-separated string into a trimmed, non-empty array. */
|
|
51
|
+
function csvToArray(value) {
|
|
52
|
+
if (!value)
|
|
53
|
+
return undefined;
|
|
54
|
+
const parts = value
|
|
55
|
+
.split(",")
|
|
56
|
+
.map((p) => p.trim())
|
|
57
|
+
.filter((p) => p.length > 0);
|
|
58
|
+
return parts.length > 0 ? parts : undefined;
|
|
59
|
+
}
|
|
60
|
+
export function secureAServicePrompt() {
|
|
61
|
+
return {
|
|
62
|
+
name: "secure-a-service",
|
|
63
|
+
description: "Guide through creating a qURL to protect a service with appropriate security policies " +
|
|
64
|
+
"(expiration, session limits, IP/geo allowlists, AI-agent blocking).",
|
|
65
|
+
args: secureAServiceArgs,
|
|
66
|
+
handler: (args) => {
|
|
67
|
+
// Note: `description` is NOT a valid create_qurl field — it lives on the
|
|
68
|
+
// resource and must be applied via update_qurl after creation.
|
|
69
|
+
const optionalParams = [
|
|
70
|
+
["label", args.label],
|
|
71
|
+
["expires_in", args.expires_in],
|
|
72
|
+
// Use `!== undefined` rather than a truthy check so a hypothetical
|
|
73
|
+
// future change from `z.enum(["true","false"])` to `z.boolean()`
|
|
74
|
+
// can't silently swallow an explicit `false`.
|
|
75
|
+
[
|
|
76
|
+
"one_time_use",
|
|
77
|
+
args.one_time_use !== undefined ? args.one_time_use === "true" : undefined,
|
|
78
|
+
],
|
|
79
|
+
["max_sessions", args.max_sessions],
|
|
80
|
+
["session_duration", args.session_duration],
|
|
81
|
+
];
|
|
82
|
+
const paramLines = optionalParams
|
|
83
|
+
.filter(([, value]) => value !== undefined)
|
|
84
|
+
.map(([key, value]) => `- ${key}: ${value}`);
|
|
85
|
+
const ipAllow = csvToArray(args.ip_allowlist);
|
|
86
|
+
const ipDeny = csvToArray(args.ip_denylist);
|
|
87
|
+
const geoAllow = csvToArray(args.geo_allowlist);
|
|
88
|
+
const geoDeny = csvToArray(args.geo_denylist);
|
|
89
|
+
const blockAI = args.block_ai_agents === "true";
|
|
90
|
+
const hasPolicy = ipAllow !== undefined ||
|
|
91
|
+
ipDeny !== undefined ||
|
|
92
|
+
geoAllow !== undefined ||
|
|
93
|
+
geoDeny !== undefined ||
|
|
94
|
+
blockAI;
|
|
95
|
+
const policy = {};
|
|
96
|
+
if (ipAllow)
|
|
97
|
+
policy.ip_allowlist = ipAllow;
|
|
98
|
+
if (ipDeny)
|
|
99
|
+
policy.ip_denylist = ipDeny;
|
|
100
|
+
if (geoAllow)
|
|
101
|
+
policy.geo_allowlist = geoAllow;
|
|
102
|
+
if (geoDeny)
|
|
103
|
+
policy.geo_denylist = geoDeny;
|
|
104
|
+
if (blockAI)
|
|
105
|
+
policy.ai_agent_policy = { block_all: true };
|
|
106
|
+
const policyLines = hasPolicy
|
|
107
|
+
? [`- access_policy: ${JSON.stringify(policy)}`]
|
|
108
|
+
: [];
|
|
109
|
+
const descriptionFollowUp = args.description
|
|
110
|
+
? [
|
|
111
|
+
"",
|
|
112
|
+
`Then call update_qurl with the returned resource_id and description: "${args.description}".`,
|
|
113
|
+
]
|
|
114
|
+
: [];
|
|
115
|
+
const text = [
|
|
116
|
+
`Create a qURL to protect the following service: ${args.target_url}`,
|
|
117
|
+
...(args.label ? [`Label: ${args.label}`] : []),
|
|
118
|
+
...(args.description ? [`Description: ${args.description}`] : []),
|
|
119
|
+
"",
|
|
120
|
+
"Use the create_qurl tool with the following parameters:",
|
|
121
|
+
`- target_url: ${args.target_url}`,
|
|
122
|
+
...paramLines,
|
|
123
|
+
...policyLines,
|
|
124
|
+
...descriptionFollowUp,
|
|
125
|
+
"",
|
|
126
|
+
"After creating the qURL, explain the returned qurl_link and how to share it securely. " +
|
|
127
|
+
"Note that the qurl_link is ephemeral and shown only once — it should be shared immediately. " +
|
|
128
|
+
"Note the expiration time and any access restrictions that were applied.",
|
|
129
|
+
].join("\n");
|
|
130
|
+
return {
|
|
131
|
+
messages: [
|
|
132
|
+
{
|
|
133
|
+
role: "user",
|
|
134
|
+
content: { type: "text", text },
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=secure-a-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-a-service.js","sourceRoot":"","sources":["../../src/prompts/secure-a-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM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AC;YAEP,MAAM,IAAI,GAAG;gBACX,mDAAmD,IAAI,CAAC,UAAU,EAAE;gBACpE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/C,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,EAAE;gBACF,yDAAyD;gBACzD,iBAAiB,IAAI,CAAC,UAAU,EAAE;gBAClC,GAAG,UAAU;gBACb,GAAG,WAAW;gBACd,GAAG,mBAAmB;gBACtB,EAAE;gBACF,wFAAwF;oBACtF,8FAA8F;oBAC9F,yEAAyE;aAC5E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEb,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;qBAChC;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource result shape that handlers return. Kept structural so we don't
|
|
3
|
+
* take a hard dep on the MCP SDK's internal types.
|
|
4
|
+
*/
|
|
5
|
+
type ResourceResult = {
|
|
6
|
+
contents: Array<{
|
|
7
|
+
uri: string;
|
|
8
|
+
mimeType?: string;
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Wrap a resource handler so that a thrown `QURLAPIError` with
|
|
14
|
+
* `code: "missing_api_key"` is converted into a resource read whose
|
|
15
|
+
* contents carry an error JSON payload, instead of propagating as a
|
|
16
|
+
* JSON-RPC error.
|
|
17
|
+
*
|
|
18
|
+
* This mirrors `withMissingApiKeyHandler` from tools/_shared.ts and
|
|
19
|
+
* keeps the deferred-auth UX consistent across the tool and resource
|
|
20
|
+
* surfaces — a missing key surfaces the same actionable
|
|
21
|
+
* `missing_api_key` message regardless of whether the caller invoked
|
|
22
|
+
* `tools/call` or `resources/read`. MCP hosts display resource contents
|
|
23
|
+
* in their resource viewer, so the JSON payload is what the user sees.
|
|
24
|
+
*
|
|
25
|
+
* Other API errors continue to throw — they're real failures and the
|
|
26
|
+
* JSON-RPC error path carries the statusCode/code metadata the host
|
|
27
|
+
* needs to surface them.
|
|
28
|
+
*/
|
|
29
|
+
export declare function withMissingApiKeyResource(uri: string, inner: () => Promise<ResourceResult>): () => Promise<ResourceResult>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=_shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../src/resources/_shared.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,GACnC,MAAM,OAAO,CAAC,cAAc,CAAC,CAqB/B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { QURLAPIError } from "../client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wrap a resource handler so that a thrown `QURLAPIError` with
|
|
4
|
+
* `code: "missing_api_key"` is converted into a resource read whose
|
|
5
|
+
* contents carry an error JSON payload, instead of propagating as a
|
|
6
|
+
* JSON-RPC error.
|
|
7
|
+
*
|
|
8
|
+
* This mirrors `withMissingApiKeyHandler` from tools/_shared.ts and
|
|
9
|
+
* keeps the deferred-auth UX consistent across the tool and resource
|
|
10
|
+
* surfaces — a missing key surfaces the same actionable
|
|
11
|
+
* `missing_api_key` message regardless of whether the caller invoked
|
|
12
|
+
* `tools/call` or `resources/read`. MCP hosts display resource contents
|
|
13
|
+
* in their resource viewer, so the JSON payload is what the user sees.
|
|
14
|
+
*
|
|
15
|
+
* Other API errors continue to throw — they're real failures and the
|
|
16
|
+
* JSON-RPC error path carries the statusCode/code metadata the host
|
|
17
|
+
* needs to surface them.
|
|
18
|
+
*/
|
|
19
|
+
export function withMissingApiKeyResource(uri, inner) {
|
|
20
|
+
return async () => {
|
|
21
|
+
try {
|
|
22
|
+
return await inner();
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err instanceof QURLAPIError && err.code === "missing_api_key") {
|
|
26
|
+
return {
|
|
27
|
+
contents: [
|
|
28
|
+
{
|
|
29
|
+
uri,
|
|
30
|
+
mimeType: "application/json",
|
|
31
|
+
text: JSON.stringify({
|
|
32
|
+
error: { code: err.code, message: err.message },
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=_shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../src/resources/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAU5C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAAW,EACX,KAAoC;IAEpC,OAAO,KAAK,IAAI,EAAE;QAChB,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,YAAY,IAAI,GAAG,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBAClE,OAAO;oBACL,QAAQ,EAAE;wBACR;4BACE,GAAG;4BACH,QAAQ,EAAE,kBAAkB;4BAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gCACnB,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE;6BAChD,CAAC;yBACH;qBACF;iBACF,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IQURLClient } from "../client.js";
|
|
2
|
+
export declare function linksResource(client: IQURLClient): {
|
|
3
|
+
uri: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
handler: () => Promise<{
|
|
8
|
+
contents: Array<{
|
|
9
|
+
uri: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
text: string;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/resources/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW;;;;;;;;oBAHU,CAAC;;;;EAoB3D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { withMissingApiKeyResource } from "./_shared.js";
|
|
2
|
+
// Hard cap on the informational resource. Resource reads are snapshot-style —
|
|
3
|
+
// callers that need full pagination should use the list_qurls tool directly.
|
|
4
|
+
const LINKS_RESOURCE_LIMIT = 50;
|
|
5
|
+
export function linksResource(client) {
|
|
6
|
+
const uri = "qurl://links";
|
|
7
|
+
const mimeType = "application/json";
|
|
8
|
+
return {
|
|
9
|
+
uri,
|
|
10
|
+
name: "Active qURL Links",
|
|
11
|
+
description: `Snapshot of up to ${LINKS_RESOURCE_LIMIT} active qURL links (most recent first). ` +
|
|
12
|
+
"For full pagination use the list_qurls tool.",
|
|
13
|
+
mimeType,
|
|
14
|
+
handler: withMissingApiKeyResource(uri, async () => {
|
|
15
|
+
const result = await client.listQURLs({ limit: LINKS_RESOURCE_LIMIT });
|
|
16
|
+
return {
|
|
17
|
+
contents: [{ uri, mimeType, text: JSON.stringify(result.data) }],
|
|
18
|
+
};
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/resources/links.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,8EAA8E;AAC9E,6EAA6E;AAC7E,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,MAAM,UAAU,aAAa,CAAC,MAAmB;IAC/C,MAAM,GAAG,GAAG,cAAc,CAAC;IAC3B,MAAM,QAAQ,GAAG,kBAAkB,CAAC;IACpC,OAAO;QACL,GAAG;QACH,IAAI,EAAE,mBAAmB;QACzB,WAAW,EACT,qBAAqB,oBAAoB,0CAA0C;YACnF,8CAA8C;QAChD,QAAQ;QACR,OAAO,EAAE,yBAAyB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;YACjD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC;YACvE,OAAO;gBACL,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;aACjE,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IQURLClient } from "../client.js";
|
|
2
|
+
export declare function usageResource(client: IQURLClient): {
|
|
3
|
+
uri: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
handler: () => Promise<{
|
|
8
|
+
contents: Array<{
|
|
9
|
+
uri: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
text: string;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW;;;;;;;;oBAI5C,CAAC;;;;EAWL"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { withMissingApiKeyResource } from "./_shared.js";
|
|
2
|
+
export function usageResource(client) {
|
|
3
|
+
const uri = "qurl://usage";
|
|
4
|
+
const mimeType = "application/json";
|
|
5
|
+
return {
|
|
6
|
+
uri,
|
|
7
|
+
name: "qURL Usage & Quota",
|
|
8
|
+
description: "Current quota and usage information",
|
|
9
|
+
mimeType,
|
|
10
|
+
handler: withMissingApiKeyResource(uri, async () => {
|
|
11
|
+
const result = await client.getQuota();
|
|
12
|
+
return {
|
|
13
|
+
contents: [{ uri, mimeType, text: JSON.stringify(result.data) }],
|
|
14
|
+
};
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,UAAU,aAAa,CAAC,MAAmB;IAC/C,MAAM,GAAG,GAAG,cAAc,CAAC;IAC3B,MAAM,QAAQ,GAAG,kBAAkB,CAAC;IACpC,OAAO;QACL,GAAG;QACH,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,qCAAqC;QAClD,QAAQ;QACR,OAAO,EAAE,yBAAyB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;YACjD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;YACvC,OAAO;gBACL,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;aACjE,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { IQURLClient } from "./client.js";
|
|
4
|
+
import { createQurlTool } from "./tools/create-qurl.js";
|
|
5
|
+
import { resolveQurlTool } from "./tools/resolve-qurl.js";
|
|
6
|
+
import { listQurlsTool } from "./tools/list-qurls.js";
|
|
7
|
+
import { getQurlTool } from "./tools/get-qurl.js";
|
|
8
|
+
import { deleteQurlTool } from "./tools/delete-qurl.js";
|
|
9
|
+
import { extendQurlTool } from "./tools/extend-qurl.js";
|
|
10
|
+
import { updateQurlTool } from "./tools/update-qurl.js";
|
|
11
|
+
import { mintLinkTool } from "./tools/mint-link.js";
|
|
12
|
+
import { batchCreateTool } from "./tools/batch-create.js";
|
|
13
|
+
import type { ToolAnnotations } from "./tools/_shared.js";
|
|
14
|
+
/**
|
|
15
|
+
* Shape of the object every tool factory returns. Exported so the
|
|
16
|
+
* TDQS-coverage test can iterate the same canonical list without
|
|
17
|
+
* redeclaring the type.
|
|
18
|
+
*/
|
|
19
|
+
export type ToolFactory = (client: IQURLClient) => {
|
|
20
|
+
name: string;
|
|
21
|
+
title: string;
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: z.AnyZodObject;
|
|
24
|
+
outputSchema: z.AnyZodObject;
|
|
25
|
+
annotations: ToolAnnotations;
|
|
26
|
+
handler: (...args: any[]) => Promise<{
|
|
27
|
+
content: Array<{
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
}>;
|
|
31
|
+
structuredContent?: Record<string, unknown>;
|
|
32
|
+
isError?: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
export declare const toolFactories: (typeof createQurlTool | typeof resolveQurlTool | typeof listQurlsTool | typeof getQurlTool | typeof deleteQurlTool | typeof extendQurlTool | typeof updateQurlTool | typeof mintLinkTool | typeof batchCreateTool)[];
|
|
36
|
+
export declare function createServer(client: IQURLClient, version: string): McpServer;
|
|
37
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAO1D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC;IAC5B,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC;IAC7B,WAAW,EAAE,eAAe,CAAC;IAG7B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;QACnC,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC,CAAC;CACJ,CAAC;AAEF,eAAO,MAAM,aAAa,uNAUD,CAAC;AAE1B,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAwC5E"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { createQurlTool } from "./tools/create-qurl.js";
|
|
3
|
+
import { resolveQurlTool } from "./tools/resolve-qurl.js";
|
|
4
|
+
import { listQurlsTool } from "./tools/list-qurls.js";
|
|
5
|
+
import { getQurlTool } from "./tools/get-qurl.js";
|
|
6
|
+
import { deleteQurlTool } from "./tools/delete-qurl.js";
|
|
7
|
+
import { extendQurlTool } from "./tools/extend-qurl.js";
|
|
8
|
+
import { updateQurlTool } from "./tools/update-qurl.js";
|
|
9
|
+
import { mintLinkTool } from "./tools/mint-link.js";
|
|
10
|
+
import { batchCreateTool } from "./tools/batch-create.js";
|
|
11
|
+
import { linksResource } from "./resources/links.js";
|
|
12
|
+
import { usageResource } from "./resources/usage.js";
|
|
13
|
+
import { secureAServicePrompt } from "./prompts/secure-a-service.js";
|
|
14
|
+
import { auditLinksPrompt } from "./prompts/audit-links.js";
|
|
15
|
+
import { rotateAccessPrompt } from "./prompts/rotate-access.js";
|
|
16
|
+
export const toolFactories = [
|
|
17
|
+
createQurlTool,
|
|
18
|
+
resolveQurlTool,
|
|
19
|
+
listQurlsTool,
|
|
20
|
+
getQurlTool,
|
|
21
|
+
deleteQurlTool,
|
|
22
|
+
extendQurlTool,
|
|
23
|
+
updateQurlTool,
|
|
24
|
+
mintLinkTool,
|
|
25
|
+
batchCreateTool,
|
|
26
|
+
];
|
|
27
|
+
export function createServer(client, version) {
|
|
28
|
+
const server = new McpServer({
|
|
29
|
+
name: "qurl",
|
|
30
|
+
version,
|
|
31
|
+
});
|
|
32
|
+
for (const factory of toolFactories) {
|
|
33
|
+
const tool = factory(client);
|
|
34
|
+
// registerTool wires outputSchema + annotations into tools/list; pass
|
|
35
|
+
// .shape (ZodRawShape), not the ZodObject itself.
|
|
36
|
+
server.registerTool(tool.name, {
|
|
37
|
+
title: tool.title,
|
|
38
|
+
description: tool.description,
|
|
39
|
+
inputSchema: tool.inputSchema.shape,
|
|
40
|
+
outputSchema: tool.outputSchema.shape,
|
|
41
|
+
annotations: tool.annotations,
|
|
42
|
+
}, tool.handler);
|
|
43
|
+
}
|
|
44
|
+
// Register resources
|
|
45
|
+
for (const factory of [linksResource, usageResource]) {
|
|
46
|
+
const resource = factory(client);
|
|
47
|
+
server.resource(resource.name, resource.uri, resource.handler);
|
|
48
|
+
}
|
|
49
|
+
// Register prompts
|
|
50
|
+
const secure = secureAServicePrompt();
|
|
51
|
+
server.prompt(secure.name, secure.description, secure.args, secure.handler);
|
|
52
|
+
const audit = auditLinksPrompt();
|
|
53
|
+
server.prompt(audit.name, audit.description, audit.handler);
|
|
54
|
+
const rotate = rotateAccessPrompt();
|
|
55
|
+
server.prompt(rotate.name, rotate.description, rotate.args, rotate.handler);
|
|
56
|
+
return server;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAuBhE,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,cAAc;IACd,eAAe;IACf,aAAa;IACb,WAAW;IACX,cAAc;IACd,cAAc;IACd,cAAc;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AC;IAE5D,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAE5E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z, type ZodError } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Tool result shape that handlers return. Kept structural so we don't
|
|
4
|
+
* take a hard dep on the MCP SDK's internal types. `structuredContent`
|
|
5
|
+
* is what the SDK validates against `outputSchema` when one is declared
|
|
6
|
+
* on the tool; `content` carries the human-readable JSON for display.
|
|
7
|
+
*/
|
|
8
|
+
type ToolResult = {
|
|
9
|
+
content: Array<{
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
}>;
|
|
13
|
+
structuredContent?: Record<string, unknown>;
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* MCP tool behavioral annotations — hints to the host for safety / UX
|
|
18
|
+
* surfacing. Mirrors `ToolAnnotations` from the MCP SDK without taking
|
|
19
|
+
* a value-level dep on it (the SDK type lives behind a deep import).
|
|
20
|
+
*
|
|
21
|
+
* - `readOnlyHint` — tool does not modify server state (list, get, resolve).
|
|
22
|
+
* - `destructiveHint` — tool may delete or revoke (delete, optionally rotate).
|
|
23
|
+
* - `idempotentHint` — repeated calls with the same args yield the same effect.
|
|
24
|
+
* - `openWorldHint` — tool reaches an external service whose state the host
|
|
25
|
+
* cannot model. True for everything here since we hit the qURL API.
|
|
26
|
+
*/
|
|
27
|
+
export type ToolAnnotations = {
|
|
28
|
+
title?: string;
|
|
29
|
+
readOnlyHint?: boolean;
|
|
30
|
+
destructiveHint?: boolean;
|
|
31
|
+
idempotentHint?: boolean;
|
|
32
|
+
openWorldHint?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare function toStructuredContent<T extends object & {
|
|
35
|
+
length?: never;
|
|
36
|
+
}>(value: T): Record<string, unknown>;
|
|
37
|
+
/**
|
|
38
|
+
* Wrap a tool handler so that a thrown `QURLAPIError` with
|
|
39
|
+
* `code: "missing_api_key"` is converted into an `isError: true` content
|
|
40
|
+
* block instead of propagating as a JSON-RPC error. MCP hosts surface
|
|
41
|
+
* `isError: true` content blocks more prominently than transport-level
|
|
42
|
+
* errors, so a missing-key misconfig becomes immediately actionable in
|
|
43
|
+
* the host UI rather than buried in a generic error toast.
|
|
44
|
+
*
|
|
45
|
+
* Other API errors continue to throw — they're real failures that callers
|
|
46
|
+
* should treat as exceptional, and the JSON-RPC error path carries the
|
|
47
|
+
* statusCode/code metadata the host needs to surface them properly.
|
|
48
|
+
*/
|
|
49
|
+
export declare function withMissingApiKeyHandler<I>(inner: (input: I) => Promise<ToolResult>): (input: I) => Promise<ToolResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Convert a ZodError into an MCP tool error result.
|
|
52
|
+
*
|
|
53
|
+
* Used by tools that register a base schema with the MCP SDK and re-parse
|
|
54
|
+
* with a refined schema inside the handler — the MCP SDK cannot serialize
|
|
55
|
+
* Zod refinements to JSON Schema, so cross-field constraints have to be
|
|
56
|
+
* checked at call time and converted into a tool error response.
|
|
57
|
+
*/
|
|
58
|
+
export declare function zodErrorToToolResult(error: ZodError): {
|
|
59
|
+
isError: true;
|
|
60
|
+
content: {
|
|
61
|
+
type: "text";
|
|
62
|
+
text: string;
|
|
63
|
+
}[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Zod schema for a tool's resource_id parameter.
|
|
67
|
+
*
|
|
68
|
+
* The API accepts both a resource ID (r_ prefix) and a qURL display ID
|
|
69
|
+
* (q_ prefix) on get/update/extend/mint_link, and resolves a q_ ID to its
|
|
70
|
+
* parent resource automatically. DELETE is the one exception — it only
|
|
71
|
+
* accepts r_ IDs and defines its own schema.
|
|
72
|
+
*
|
|
73
|
+
* Rejects empty strings so a malformed call can't hit `/v1/qurls/` with
|
|
74
|
+
* an empty path segment.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resourceIdSchema(verb: string): z.ZodString;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=_shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../src/tools/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAGvC;;;;;GAKG;AACH,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG;IAK5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAWF,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,EACvE,KAAK,EAAE,CAAC,GACP,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,GACvC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAcnC;AAED;;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