@chrischall/mcp-utils 2.11.0 → 2.13.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 +507 -13
- package/dist/concurrency/index.d.ts +3 -1
- package/dist/concurrency/index.d.ts.map +1 -1
- package/dist/concurrency/index.js +3 -1
- package/dist/concurrency/index.js.map +1 -1
- package/dist/concurrency/verify-after-write.d.ts +84 -0
- package/dist/concurrency/verify-after-write.d.ts.map +1 -0
- package/dist/concurrency/verify-after-write.js +108 -0
- package/dist/concurrency/verify-after-write.js.map +1 -0
- package/dist/errors/index.d.ts +35 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +79 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/fetchproxy/fallback.d.ts +130 -0
- package/dist/fetchproxy/fallback.d.ts.map +1 -0
- package/dist/fetchproxy/fallback.js +199 -0
- package/dist/fetchproxy/fallback.js.map +1 -0
- package/dist/fetchproxy/index.d.ts +31 -1
- package/dist/fetchproxy/index.d.ts.map +1 -1
- package/dist/fetchproxy/index.js +120 -13
- package/dist/fetchproxy/index.js.map +1 -1
- package/dist/fs/confine.d.ts +9 -0
- package/dist/fs/confine.d.ts.map +1 -1
- package/dist/fs/confine.js +11 -2
- package/dist/fs/confine.js.map +1 -1
- package/dist/fs/index.d.ts +9 -2
- package/dist/fs/index.d.ts.map +1 -1
- package/dist/fs/index.js +13 -4
- package/dist/fs/index.js.map +1 -1
- package/dist/fs/magic.d.ts +35 -0
- package/dist/fs/magic.d.ts.map +1 -0
- package/dist/fs/magic.js +110 -0
- package/dist/fs/magic.js.map +1 -0
- package/dist/fs/output.d.ts +14 -10
- package/dist/fs/output.d.ts.map +1 -1
- package/dist/fs/output.js +21 -45
- package/dist/fs/output.js.map +1 -1
- package/dist/fs/upload-guard.d.ts +97 -0
- package/dist/fs/upload-guard.d.ts.map +1 -0
- package/dist/fs/upload-guard.js +185 -0
- package/dist/fs/upload-guard.js.map +1 -0
- package/dist/fs/write.d.ts +100 -0
- package/dist/fs/write.d.ts.map +1 -0
- package/dist/fs/write.js +207 -0
- package/dist/fs/write.js.map +1 -0
- package/dist/graphql/client.d.ts +228 -0
- package/dist/graphql/client.d.ts.map +1 -0
- package/dist/graphql/client.js +341 -0
- package/dist/graphql/client.js.map +1 -0
- package/dist/graphql/index.d.ts +20 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +20 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/operation-kind.d.ts +58 -0
- package/dist/graphql/operation-kind.d.ts.map +1 -0
- package/dist/graphql/operation-kind.js +237 -0
- package/dist/graphql/operation-kind.js.map +1 -0
- package/dist/html/index.d.ts +33 -0
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +78 -13
- package/dist/html/index.js.map +1 -1
- package/dist/http/index.d.ts +75 -5
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +111 -22
- package/dist/http/index.js.map +1 -1
- package/dist/http/net-atoms.d.ts +14 -4
- package/dist/http/net-atoms.d.ts.map +1 -1
- package/dist/http/net-atoms.js +95 -13
- package/dist/http/net-atoms.js.map +1 -1
- package/dist/internal/code-point.d.ts +20 -0
- package/dist/internal/code-point.d.ts.map +1 -0
- package/dist/internal/code-point.js +26 -0
- package/dist/internal/code-point.js.map +1 -0
- package/dist/internal/retry-after.d.ts +12 -0
- package/dist/internal/retry-after.d.ts.map +1 -0
- package/dist/internal/retry-after.js +26 -0
- package/dist/internal/retry-after.js.map +1 -0
- package/dist/response/index.d.ts +1 -0
- package/dist/response/index.d.ts.map +1 -1
- package/dist/response/index.js +1 -0
- package/dist/response/index.js.map +1 -1
- package/dist/response/untrusted.d.ts +72 -0
- package/dist/response/untrusted.d.ts.map +1 -0
- package/dist/response/untrusted.js +55 -0
- package/dist/response/untrusted.js.map +1 -0
- package/dist/scrape/index.d.ts +78 -1
- package/dist/scrape/index.d.ts.map +1 -1
- package/dist/scrape/index.js +276 -20
- package/dist/scrape/index.js.map +1 -1
- package/dist/server/confirm-write.d.ts +152 -0
- package/dist/server/confirm-write.d.ts.map +1 -0
- package/dist/server/confirm-write.js +107 -0
- package/dist/server/confirm-write.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/merge-write.d.ts +101 -0
- package/dist/server/merge-write.d.ts.map +1 -0
- package/dist/server/merge-write.js +94 -0
- package/dist/server/merge-write.js.map +1 -0
- package/dist/session/atomic-write.d.ts +15 -0
- package/dist/session/atomic-write.d.ts.map +1 -0
- package/dist/session/atomic-write.js +42 -0
- package/dist/session/atomic-write.js.map +1 -0
- package/dist/session/file-lock.d.ts +57 -0
- package/dist/session/file-lock.d.ts.map +1 -0
- package/dist/session/file-lock.js +215 -0
- package/dist/session/file-lock.js.map +1 -0
- package/dist/session/index.d.ts +118 -2
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +200 -82
- package/dist/session/index.js.map +1 -1
- package/dist/session/login-page.d.ts +73 -0
- package/dist/session/login-page.d.ts.map +1 -0
- package/dist/session/login-page.js +143 -0
- package/dist/session/login-page.js.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createGraphqlClient` — the GraphQL-over-HTTP POST transport.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates the hand-rolled GraphQL clients in vibo-mcp (`src/client.ts`
|
|
5
|
+
* `ViboClient.post` / `readGraphQLBody` / `unwrap` / `transportError`, the
|
|
6
|
+
* reference implementation) and thumbtack-mcp (`src/client.ts`
|
|
7
|
+
* `ThumbtackClient.graphql`) — chrischall/fleet-audit#1138, #1128. Both POST
|
|
8
|
+
* `{ query, variables }`, treat `errors[]` on an HTTP 200 as a failure, join
|
|
9
|
+
* and truncate the messages, and refuse a non-JSON 2xx as a challenge page;
|
|
10
|
+
* vibo adds auth-code classification, a refresh-and-replay-once, CDN/WAF
|
|
11
|
+
* detection, a timeout plus the caller's cancellation, and a write-aware
|
|
12
|
+
* transport error.
|
|
13
|
+
*
|
|
14
|
+
* It composes the `http` module's pieces rather than re-deriving them:
|
|
15
|
+
* {@link detectEdgeBlock} / {@link EdgeBlockedError} for refusals in front of
|
|
16
|
+
* the API, {@link RetryPolicy} and `parseRetryAfterMs` for 429s,
|
|
17
|
+
* {@link UnauthorizedError} / {@link RateLimitedError} /
|
|
18
|
+
* {@link UpstreamHttpError} for the statuses `createApiClient` already names,
|
|
19
|
+
* `formatApiError` / `truncateErrorMessage` so no upstream body or message
|
|
20
|
+
* reaches a tool result unredacted, and `withAmbientCancellation` so a
|
|
21
|
+
* cancelled tool call stops its request.
|
|
22
|
+
*
|
|
23
|
+
* It is not built ON `createApiClient` because a GraphQL server's error
|
|
24
|
+
* answer is a JSON body at whatever status (Apollo validation errors are a
|
|
25
|
+
* 400, vibo's permission denials a 403) and `fetchJson` turns every non-2xx
|
|
26
|
+
* into a message string, losing the `errors[]` this layer exists to read.
|
|
27
|
+
*/
|
|
28
|
+
import { McpToolError } from '../errors/index.js';
|
|
29
|
+
import { type RateLimitContext, type RetryPolicy } from '../http/index.js';
|
|
30
|
+
/** One entry of a GraphQL response's `errors[]`. */
|
|
31
|
+
export interface GraphqlError {
|
|
32
|
+
message?: string;
|
|
33
|
+
/** Some servers (vibo) put the code at the top level… */
|
|
34
|
+
code?: string;
|
|
35
|
+
/** …the spec-blessed home is `extensions.code`. */
|
|
36
|
+
extensions?: {
|
|
37
|
+
code?: string;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
};
|
|
40
|
+
path?: ReadonlyArray<string | number>;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/** A GraphQL request. */
|
|
44
|
+
export interface GraphqlRequest {
|
|
45
|
+
/** The document. */
|
|
46
|
+
query: string;
|
|
47
|
+
/** Sent only when given. */
|
|
48
|
+
variables?: Record<string, unknown>;
|
|
49
|
+
/** Sent only when given. */
|
|
50
|
+
operationName?: string;
|
|
51
|
+
/** Extra headers for this request, merged over the client's. */
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Treat the request as safe to repeat even though the document contains a
|
|
55
|
+
* mutation — a sign-in or token refresh, say. It then gets a read's retry
|
|
56
|
+
* policy and a read's transport-error wording. Defaults to what
|
|
57
|
+
* {@link isReadOnlyGraphqlDocument} says about the document.
|
|
58
|
+
*/
|
|
59
|
+
idempotent?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** What {@link GraphqlClient.execute} returns: the parsed envelope plus the HTTP status. */
|
|
62
|
+
export interface GraphqlResult<T = unknown> {
|
|
63
|
+
status: number;
|
|
64
|
+
headers: Headers;
|
|
65
|
+
data?: T | null;
|
|
66
|
+
/** Normalized to an array of objects when present. */
|
|
67
|
+
errors?: GraphqlError[];
|
|
68
|
+
extensions?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/** What {@link GraphqlClientOptions.mapError} is shown. */
|
|
71
|
+
export interface GraphqlErrorContext {
|
|
72
|
+
status: number;
|
|
73
|
+
errors: readonly GraphqlError[];
|
|
74
|
+
data: unknown;
|
|
75
|
+
}
|
|
76
|
+
/** Options for {@link createGraphqlClient}. */
|
|
77
|
+
export interface GraphqlClientOptions {
|
|
78
|
+
/** Absolute URL of the GraphQL endpoint. */
|
|
79
|
+
endpoint: string;
|
|
80
|
+
/** Human name of the upstream, used in messages. Defaults to the endpoint's host. */
|
|
81
|
+
serviceName?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Headers sent on every request — a record, or a (possibly async) function
|
|
84
|
+
* re-read per request, which is where a rotating credential such as vibo's
|
|
85
|
+
* `x-token` belongs. A request's own `headers` override these.
|
|
86
|
+
*/
|
|
87
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
88
|
+
/**
|
|
89
|
+
* Per-attempt timeout in ms, from the request until the body is read.
|
|
90
|
+
* Defaults to 30 000 (both copies used 30 s); `0` disables it. The caller's
|
|
91
|
+
* cancellation applies either way.
|
|
92
|
+
*/
|
|
93
|
+
timeout?: number;
|
|
94
|
+
/**
|
|
95
|
+
* 429 retry policy, as `createApiClient`'s: defaults to one retry after 2 s.
|
|
96
|
+
* Other `statuses` (transient 5xx) are retried only for a read-only or
|
|
97
|
+
* `idempotent` request — a 5xx on a mutation may have committed it. A 429
|
|
98
|
+
* is retried for a write too: a rate-limited request was refused, not run.
|
|
99
|
+
*/
|
|
100
|
+
retry?: RetryPolicy;
|
|
101
|
+
/**
|
|
102
|
+
* Whether a response is an expired / missing session. Defaults to
|
|
103
|
+
* {@link isGraphqlAuthError}: HTTP 401, or an `UNAUTHENTICATED` /
|
|
104
|
+
* `UNAUTHORIZED` code. Never consulted for a CDN/WAF refusal.
|
|
105
|
+
*/
|
|
106
|
+
isAuthError?: (status: number, errors: readonly GraphqlError[]) => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Re-authenticate after an auth failure (refresh the token, log in again).
|
|
109
|
+
* When set, the request is replayed ONCE with freshly read headers; a second
|
|
110
|
+
* auth failure throws. Single-flighting concurrent refreshes is the
|
|
111
|
+
* caller's job (a `TokenManager` or `createCachedTokenSource` does it).
|
|
112
|
+
*/
|
|
113
|
+
onAuthError?: () => Promise<void> | void;
|
|
114
|
+
/** The error an unrecovered auth failure throws. Defaults to {@link UnauthorizedError}. */
|
|
115
|
+
onUnauthorized?: () => Error;
|
|
116
|
+
/**
|
|
117
|
+
* The error an exhausted 429 throws. Defaults to {@link RateLimitedError}.
|
|
118
|
+
* Receives the same {@link RateLimitContext} as `createApiClient`'s hook
|
|
119
|
+
* (`edgeBlock` is always `null` here: an edge-refused 429 has already thrown
|
|
120
|
+
* {@link EdgeBlockedError}). A zero-argument hook still works.
|
|
121
|
+
*/
|
|
122
|
+
onRateLimited?: (ctx: RateLimitContext) => Error;
|
|
123
|
+
/**
|
|
124
|
+
* Claim a failed response before the default mapping — return an error to
|
|
125
|
+
* throw it, or `undefined` to fall through. Runs after any auth replay, on
|
|
126
|
+
* every response {@link GraphqlClient.request} would otherwise reject (and
|
|
127
|
+
* on none it would accept). The place for site rules such as vibo's
|
|
128
|
+
* "FORBIDDEN / HTTP 403 is a permission denial, not an expired session".
|
|
129
|
+
*/
|
|
130
|
+
mapError?: (ctx: GraphqlErrorContext) => Error | undefined;
|
|
131
|
+
/** Hint attached to the {@link GraphqlResponseError} for an `errors[]` answer. */
|
|
132
|
+
errorHint?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Hint for a write whose outcome is unknown (timed out / connection dropped
|
|
135
|
+
* after sending). Name the tool that checks the state.
|
|
136
|
+
*/
|
|
137
|
+
writeOutcomeHint?: string;
|
|
138
|
+
/** Injectable fetch. Defaults to the global `fetch`. */
|
|
139
|
+
fetchImpl?: typeof fetch;
|
|
140
|
+
/** Injectable sleep for retries (tests). */
|
|
141
|
+
sleep?: (ms: number) => Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
/** The client surface {@link createGraphqlClient} returns. */
|
|
144
|
+
export interface GraphqlClient {
|
|
145
|
+
/**
|
|
146
|
+
* Send a request and return its parsed envelope, `errors[]` and all — for a
|
|
147
|
+
* raw passthrough tool that shows the caller what the server said. Still
|
|
148
|
+
* throws for everything that is not a GraphQL answer: a transport failure,
|
|
149
|
+
* a CDN/WAF refusal, an exhausted 429, or a body that is not a GraphQL
|
|
150
|
+
* response object (a non-JSON error page is an {@link UpstreamHttpError}).
|
|
151
|
+
* An auth failure is replayed once when `onAuthError` is set, then
|
|
152
|
+
* returned as-is.
|
|
153
|
+
*/
|
|
154
|
+
execute<T = unknown>(request: GraphqlRequest): Promise<GraphqlResult<T>>;
|
|
155
|
+
/**
|
|
156
|
+
* Send a request and return its `data`, throwing for any failure: the
|
|
157
|
+
* `execute` failures, an auth failure ({@link UnauthorizedError} or
|
|
158
|
+
* `onUnauthorized`), `errors[]` ({@link GraphqlResponseError}, even beside
|
|
159
|
+
* partial data), a JSON non-2xx with no `errors[]`
|
|
160
|
+
* ({@link UpstreamHttpError}), or a response with no data.
|
|
161
|
+
*/
|
|
162
|
+
request<T = unknown>(query: string, variables?: Record<string, unknown>, opts?: Omit<GraphqlRequest, 'query' | 'variables'>): Promise<T>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The server answered, but with GraphQL `errors[]` (or with something that is
|
|
166
|
+
* not a GraphQL response at all — then `errors` is empty). The message joins
|
|
167
|
+
* the messages, redacted and truncated; the raw entries, any partial `data`,
|
|
168
|
+
* and the codes ride along for callers that branch.
|
|
169
|
+
*/
|
|
170
|
+
export declare class GraphqlResponseError extends McpToolError {
|
|
171
|
+
readonly status: number;
|
|
172
|
+
readonly errors: readonly GraphqlError[];
|
|
173
|
+
readonly data: unknown;
|
|
174
|
+
/** Every `code` / `extensions.code` present, in order. */
|
|
175
|
+
readonly codes: readonly string[];
|
|
176
|
+
constructor(message: string, details: {
|
|
177
|
+
status: number;
|
|
178
|
+
errors?: readonly GraphqlError[];
|
|
179
|
+
data?: unknown;
|
|
180
|
+
hint?: string;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The request never produced a response: it timed out, or the connection
|
|
185
|
+
* failed. For a read that is safe to retry. For a write the outcome is
|
|
186
|
+
* UNKNOWN — the server may already have committed it — so `outcomeUnknown` is
|
|
187
|
+
* set, the message says so, and the hint asks for a state check before any
|
|
188
|
+
* retry (a confirmation gate cannot stop a blind retry: a fresh preview earns
|
|
189
|
+
* a fresh approval). A caller's cancellation is not this error; its abort is
|
|
190
|
+
* rethrown untouched.
|
|
191
|
+
*/
|
|
192
|
+
export declare class GraphqlTransportError extends McpToolError {
|
|
193
|
+
readonly timedOut: boolean;
|
|
194
|
+
readonly outcomeUnknown: boolean;
|
|
195
|
+
constructor(message: string, details: {
|
|
196
|
+
timedOut: boolean;
|
|
197
|
+
outcomeUnknown: boolean;
|
|
198
|
+
hint: string;
|
|
199
|
+
cause: unknown;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/** The error code of one `errors[]` entry: top-level `code`, else `extensions.code`. */
|
|
203
|
+
export declare function graphqlErrorCode(error: GraphqlError): string | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* The default expired-session test: HTTP 401, or an `UNAUTHENTICATED` /
|
|
206
|
+
* `UNAUTHORIZED` code. `FORBIDDEN` is deliberately not one — it is a
|
|
207
|
+
* permission denial, and refreshing a token cannot fix it.
|
|
208
|
+
*/
|
|
209
|
+
export declare function isGraphqlAuthError(status: number, errors: readonly GraphqlError[]): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Build a GraphQL-over-HTTP client: POST `{ query, variables?, operationName? }`
|
|
212
|
+
* as JSON, read `errors[]` at any status, and map every other outcome onto the
|
|
213
|
+
* package's existing error types. See {@link GraphqlClient} for what each
|
|
214
|
+
* method throws and {@link GraphqlClientOptions} for the hooks.
|
|
215
|
+
*
|
|
216
|
+
* ```ts
|
|
217
|
+
* const gql = createGraphqlClient({
|
|
218
|
+
* endpoint: 'https://api.vibodj.com/v2/graphql',
|
|
219
|
+
* serviceName: 'Vibo',
|
|
220
|
+
* headers: async () => ({ 'x-token': await tokens.current() }),
|
|
221
|
+
* onAuthError: () => tokens.refresh(),
|
|
222
|
+
* onUnauthorized: () => new SessionNotAuthenticatedError('Vibo', 'https://web.vibodj.com'),
|
|
223
|
+
* });
|
|
224
|
+
* const { me } = await gql.request<{ me: { id: string } }>('query Me { me { id } }');
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export declare function createGraphqlClient(opts: GraphqlClientOptions): GraphqlClient;
|
|
228
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/graphql/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,YAAY,EAAmC,MAAM,o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AC,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAGxE;AAID;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,OAAO,CAM3F;AA6DD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,aAAa,CAgL7E"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createGraphqlClient` — the GraphQL-over-HTTP POST transport.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates the hand-rolled GraphQL clients in vibo-mcp (`src/client.ts`
|
|
5
|
+
* `ViboClient.post` / `readGraphQLBody` / `unwrap` / `transportError`, the
|
|
6
|
+
* reference implementation) and thumbtack-mcp (`src/client.ts`
|
|
7
|
+
* `ThumbtackClient.graphql`) — chrischall/fleet-audit#1138, #1128. Both POST
|
|
8
|
+
* `{ query, variables }`, treat `errors[]` on an HTTP 200 as a failure, join
|
|
9
|
+
* and truncate the messages, and refuse a non-JSON 2xx as a challenge page;
|
|
10
|
+
* vibo adds auth-code classification, a refresh-and-replay-once, CDN/WAF
|
|
11
|
+
* detection, a timeout plus the caller's cancellation, and a write-aware
|
|
12
|
+
* transport error.
|
|
13
|
+
*
|
|
14
|
+
* It composes the `http` module's pieces rather than re-deriving them:
|
|
15
|
+
* {@link detectEdgeBlock} / {@link EdgeBlockedError} for refusals in front of
|
|
16
|
+
* the API, {@link RetryPolicy} and `parseRetryAfterMs` for 429s,
|
|
17
|
+
* {@link UnauthorizedError} / {@link RateLimitedError} /
|
|
18
|
+
* {@link UpstreamHttpError} for the statuses `createApiClient` already names,
|
|
19
|
+
* `formatApiError` / `truncateErrorMessage` so no upstream body or message
|
|
20
|
+
* reaches a tool result unredacted, and `withAmbientCancellation` so a
|
|
21
|
+
* cancelled tool call stops its request.
|
|
22
|
+
*
|
|
23
|
+
* It is not built ON `createApiClient` because a GraphQL server's error
|
|
24
|
+
* answer is a JSON body at whatever status (Apollo validation errors are a
|
|
25
|
+
* 400, vibo's permission denials a 403) and `fetchJson` turns every non-2xx
|
|
26
|
+
* into a message string, losing the `errors[]` this layer exists to read.
|
|
27
|
+
*/
|
|
28
|
+
import { withAmbientCancellation } from '../cancel/index.js';
|
|
29
|
+
import { McpToolError, messageOf, truncateErrorMessage } from '../errors/index.js';
|
|
30
|
+
import { EdgeBlockedError, RateLimitedError, UnauthorizedError, UpstreamHttpError, detectEdgeBlock, formatApiError, parseRetryAfterMs, } from '../http/index.js';
|
|
31
|
+
import { retryAfterToMs } from '../internal/retry-after.js';
|
|
32
|
+
import { isReadOnlyGraphqlDocument } from './operation-kind.js';
|
|
33
|
+
/**
|
|
34
|
+
* The server answered, but with GraphQL `errors[]` (or with something that is
|
|
35
|
+
* not a GraphQL response at all — then `errors` is empty). The message joins
|
|
36
|
+
* the messages, redacted and truncated; the raw entries, any partial `data`,
|
|
37
|
+
* and the codes ride along for callers that branch.
|
|
38
|
+
*/
|
|
39
|
+
export class GraphqlResponseError extends McpToolError {
|
|
40
|
+
status;
|
|
41
|
+
errors;
|
|
42
|
+
data;
|
|
43
|
+
/** Every `code` / `extensions.code` present, in order. */
|
|
44
|
+
codes;
|
|
45
|
+
constructor(message, details) {
|
|
46
|
+
super(message, details.hint !== undefined ? { hint: details.hint } : undefined);
|
|
47
|
+
this.name = 'GraphqlResponseError';
|
|
48
|
+
this.status = details.status;
|
|
49
|
+
this.errors = details.errors ?? [];
|
|
50
|
+
this.data = details.data;
|
|
51
|
+
this.codes = this.errors.map(graphqlErrorCode).filter((c) => c !== undefined);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The request never produced a response: it timed out, or the connection
|
|
56
|
+
* failed. For a read that is safe to retry. For a write the outcome is
|
|
57
|
+
* UNKNOWN — the server may already have committed it — so `outcomeUnknown` is
|
|
58
|
+
* set, the message says so, and the hint asks for a state check before any
|
|
59
|
+
* retry (a confirmation gate cannot stop a blind retry: a fresh preview earns
|
|
60
|
+
* a fresh approval). A caller's cancellation is not this error; its abort is
|
|
61
|
+
* rethrown untouched.
|
|
62
|
+
*/
|
|
63
|
+
export class GraphqlTransportError extends McpToolError {
|
|
64
|
+
timedOut;
|
|
65
|
+
outcomeUnknown;
|
|
66
|
+
constructor(message, details) {
|
|
67
|
+
super(message, { hint: details.hint, cause: details.cause });
|
|
68
|
+
this.name = 'GraphqlTransportError';
|
|
69
|
+
this.timedOut = details.timedOut;
|
|
70
|
+
this.outcomeUnknown = details.outcomeUnknown;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** The error code of one `errors[]` entry: top-level `code`, else `extensions.code`. */
|
|
74
|
+
export function graphqlErrorCode(error) {
|
|
75
|
+
const code = error.code ?? error.extensions?.code;
|
|
76
|
+
return typeof code === 'string' ? code : undefined;
|
|
77
|
+
}
|
|
78
|
+
const AUTH_CODES = new Set(['UNAUTHENTICATED', 'UNAUTHORIZED']);
|
|
79
|
+
/**
|
|
80
|
+
* The default expired-session test: HTTP 401, or an `UNAUTHENTICATED` /
|
|
81
|
+
* `UNAUTHORIZED` code. `FORBIDDEN` is deliberately not one — it is a
|
|
82
|
+
* permission denial, and refreshing a token cannot fix it.
|
|
83
|
+
*/
|
|
84
|
+
export function isGraphqlAuthError(status, errors) {
|
|
85
|
+
if (status === 401)
|
|
86
|
+
return true;
|
|
87
|
+
return errors.some((e) => {
|
|
88
|
+
const code = graphqlErrorCode(e);
|
|
89
|
+
return code !== undefined && AUTH_CODES.has(code);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
93
|
+
const DEFAULT_RETRY = { count: 1, delayMs: 2000 };
|
|
94
|
+
const defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
95
|
+
/** Thrown internally when our own timer fired. */
|
|
96
|
+
class TimedOut extends Error {
|
|
97
|
+
}
|
|
98
|
+
function objectOf(value) {
|
|
99
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
100
|
+
? value
|
|
101
|
+
: undefined;
|
|
102
|
+
}
|
|
103
|
+
/** `errors` as an array of objects, whatever shape the server sent. */
|
|
104
|
+
function normalizeErrors(raw) {
|
|
105
|
+
if (raw === undefined || raw === null)
|
|
106
|
+
return undefined;
|
|
107
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
108
|
+
return list.map((e) => {
|
|
109
|
+
const obj = objectOf(e);
|
|
110
|
+
if (obj)
|
|
111
|
+
return obj;
|
|
112
|
+
return { message: typeof e === 'string' ? e : String(e) };
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** Parse a body into a GraphQL envelope, or `undefined` when it is not one. */
|
|
116
|
+
function parseEnvelope(text) {
|
|
117
|
+
let parsed;
|
|
118
|
+
try {
|
|
119
|
+
parsed = JSON.parse(text);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
const obj = objectOf(parsed);
|
|
125
|
+
if (!obj)
|
|
126
|
+
return undefined;
|
|
127
|
+
const errors = normalizeErrors(obj.errors);
|
|
128
|
+
const extensions = objectOf(obj.extensions);
|
|
129
|
+
return {
|
|
130
|
+
...('data' in obj ? { data: obj.data } : {}),
|
|
131
|
+
...(errors !== undefined ? { errors } : {}),
|
|
132
|
+
...(extensions !== undefined ? { extensions } : {}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function hostOf(url) {
|
|
136
|
+
try {
|
|
137
|
+
return new URL(url).host;
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return url;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function pathOf(url) {
|
|
144
|
+
try {
|
|
145
|
+
return new URL(url).pathname;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return url;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Build a GraphQL-over-HTTP client: POST `{ query, variables?, operationName? }`
|
|
153
|
+
* as JSON, read `errors[]` at any status, and map every other outcome onto the
|
|
154
|
+
* package's existing error types. See {@link GraphqlClient} for what each
|
|
155
|
+
* method throws and {@link GraphqlClientOptions} for the hooks.
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* const gql = createGraphqlClient({
|
|
159
|
+
* endpoint: 'https://api.vibodj.com/v2/graphql',
|
|
160
|
+
* serviceName: 'Vibo',
|
|
161
|
+
* headers: async () => ({ 'x-token': await tokens.current() }),
|
|
162
|
+
* onAuthError: () => tokens.refresh(),
|
|
163
|
+
* onUnauthorized: () => new SessionNotAuthenticatedError('Vibo', 'https://web.vibodj.com'),
|
|
164
|
+
* });
|
|
165
|
+
* const { me } = await gql.request<{ me: { id: string } }>('query Me { me { id } }');
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export function createGraphqlClient(opts) {
|
|
169
|
+
const service = opts.serviceName ?? hostOf(opts.endpoint);
|
|
170
|
+
const path = pathOf(opts.endpoint);
|
|
171
|
+
const doFetch = opts.fetchImpl ?? fetch;
|
|
172
|
+
const sleep = opts.sleep ?? defaultSleep;
|
|
173
|
+
const timeoutMs = opts.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
174
|
+
const retry = opts.retry ?? DEFAULT_RETRY;
|
|
175
|
+
const retryStatuses = retry.statuses ?? [429];
|
|
176
|
+
const isAuth = opts.isAuthError ?? isGraphqlAuthError;
|
|
177
|
+
async function headersFor(req) {
|
|
178
|
+
const base = typeof opts.headers === 'function' ? await opts.headers() : (opts.headers ?? {});
|
|
179
|
+
return { 'content-type': 'application/json', accept: 'application/json', ...base, ...req.headers };
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* One HTTP attempt, bounded from the request until the body has been read.
|
|
183
|
+
* The read is RACED against the timer rather than trusting the body stream
|
|
184
|
+
* to honour the abort, so a `fetchImpl` that ignores the signal is bounded
|
|
185
|
+
* too.
|
|
186
|
+
*/
|
|
187
|
+
async function attempt(init) {
|
|
188
|
+
const controller = timeoutMs > 0 ? new AbortController() : undefined;
|
|
189
|
+
let timer;
|
|
190
|
+
let expired;
|
|
191
|
+
if (controller) {
|
|
192
|
+
expired = new Promise((_resolve, reject) => {
|
|
193
|
+
controller.signal.addEventListener('abort', () => reject(new TimedOut()), { once: true });
|
|
194
|
+
});
|
|
195
|
+
expired.catch(() => { });
|
|
196
|
+
timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
197
|
+
}
|
|
198
|
+
const signal = withAmbientCancellation(controller?.signal);
|
|
199
|
+
const work = (async () => {
|
|
200
|
+
const res = await doFetch(opts.endpoint, { ...init, ...(signal ? { signal } : {}) });
|
|
201
|
+
return { res, text: await res.text() };
|
|
202
|
+
})();
|
|
203
|
+
work.catch(() => { });
|
|
204
|
+
try {
|
|
205
|
+
return await (expired ? Promise.race([work, expired]) : work);
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
// Told apart by WHICH signal fired: an abort is an `AbortError` whichever
|
|
209
|
+
// end caused it, and a caller's cancellation is not this service timing out.
|
|
210
|
+
if (controller?.signal.aborted)
|
|
211
|
+
throw new TimedOut();
|
|
212
|
+
throw err;
|
|
213
|
+
}
|
|
214
|
+
finally {
|
|
215
|
+
clearTimeout(timer);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function transportError(err, timedOut, write) {
|
|
219
|
+
const what = timedOut
|
|
220
|
+
? `Request to ${service} timed out after ${timeoutMs}ms`
|
|
221
|
+
: `Request to ${service} failed: ${truncateErrorMessage(messageOf(err), 200)}`;
|
|
222
|
+
if (write) {
|
|
223
|
+
return new GraphqlTransportError(`${what} — the change may already have been applied (outcome is unknown).`, {
|
|
224
|
+
timedOut,
|
|
225
|
+
outcomeUnknown: true,
|
|
226
|
+
hint: opts.writeOutcomeHint ??
|
|
227
|
+
'Do not repeat this write blindly — check the current state first, and retry only if the change is not there.',
|
|
228
|
+
cause: err,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return new GraphqlTransportError(`${what}.`, {
|
|
232
|
+
timedOut,
|
|
233
|
+
outcomeUnknown: false,
|
|
234
|
+
hint: `The ${service} API may be slow or unreachable — check your connection and retry.`,
|
|
235
|
+
cause: err,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/** Send with the retry policy; returns the final response and its body. */
|
|
239
|
+
async function send(req, write) {
|
|
240
|
+
const body = JSON.stringify({
|
|
241
|
+
query: req.query,
|
|
242
|
+
...(req.variables !== undefined ? { variables: req.variables } : {}),
|
|
243
|
+
...(req.operationName !== undefined ? { operationName: req.operationName } : {}),
|
|
244
|
+
});
|
|
245
|
+
for (let tries = 0;; tries++) {
|
|
246
|
+
let sent;
|
|
247
|
+
try {
|
|
248
|
+
sent = await attempt({ method: 'POST', headers: await headersFor(req), body });
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
if (err instanceof TimedOut)
|
|
252
|
+
throw transportError(err, true, write);
|
|
253
|
+
if (err instanceof Error && err.name === 'AbortError')
|
|
254
|
+
throw err; // the caller cancelled
|
|
255
|
+
throw transportError(err, false, write);
|
|
256
|
+
}
|
|
257
|
+
const status = sent.res.status;
|
|
258
|
+
const retryable = retryStatuses.includes(status) && (status === 429 || !write);
|
|
259
|
+
if (retryable && tries < retry.count) {
|
|
260
|
+
const delay = retry.honorRetryAfter
|
|
261
|
+
? parseRetryAfterMs(sent.res.headers.get('retry-after'), {
|
|
262
|
+
defaultMs: retry.delayMs,
|
|
263
|
+
capMs: retry.maxRetryAfterMs ?? 30_000,
|
|
264
|
+
})
|
|
265
|
+
: retry.delayMs;
|
|
266
|
+
await sleep(delay);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
return sent;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async function execute(req) {
|
|
273
|
+
const write = req.idempotent === true ? false : !isReadOnlyGraphqlDocument(req.query);
|
|
274
|
+
for (let replayed = false;; replayed = true) {
|
|
275
|
+
const { res, text } = await send(req, write);
|
|
276
|
+
const status = res.status;
|
|
277
|
+
if (status >= 400) {
|
|
278
|
+
const edge = detectEdgeBlock({ body: text, headers: res.headers, status });
|
|
279
|
+
if (edge)
|
|
280
|
+
throw new EdgeBlockedError(status, edge.vendor, { service, method: 'POST', path });
|
|
281
|
+
}
|
|
282
|
+
if (status === 429) {
|
|
283
|
+
const retryAfter = res.headers.get('retry-after');
|
|
284
|
+
const retryAfterMs = retryAfterToMs(retryAfter);
|
|
285
|
+
throw opts.onRateLimited
|
|
286
|
+
? opts.onRateLimited({ status, retryAfter, retryAfterMs, edgeBlock: null, method: 'POST', path })
|
|
287
|
+
: new RateLimitedError(service, retryAfterMs);
|
|
288
|
+
}
|
|
289
|
+
const envelope = parseEnvelope(text);
|
|
290
|
+
if (envelope === undefined) {
|
|
291
|
+
if (status >= 400 && status !== 401) {
|
|
292
|
+
throw new UpstreamHttpError(status, formatApiError(status, 'POST', path, text, { service }));
|
|
293
|
+
}
|
|
294
|
+
if (status < 400) {
|
|
295
|
+
const edge = detectEdgeBlock({ body: text, headers: res.headers, status });
|
|
296
|
+
if (edge)
|
|
297
|
+
throw new EdgeBlockedError(status, edge.vendor, { service, method: 'POST', path });
|
|
298
|
+
throw new GraphqlResponseError(text.trim().length === 0
|
|
299
|
+
? `${service} GraphQL API returned an empty response (HTTP ${status}).`
|
|
300
|
+
: `${service} GraphQL API returned a non-JSON body (HTTP ${status}) — this is usually a challenge or error page, not data.`, { status, hint: 'Retry shortly. If it persists, the endpoint or its request shape has changed.' });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const result = { status, headers: res.headers, ...envelope };
|
|
304
|
+
if (!replayed && opts.onAuthError && isAuth(status, result.errors ?? [])) {
|
|
305
|
+
await opts.onAuthError();
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
return result;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
async function request(query, variables, more = {}) {
|
|
312
|
+
const result = await execute({ ...more, query, ...(variables !== undefined ? { variables } : {}) });
|
|
313
|
+
const { status, data } = result;
|
|
314
|
+
const errors = result.errors ?? [];
|
|
315
|
+
const failed = errors.length > 0 || status >= 400 || data === undefined || data === null;
|
|
316
|
+
if (failed && opts.mapError) {
|
|
317
|
+
const mapped = opts.mapError({ status, errors, data });
|
|
318
|
+
if (mapped)
|
|
319
|
+
throw mapped;
|
|
320
|
+
}
|
|
321
|
+
if (isAuth(status, errors))
|
|
322
|
+
throw opts.onUnauthorized ? opts.onUnauthorized() : new UnauthorizedError(service);
|
|
323
|
+
if (errors.length > 0) {
|
|
324
|
+
const detail = errors.map((e) => (typeof e.message === 'string' && e.message ? e.message : 'Unknown error')).join('; ');
|
|
325
|
+
throw new GraphqlResponseError(`${service} GraphQL error: ${truncateErrorMessage(detail)}`, {
|
|
326
|
+
status,
|
|
327
|
+
errors,
|
|
328
|
+
data,
|
|
329
|
+
...(opts.errorHint !== undefined ? { hint: opts.errorHint } : {}),
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
if (status >= 400)
|
|
333
|
+
throw new UpstreamHttpError(status, `${service} GraphQL API returned HTTP ${status}.`);
|
|
334
|
+
if (data === undefined || data === null) {
|
|
335
|
+
throw new GraphqlResponseError(`${service} GraphQL API returned an empty response.`, { status });
|
|
336
|
+
}
|
|
337
|
+
return data;
|
|
338
|
+
}
|
|
339
|
+
return { execute, request };
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/graphql/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;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,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chrischall/mcp-utils/graphql` — a GraphQL-over-HTTP transport and a
|
|
3
|
+
* GraphQL operation-kind lexer.
|
|
4
|
+
*
|
|
5
|
+
* Zero optional peers (it builds on the core `http`, `errors` and `cancel`
|
|
6
|
+
* modules only). It is a subpath rather than part of the core barrel for the
|
|
7
|
+
* same reason `/healthcheck` is: only the handful of GraphQL servers in the
|
|
8
|
+
* fleet need it.
|
|
9
|
+
*
|
|
10
|
+
* - {@link createGraphqlClient} — POST `{ query, variables, operationName }`,
|
|
11
|
+
* `errors[]` at any status, auth replay, CDN/WAF detection, timeout and
|
|
12
|
+
* cancellation, write-aware transport errors (vibo-mcp / thumbtack-mcp,
|
|
13
|
+
* chrischall/fleet-audit#1138, #1128).
|
|
14
|
+
* - {@link graphqlOperationKinds} / {@link isReadOnlyGraphqlDocument} — is a
|
|
15
|
+
* document a query, mutation or subscription (onehome-mcp / hemnet-mcp /
|
|
16
|
+
* booli-mcp / vibo-mcp, chrischall/fleet-audit#1080, #988, #1020).
|
|
17
|
+
*/
|
|
18
|
+
export * from './client.js';
|
|
19
|
+
export * from './operation-kind.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chrischall/mcp-utils/graphql` — a GraphQL-over-HTTP transport and a
|
|
3
|
+
* GraphQL operation-kind lexer.
|
|
4
|
+
*
|
|
5
|
+
* Zero optional peers (it builds on the core `http`, `errors` and `cancel`
|
|
6
|
+
* modules only). It is a subpath rather than part of the core barrel for the
|
|
7
|
+
* same reason `/healthcheck` is: only the handful of GraphQL servers in the
|
|
8
|
+
* fleet need it.
|
|
9
|
+
*
|
|
10
|
+
* - {@link createGraphqlClient} — POST `{ query, variables, operationName }`,
|
|
11
|
+
* `errors[]` at any status, auth replay, CDN/WAF detection, timeout and
|
|
12
|
+
* cancellation, write-aware transport errors (vibo-mcp / thumbtack-mcp,
|
|
13
|
+
* chrischall/fleet-audit#1138, #1128).
|
|
14
|
+
* - {@link graphqlOperationKinds} / {@link isReadOnlyGraphqlDocument} — is a
|
|
15
|
+
* document a query, mutation or subscription (onehome-mcp / hemnet-mcp /
|
|
16
|
+
* booli-mcp / vibo-mcp, chrischall/fleet-audit#1080, #988, #1020).
|
|
17
|
+
*/
|
|
18
|
+
export * from './client.js';
|
|
19
|
+
export * from './operation-kind.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
|