@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LayerV AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @layervai/qurl-mcp
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@layervai/qurl-mcp)
|
|
4
|
+
|
|
5
|
+
> **⚠️ Renamed from `@layerv/qurl-mcp` in v0.4.0.** The old package is deprecated and will not receive further updates. If you're using `@layerv/qurl-mcp@0.3.x`, swap the scope in your MCP client config — same binary, same API key, no other changes.
|
|
6
|
+
|
|
7
|
+
MCP server for qURL™ secure link management.
|
|
8
|
+
|
|
9
|
+
> **Quantum URL (qURL)** · The internet has a hidden layer. This is how you enter.
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
qURL MCP Server is a [Model Context Protocol](https://modelcontextprotocol.io/) server that lets AI agents (Claude, GPT, Cursor, etc.) create, resolve, list, and manage qURL secure links natively. It connects to the qURL API over stdio transport, so any MCP-compatible client can use it without custom integration code.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Add the server to your MCP client configuration (Claude Desktop, Claude Code, etc.):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"qurl": {
|
|
23
|
+
"command": "npx",
|
|
24
|
+
"args": ["@layervai/qurl-mcp"],
|
|
25
|
+
"env": { "QURL_API_KEY": "lv_live_xxx" }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Replace `lv_live_xxx` with your actual API key. The key must have the appropriate scopes for the tools you intend to use (see below).
|
|
32
|
+
|
|
33
|
+
## Available Tools
|
|
34
|
+
|
|
35
|
+
| Tool | Description | Required Scope |
|
|
36
|
+
|------|-------------|----------------|
|
|
37
|
+
| `create_qurl` | Create a secure, policy-bound link to a protected resource | `qurl:write` |
|
|
38
|
+
| `resolve_qurl` | Resolve an access token to get the target URL and open firewall access | `qurl:resolve` |
|
|
39
|
+
| `list_qurls` | List active qURLs with optional pagination | `qurl:read` |
|
|
40
|
+
| `get_qurl` | Get details of a specific qURL by resource ID | `qurl:read` |
|
|
41
|
+
| `delete_qurl` | Revoke a qURL, immediately invalidating the link | `qurl:write` |
|
|
42
|
+
| `extend_qurl` | Extend the expiration of an active qURL (alias for `update_qurl`) | `qurl:write` |
|
|
43
|
+
| `update_qurl` | Update expiration, tags, or description on an active qURL | `qurl:write` |
|
|
44
|
+
| `mint_link` | Mint a new access link for an existing protected resource | `qurl:write` |
|
|
45
|
+
| `batch_create_qurls` | Create multiple qURLs in a single call | `qurl:write` |
|
|
46
|
+
|
|
47
|
+
## Available Resources
|
|
48
|
+
|
|
49
|
+
| URI | Name | Description |
|
|
50
|
+
|-----|------|-------------|
|
|
51
|
+
| `qurl://links` | Active qURL Links | List of all active qURL links |
|
|
52
|
+
| `qurl://usage` | qURL Usage & Quota | Current quota and usage information |
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
| Environment Variable | Required | Description | Default |
|
|
57
|
+
|---------------------|----------|-------------|---------|
|
|
58
|
+
| `QURL_API_KEY` | Conditional (see description) | API key with appropriate scopes (`qurl:read`, `qurl:write`, `qurl:resolve`). The server boots without it so MCP introspection (`tools/list`, `resources/list`, `prompts/list`) works for directory probes — required only on the first tool call or resource read, where invocations surface a typed `missing_api_key` error until the key is set. | -- |
|
|
59
|
+
| `QURL_API_URL` | No | qURL API base URL | `https://api.layerv.ai` |
|
|
60
|
+
|
|
61
|
+
## Docker
|
|
62
|
+
|
|
63
|
+
A multi-stage Dockerfile is included for container-based deployment:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
docker build -t qurl-mcp .
|
|
67
|
+
docker run -i -e QURL_API_KEY=lv_live_xxx qurl-mcp
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The image runs as the non-root `node` user, ships only production dependencies, and uses `tini` as PID 1 for clean signal handling.
|
|
71
|
+
|
|
72
|
+
If a tool call returns `missing_api_key` despite `QURL_API_KEY` looking set, check stderr for the boot-time warning — some MCP hosts hide stderr, and the warning is the fastest way to spot a whitespace-only or unset value:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
docker logs <container> # if running detached
|
|
76
|
+
docker run -i -e QURL_API_KEY=lv_live_xxx qurl-mcp 2>&1 # interactive
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm install
|
|
83
|
+
npm run build
|
|
84
|
+
npm test
|
|
85
|
+
npm run lint
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Additional commands:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm run dev # Watch mode (rebuild on changes)
|
|
92
|
+
npm run format # Format source with Prettier
|
|
93
|
+
npm run format:check # Check formatting without modifying files
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT -- [LayerV AI](https://layerv.ai)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* qURL API client for the MCP server.
|
|
3
|
+
*/
|
|
4
|
+
export interface QURLClientConfig {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseURL: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AccessToken {
|
|
9
|
+
qurl_id: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
status: "active" | "consumed" | "expired" | "revoked";
|
|
12
|
+
one_time_use: boolean;
|
|
13
|
+
max_sessions: number;
|
|
14
|
+
session_duration: number;
|
|
15
|
+
use_count: number;
|
|
16
|
+
qurl_site?: string;
|
|
17
|
+
access_policy?: AccessPolicy;
|
|
18
|
+
created_at: string;
|
|
19
|
+
expires_at: string;
|
|
20
|
+
}
|
|
21
|
+
export interface QURL {
|
|
22
|
+
resource_id: string;
|
|
23
|
+
qurl_site?: string;
|
|
24
|
+
target_url: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
tags?: string[];
|
|
27
|
+
expires_at: string;
|
|
28
|
+
created_at: string;
|
|
29
|
+
status: "active" | "revoked";
|
|
30
|
+
custom_domain?: string | null;
|
|
31
|
+
preserve_host?: boolean;
|
|
32
|
+
qurl_count?: number;
|
|
33
|
+
qurls?: AccessToken[];
|
|
34
|
+
}
|
|
35
|
+
export interface CreateQURLData {
|
|
36
|
+
qurl_id: string;
|
|
37
|
+
resource_id: string;
|
|
38
|
+
qurl_link: string;
|
|
39
|
+
qurl_site: string;
|
|
40
|
+
expires_at: string;
|
|
41
|
+
label?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface AIAgentPolicy {
|
|
44
|
+
block_all?: boolean;
|
|
45
|
+
deny_categories?: string[];
|
|
46
|
+
allow_categories?: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface AccessPolicy {
|
|
49
|
+
ip_allowlist?: string[];
|
|
50
|
+
ip_denylist?: string[];
|
|
51
|
+
geo_allowlist?: string[];
|
|
52
|
+
geo_denylist?: string[];
|
|
53
|
+
user_agent_allow_regex?: string;
|
|
54
|
+
user_agent_deny_regex?: string;
|
|
55
|
+
ai_agent_policy?: AIAgentPolicy;
|
|
56
|
+
}
|
|
57
|
+
export interface CreateQURLInput {
|
|
58
|
+
target_url: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
expires_in?: string;
|
|
61
|
+
one_time_use?: boolean;
|
|
62
|
+
max_sessions?: number;
|
|
63
|
+
session_duration?: string;
|
|
64
|
+
custom_domain?: string;
|
|
65
|
+
access_policy?: AccessPolicy;
|
|
66
|
+
}
|
|
67
|
+
export interface ListQURLsInput {
|
|
68
|
+
limit?: number;
|
|
69
|
+
cursor?: string;
|
|
70
|
+
/** Filter by status. Accepts comma-separated values, e.g. `"active,revoked"`. */
|
|
71
|
+
status?: string;
|
|
72
|
+
/** RFC 3339 timestamp. */
|
|
73
|
+
created_after?: string;
|
|
74
|
+
/** RFC 3339 timestamp. */
|
|
75
|
+
created_before?: string;
|
|
76
|
+
/** RFC 3339 timestamp. */
|
|
77
|
+
expires_before?: string;
|
|
78
|
+
/** RFC 3339 timestamp. */
|
|
79
|
+
expires_after?: string;
|
|
80
|
+
/** Sort field and direction, e.g. `"created_at:desc"`. */
|
|
81
|
+
sort?: string;
|
|
82
|
+
/** Free-text search over description and target_url. */
|
|
83
|
+
q?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface UpdateQURLInput {
|
|
86
|
+
extend_by?: string;
|
|
87
|
+
expires_at?: string;
|
|
88
|
+
tags?: string[];
|
|
89
|
+
description?: string;
|
|
90
|
+
custom_domain?: string;
|
|
91
|
+
preserve_host?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface ExtendQURLInput {
|
|
94
|
+
extend_by: string;
|
|
95
|
+
}
|
|
96
|
+
export interface ResolveInput {
|
|
97
|
+
access_token: string;
|
|
98
|
+
}
|
|
99
|
+
export interface MintLinkInput {
|
|
100
|
+
label?: string;
|
|
101
|
+
expires_in?: string;
|
|
102
|
+
expires_at?: string;
|
|
103
|
+
one_time_use?: boolean;
|
|
104
|
+
max_sessions?: number;
|
|
105
|
+
session_duration?: string;
|
|
106
|
+
access_policy?: AccessPolicy;
|
|
107
|
+
}
|
|
108
|
+
export interface BatchCreateInput {
|
|
109
|
+
items: CreateQURLInput[];
|
|
110
|
+
}
|
|
111
|
+
export interface ListQURLsOutput {
|
|
112
|
+
data: QURL[];
|
|
113
|
+
meta: {
|
|
114
|
+
next_cursor?: string;
|
|
115
|
+
has_more: boolean;
|
|
116
|
+
page_size?: number;
|
|
117
|
+
request_id?: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export interface ResolveOutput {
|
|
121
|
+
target_url: string;
|
|
122
|
+
resource_id: string;
|
|
123
|
+
access_grant: {
|
|
124
|
+
expires_in: number;
|
|
125
|
+
granted_at: string;
|
|
126
|
+
src_ip: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export interface QuotaOutput {
|
|
130
|
+
plan: "free" | "growth" | "enterprise";
|
|
131
|
+
period_start: string;
|
|
132
|
+
period_end: string;
|
|
133
|
+
rate_limits: {
|
|
134
|
+
create_per_minute: number;
|
|
135
|
+
create_per_hour: number;
|
|
136
|
+
list_per_minute: number;
|
|
137
|
+
resolve_per_minute: number;
|
|
138
|
+
max_active_qurls: number;
|
|
139
|
+
max_tokens_per_qurl: number;
|
|
140
|
+
max_expiry_seconds: number;
|
|
141
|
+
};
|
|
142
|
+
usage: {
|
|
143
|
+
qurls_created: number;
|
|
144
|
+
active_qurls: number;
|
|
145
|
+
active_qurls_percent: number | null;
|
|
146
|
+
total_accesses: number;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export interface MintLinkOutput {
|
|
150
|
+
qurl_link: string;
|
|
151
|
+
expires_at: string;
|
|
152
|
+
}
|
|
153
|
+
export type BatchItemResult = {
|
|
154
|
+
index: number;
|
|
155
|
+
success: true;
|
|
156
|
+
resource_id: string;
|
|
157
|
+
qurl_link: string;
|
|
158
|
+
qurl_site: string;
|
|
159
|
+
expires_at: string;
|
|
160
|
+
} | {
|
|
161
|
+
index: number;
|
|
162
|
+
success: false;
|
|
163
|
+
error: {
|
|
164
|
+
code: string;
|
|
165
|
+
message: string;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
export interface BatchCreateOutput {
|
|
169
|
+
data: {
|
|
170
|
+
succeeded: number;
|
|
171
|
+
failed: number;
|
|
172
|
+
results: BatchItemResult[];
|
|
173
|
+
};
|
|
174
|
+
meta: {
|
|
175
|
+
request_id?: string;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export interface IQURLClient {
|
|
179
|
+
/**
|
|
180
|
+
* Create a new qURL. Returns `CreateQURLData` — the ephemeral create-time
|
|
181
|
+
* shape that carries `qurl_link` (shown only once) and `qurl_id`. This is
|
|
182
|
+
* intentionally distinct from the `QURL` shape returned by `getQURL` /
|
|
183
|
+
* `listQURLs`, which does not include `qurl_link`.
|
|
184
|
+
*/
|
|
185
|
+
createQURL(input: CreateQURLInput): Promise<{
|
|
186
|
+
data: CreateQURLData;
|
|
187
|
+
}>;
|
|
188
|
+
/**
|
|
189
|
+
* Fetch a resource and its access tokens. Returns the stable `QURL` shape
|
|
190
|
+
* (no `qurl_link` — that only exists on the create response).
|
|
191
|
+
*/
|
|
192
|
+
getQURL(id: string): Promise<{
|
|
193
|
+
data: QURL;
|
|
194
|
+
}>;
|
|
195
|
+
listQURLs(input?: ListQURLsInput): Promise<ListQURLsOutput>;
|
|
196
|
+
deleteQURL(id: string): Promise<void>;
|
|
197
|
+
updateQURL(id: string, input: UpdateQURLInput): Promise<{
|
|
198
|
+
data: QURL;
|
|
199
|
+
}>;
|
|
200
|
+
extendQURL(id: string, input: ExtendQURLInput): Promise<{
|
|
201
|
+
data: QURL;
|
|
202
|
+
}>;
|
|
203
|
+
resolveQURL(input: ResolveInput): Promise<{
|
|
204
|
+
data: ResolveOutput;
|
|
205
|
+
}>;
|
|
206
|
+
getQuota(): Promise<{
|
|
207
|
+
data: QuotaOutput;
|
|
208
|
+
}>;
|
|
209
|
+
mintLink(id: string, input?: MintLinkInput): Promise<{
|
|
210
|
+
data: MintLinkOutput;
|
|
211
|
+
}>;
|
|
212
|
+
batchCreate(input: BatchCreateInput): Promise<BatchCreateOutput>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Error thrown by `QURLClient` for any API or pre-flight failure.
|
|
216
|
+
*
|
|
217
|
+
* `statusCode` is the HTTP response status, with one sentinel: **`0`** means
|
|
218
|
+
* the error was raised on the client before any network request was issued
|
|
219
|
+
* (e.g. `code: "missing_api_key"`). Branching logic that inspects HTTP
|
|
220
|
+
* status should special-case `0` rather than treating it as a real status.
|
|
221
|
+
*/
|
|
222
|
+
export declare class QURLAPIError extends Error {
|
|
223
|
+
statusCode: number;
|
|
224
|
+
code: string;
|
|
225
|
+
type?: string | undefined;
|
|
226
|
+
instance?: string | undefined;
|
|
227
|
+
requestId?: string | undefined;
|
|
228
|
+
constructor(statusCode: number, code: string, message: string, type?: string | undefined, instance?: string | undefined, requestId?: string | undefined);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Shared message for the missing-API-key condition. Emitted both at boot
|
|
232
|
+
* (stderr warning in `index.ts`) and on every API call from `request()`.
|
|
233
|
+
* Keeping a single string means a user grepping logs/transcripts hits the
|
|
234
|
+
* same phrase from both sites, and the CI introspection probe has a stable
|
|
235
|
+
* substring to assert against.
|
|
236
|
+
*/
|
|
237
|
+
export declare const MISSING_API_KEY_MESSAGE = "QURL_API_KEY is not set. Set it in the MCP server environment and restart to make API calls.";
|
|
238
|
+
export declare class QURLClient implements IQURLClient {
|
|
239
|
+
private apiKey;
|
|
240
|
+
private baseURL;
|
|
241
|
+
constructor(config: QURLClientConfig);
|
|
242
|
+
/**
|
|
243
|
+
* Issue an HTTP request and parse the JSON response.
|
|
244
|
+
*
|
|
245
|
+
* `passthroughStatuses` lets a caller opt certain non-2xx codes out of the
|
|
246
|
+
* default throw-on-error path and receive the parsed body instead. This is
|
|
247
|
+
* used by `batchCreate`, where the API returns a structured BatchCreateResponse
|
|
248
|
+
* on HTTP 400 (all items rejected) — throwing would drop the per-item errors.
|
|
249
|
+
*/
|
|
250
|
+
private request;
|
|
251
|
+
private parseJSON;
|
|
252
|
+
private qurlPath;
|
|
253
|
+
createQURL(input: CreateQURLInput): Promise<{
|
|
254
|
+
data: CreateQURLData;
|
|
255
|
+
}>;
|
|
256
|
+
getQURL(id: string): Promise<{
|
|
257
|
+
data: QURL;
|
|
258
|
+
}>;
|
|
259
|
+
listQURLs(input?: ListQURLsInput): Promise<ListQURLsOutput>;
|
|
260
|
+
deleteQURL(id: string): Promise<void>;
|
|
261
|
+
updateQURL(id: string, input: UpdateQURLInput): Promise<{
|
|
262
|
+
data: QURL;
|
|
263
|
+
}>;
|
|
264
|
+
extendQURL(id: string, input: ExtendQURLInput): Promise<{
|
|
265
|
+
data: QURL;
|
|
266
|
+
}>;
|
|
267
|
+
resolveQURL(input: ResolveInput): Promise<{
|
|
268
|
+
data: ResolveOutput;
|
|
269
|
+
}>;
|
|
270
|
+
getQuota(): Promise<{
|
|
271
|
+
data: QuotaOutput;
|
|
272
|
+
}>;
|
|
273
|
+
mintLink(id: string, input?: MintLinkInput): Promise<{
|
|
274
|
+
data: MintLinkOutput;
|
|
275
|
+
}>;
|
|
276
|
+
batchCreate(input: BatchCreateInput): Promise<BatchCreateOutput>;
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],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AAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC;IAI9E,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAIvE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* qURL API client for the MCP server.
|
|
3
|
+
*/
|
|
4
|
+
// --- Error class ---
|
|
5
|
+
/**
|
|
6
|
+
* Error thrown by `QURLClient` for any API or pre-flight failure.
|
|
7
|
+
*
|
|
8
|
+
* `statusCode` is the HTTP response status, with one sentinel: **`0`** means
|
|
9
|
+
* the error was raised on the client before any network request was issued
|
|
10
|
+
* (e.g. `code: "missing_api_key"`). Branching logic that inspects HTTP
|
|
11
|
+
* status should special-case `0` rather than treating it as a real status.
|
|
12
|
+
*/
|
|
13
|
+
export class QURLAPIError extends Error {
|
|
14
|
+
statusCode;
|
|
15
|
+
code;
|
|
16
|
+
type;
|
|
17
|
+
instance;
|
|
18
|
+
requestId;
|
|
19
|
+
constructor(statusCode, code, message, type, instance, requestId) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.statusCode = statusCode;
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.type = type;
|
|
24
|
+
this.instance = instance;
|
|
25
|
+
this.requestId = requestId;
|
|
26
|
+
this.name = "QURLAPIError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Shared message for the missing-API-key condition. Emitted both at boot
|
|
31
|
+
* (stderr warning in `index.ts`) and on every API call from `request()`.
|
|
32
|
+
* Keeping a single string means a user grepping logs/transcripts hits the
|
|
33
|
+
* same phrase from both sites, and the CI introspection probe has a stable
|
|
34
|
+
* substring to assert against.
|
|
35
|
+
*/
|
|
36
|
+
export const MISSING_API_KEY_MESSAGE = "QURL_API_KEY is not set. Set it in the MCP server environment and restart to make API calls.";
|
|
37
|
+
// --- Client implementation ---
|
|
38
|
+
export class QURLClient {
|
|
39
|
+
apiKey;
|
|
40
|
+
baseURL;
|
|
41
|
+
constructor(config) {
|
|
42
|
+
// `?? ""` defends against JS callers that hand in `undefined` (the TS
|
|
43
|
+
// type forbids it, but `JSON.parse`'d configs and other dynamic call
|
|
44
|
+
// sites can land here). Trim so a whitespace-only key (e.g. from a
|
|
45
|
+
// stray `QURL_API_KEY=" "`) takes the typed `missing_api_key` path
|
|
46
|
+
// instead of being sent over the wire as a server-side 401.
|
|
47
|
+
this.apiKey = (config.apiKey ?? "").trim();
|
|
48
|
+
this.baseURL = config.baseURL.replace(/\/$/, "");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Issue an HTTP request and parse the JSON response.
|
|
52
|
+
*
|
|
53
|
+
* `passthroughStatuses` lets a caller opt certain non-2xx codes out of the
|
|
54
|
+
* default throw-on-error path and receive the parsed body instead. This is
|
|
55
|
+
* used by `batchCreate`, where the API returns a structured BatchCreateResponse
|
|
56
|
+
* on HTTP 400 (all items rejected) — throwing would drop the per-item errors.
|
|
57
|
+
*/
|
|
58
|
+
async request(method, path, body, passthroughStatuses = []) {
|
|
59
|
+
if (!this.apiKey) {
|
|
60
|
+
throw new QURLAPIError(0, "missing_api_key", MISSING_API_KEY_MESSAGE);
|
|
61
|
+
}
|
|
62
|
+
const url = `${this.baseURL}${path}`;
|
|
63
|
+
const headers = {
|
|
64
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
65
|
+
};
|
|
66
|
+
if (body !== undefined) {
|
|
67
|
+
headers["Content-Type"] = "application/json";
|
|
68
|
+
}
|
|
69
|
+
const response = await fetch(url, {
|
|
70
|
+
method,
|
|
71
|
+
headers,
|
|
72
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
73
|
+
});
|
|
74
|
+
const text = await response.text();
|
|
75
|
+
// Handle empty 2xx responses (e.g., 204 No Content from DELETE).
|
|
76
|
+
// Only deleteQURL hits this path — T is void there, so undefined is correct.
|
|
77
|
+
if (!text && response.ok) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const json = this.parseJSON(text, response.status);
|
|
81
|
+
if (!response.ok && !passthroughStatuses.includes(response.status)) {
|
|
82
|
+
// Trust boundary: we cast the parsed error body to the RFC 7807 shape
|
|
83
|
+
// the API documents. The fallback chain below tolerates missing fields,
|
|
84
|
+
// so a malformed error response still degrades to `HTTP ${status}`.
|
|
85
|
+
const error = json.error;
|
|
86
|
+
const meta = json.meta;
|
|
87
|
+
throw new QURLAPIError(response.status, error?.code ?? "unknown", error?.detail ?? error?.title ?? error?.message ?? `HTTP ${response.status}`, error?.type, error?.instance, meta?.request_id);
|
|
88
|
+
}
|
|
89
|
+
return json;
|
|
90
|
+
}
|
|
91
|
+
parseJSON(text, status) {
|
|
92
|
+
try {
|
|
93
|
+
return JSON.parse(text);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
throw new QURLAPIError(status, "parse_error", `Failed to parse response: ${text.slice(0, 200)}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
qurlPath(id) {
|
|
100
|
+
return `/v1/qurls/${encodeURIComponent(id)}`;
|
|
101
|
+
}
|
|
102
|
+
async createQURL(input) {
|
|
103
|
+
return this.request("POST", "/v1/qurls", input);
|
|
104
|
+
}
|
|
105
|
+
async getQURL(id) {
|
|
106
|
+
return this.request("GET", this.qurlPath(id));
|
|
107
|
+
}
|
|
108
|
+
async listQURLs(input) {
|
|
109
|
+
const params = new URLSearchParams();
|
|
110
|
+
if (input?.limit !== undefined)
|
|
111
|
+
params.set("limit", String(input.limit));
|
|
112
|
+
if (input?.cursor)
|
|
113
|
+
params.set("cursor", input.cursor);
|
|
114
|
+
if (input?.status)
|
|
115
|
+
params.set("status", input.status);
|
|
116
|
+
if (input?.created_after)
|
|
117
|
+
params.set("created_after", input.created_after);
|
|
118
|
+
if (input?.created_before)
|
|
119
|
+
params.set("created_before", input.created_before);
|
|
120
|
+
if (input?.expires_before)
|
|
121
|
+
params.set("expires_before", input.expires_before);
|
|
122
|
+
if (input?.expires_after)
|
|
123
|
+
params.set("expires_after", input.expires_after);
|
|
124
|
+
if (input?.sort)
|
|
125
|
+
params.set("sort", input.sort);
|
|
126
|
+
if (input?.q)
|
|
127
|
+
params.set("q", input.q);
|
|
128
|
+
const query = params.toString();
|
|
129
|
+
return this.request("GET", `/v1/qurls${query ? `?${query}` : ""}`);
|
|
130
|
+
}
|
|
131
|
+
async deleteQURL(id) {
|
|
132
|
+
await this.request("DELETE", this.qurlPath(id));
|
|
133
|
+
}
|
|
134
|
+
async updateQURL(id, input) {
|
|
135
|
+
return this.request("PATCH", this.qurlPath(id), input);
|
|
136
|
+
}
|
|
137
|
+
async extendQURL(id, input) {
|
|
138
|
+
// ExtendQURLInput is a strict subset of UpdateQURLInput (just extend_by),
|
|
139
|
+
// so we delegate to updateQURL rather than duplicating the PATCH call.
|
|
140
|
+
return this.updateQURL(id, input);
|
|
141
|
+
}
|
|
142
|
+
async resolveQURL(input) {
|
|
143
|
+
return this.request("POST", "/v1/resolve", input);
|
|
144
|
+
}
|
|
145
|
+
async getQuota() {
|
|
146
|
+
return this.request("GET", "/v1/quota");
|
|
147
|
+
}
|
|
148
|
+
async mintLink(id, input) {
|
|
149
|
+
return this.request("POST", `${this.qurlPath(id)}/mint_link`, input);
|
|
150
|
+
}
|
|
151
|
+
async batchCreate(input) {
|
|
152
|
+
// 400 carries per-item errors (see request() JSDoc).
|
|
153
|
+
return this.request("POST", "/v1/qurls/batch", input, [400]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AA4OH,sBAAsB;AAEtB;;;;;;;GAOG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE5B;IACA;IAEA;IACA;IACA;IANT,YACS,UAAkB,EAClB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ED,KAAK,CAAC,QAAQ,CAAC,EAAU,EAAE,KAAqB;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAuB;QACvC,qDAAqD;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { MISSING_API_KEY_MESSAGE, QURLClient } from "./client.js";
|
|
5
|
+
import { createServer } from "./server.js";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const { version } = require("../package.json");
|
|
8
|
+
// Auth validation is deferred to first API call so the server can boot for
|
|
9
|
+
// MCP introspection (tools/list, resources/list, prompts/list) without a key.
|
|
10
|
+
// Tool/resource invocations that hit the API will throw the same typed error
|
|
11
|
+
// from `QURLClient.request()` if the key is missing.
|
|
12
|
+
//
|
|
13
|
+
// Trim so whitespace-only values (e.g. `QURL_API_KEY=" "`) take the same
|
|
14
|
+
// missing-key path as truly unset; otherwise they'd silently pass the guard
|
|
15
|
+
// and surface as a 401 from the server.
|
|
16
|
+
const apiKey = process.env.QURL_API_KEY?.trim() ?? "";
|
|
17
|
+
if (!apiKey) {
|
|
18
|
+
console.error(`Warning: ${MISSING_API_KEY_MESSAGE}`);
|
|
19
|
+
}
|
|
20
|
+
// Trim symmetric with the apiKey path so a stray space in the URL doesn't
|
|
21
|
+
// produce a confusing fetch failure (DNS or scheme parse error) instead of
|
|
22
|
+
// being treated as unset.
|
|
23
|
+
//
|
|
24
|
+
// Intentional asymmetry vs. line 19 (`?? ""`): an empty/whitespace key is
|
|
25
|
+
// a misconfig the user has to fix, so we want it to land on the empty path
|
|
26
|
+
// where the warning fires. An empty/whitespace URL should silently fall
|
|
27
|
+
// back to the default — `||` collapses both `undefined` and `""` cases
|
|
28
|
+
// into one fallback expression.
|
|
29
|
+
const baseURL = process.env.QURL_API_URL?.trim() || "https://api.layerv.ai";
|
|
30
|
+
const client = new QURLClient({ apiKey, baseURL });
|
|
31
|
+
const server = createServer(client, version);
|
|
32
|
+
const transport = new StdioServerTransport();
|
|
33
|
+
await server.connect(transport);
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAEtE,2EAA2E;AAC3E,8EAA8E;AAC9E,6EAA6E;AAC7E,qDAAqD;AACrD,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,wCAAwC;AACxC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACtD,IAAI,CAAC,MAAM,EAAE,CAAC;IACZ,OAAO,CAAC,KAAK,CAAC,YAAY,uBAAuB,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,0EAA0E;AAC1E,2EAA2E;AAC3E,0BAA0B;AAC1B,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,uEAAuE;AACvE,gCAAgC;AAChC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,uBAAuB,CAAC;AAE5E,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACnD,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-links.d.ts","sourceRoot":"","sources":["../../src/prompts/audit-links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,wBAAgB,gBAAgB;;;mBAKf,eAAe;EAyB/B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function auditLinksPrompt() {
|
|
2
|
+
return {
|
|
3
|
+
name: "audit-links",
|
|
4
|
+
description: "Review all active qURLs and identify expiring links, token counts, missing metadata, or potential issues.",
|
|
5
|
+
handler: () => {
|
|
6
|
+
return {
|
|
7
|
+
messages: [
|
|
8
|
+
{
|
|
9
|
+
role: "user",
|
|
10
|
+
content: {
|
|
11
|
+
type: "text",
|
|
12
|
+
text: [
|
|
13
|
+
"Audit my active qURL links. Follow these steps:",
|
|
14
|
+
"",
|
|
15
|
+
"1. Use the list_qurls tool to fetch all active qURLs.",
|
|
16
|
+
"2. For each qURL, collect facts:",
|
|
17
|
+
" - Is it expiring within the next 24 hours? (flag as expiring-soon)",
|
|
18
|
+
" - How many access tokens does it have (qurl_count)?",
|
|
19
|
+
" - Is it missing tags for organization? (flag as untagged)",
|
|
20
|
+
" - Note any custom_domain it has configured — this is informational, not an issue.",
|
|
21
|
+
"3. Summarize findings in a table with columns: resource_id, target_url, status, tags, expires_at, qurl_count, custom_domain, and any flags.",
|
|
22
|
+
"4. Recommend actions for any issues found (use update_qurl to extend, add tags, or update description; use delete_qurl to revoke).",
|
|
23
|
+
].join("\n"),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=audit-links.js.map
|