@anyknown/mcp 0.2.0 → 0.3.1
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 +11 -57
- package/dist/catalog/types.d.ts +1 -1
- package/dist/portable/public-types.d.ts +27 -0
- package/dist/public.d.ts +1 -1
- package/dist/rpc/hub-rpc.d.ts +1 -2
- package/dist/rpc/types.d.ts +2 -5
- package/dist/schema.d.ts +1 -2
- package/package.json +1 -1
- package/dist/client/constants.d.ts +0 -3
- package/dist/client/handshake.d.ts +0 -2
- package/dist/client/headers-for.d.ts +0 -2
- package/dist/client/index.d.ts +0 -6
- package/dist/client/joined-data-lines.d.ts +0 -1
- package/dist/client/message-matching-id.d.ts +0 -2
- package/dist/client/notify.d.ts +0 -2
- package/dist/client/parse-body.d.ts +0 -2
- package/dist/client/parse-challenge.d.ts +0 -2
- package/dist/client/read-sse.d.ts +0 -2
- package/dist/client/rpc.d.ts +0 -2
- package/dist/client/send.d.ts +0 -2
- package/dist/client/types.d.ts +0 -25
- package/dist/portable/apply-auth.d.ts +0 -5
- package/dist/portable/args-errors.d.ts +0 -2
- package/dist/portable/call-tool.d.ts +0 -6
- package/dist/portable/constants.d.ts +0 -16
- package/dist/portable/fetch-document.d.ts +0 -1
- package/dist/portable/graphql/args-schema.d.ts +0 -5
- package/dist/portable/graphql/call-graphql.d.ts +0 -2
- package/dist/portable/graphql/constants.d.ts +0 -15
- package/dist/portable/graphql/default-selection.d.ts +0 -2
- package/dist/portable/graphql/field-tool.d.ts +0 -4
- package/dist/portable/graphql/index.d.ts +0 -2
- package/dist/portable/graphql/input-defs.d.ts +0 -2
- package/dist/portable/graphql/input-schema.d.ts +0 -2
- package/dist/portable/graphql/introspect.d.ts +0 -3
- package/dist/portable/graphql/introspected-schema.d.ts +0 -2
- package/dist/portable/graphql/json-of.d.ts +0 -1
- package/dist/portable/graphql/or-null.d.ts +0 -1
- package/dist/portable/graphql/post-graphql.d.ts +0 -2
- package/dist/portable/graphql/query-document.d.ts +0 -2
- package/dist/portable/graphql/read-graphql.d.ts +0 -6
- package/dist/portable/graphql/schema.d.ts +0 -14
- package/dist/portable/graphql/sdl-schema.d.ts +0 -2
- package/dist/portable/graphql/single-root-field.d.ts +0 -3
- package/dist/portable/graphql/type-schema.d.ts +0 -3
- package/dist/portable/graphql/types.d.ts +0 -9
- package/dist/portable/index.d.ts +0 -15
- package/dist/portable/mcp/call-mcp-tool.d.ts +0 -6
- package/dist/portable/mcp/index.d.ts +0 -4
- package/dist/portable/mcp/list-mcp-tools.d.ts +0 -6
- package/dist/portable/mcp/mcp-request.d.ts +0 -6
- package/dist/portable/mcp/schema.d.ts +0 -11
- package/dist/portable/mcp/types.d.ts +0 -4
- package/dist/portable/oauth/authorize-url.d.ts +0 -7
- package/dist/portable/oauth/b64url.d.ts +0 -1
- package/dist/portable/oauth/client-basic.d.ts +0 -1
- package/dist/portable/oauth/constants.d.ts +0 -1
- package/dist/portable/oauth/discover.d.ts +0 -3
- package/dist/portable/oauth/exchange-code.d.ts +0 -9
- package/dist/portable/oauth/get-json.d.ts +0 -2
- package/dist/portable/oauth/index.d.ts +0 -11
- package/dist/portable/oauth/issuer-mismatch.d.ts +0 -1
- package/dist/portable/oauth/metadata-urls.d.ts +0 -1
- package/dist/portable/oauth/pick-scope.d.ts +0 -2
- package/dist/portable/oauth/pkce.d.ts +0 -4
- package/dist/portable/oauth/post-token.d.ts +0 -2
- package/dist/portable/oauth/protected-resource-url.d.ts +0 -1
- package/dist/portable/oauth/random-state.d.ts +0 -1
- package/dist/portable/oauth/read-metadata.d.ts +0 -8
- package/dist/portable/oauth/refresh-tokens.d.ts +0 -7
- package/dist/portable/oauth/register-client.d.ts +0 -2
- package/dist/portable/oauth/schema.d.ts +0 -20
- package/dist/portable/oauth/types.d.ts +0 -12
- package/dist/portable/openapi/annotations-for.d.ts +0 -4
- package/dist/portable/openapi/append-params.d.ts +0 -1
- package/dist/portable/openapi/call-openapi.d.ts +0 -2
- package/dist/portable/openapi/collect-defs.d.ts +0 -2
- package/dist/portable/openapi/constants.d.ts +0 -6
- package/dist/portable/openapi/discovered-oauth.d.ts +0 -2
- package/dist/portable/openapi/has-cyclic-alias.d.ts +0 -2
- package/dist/portable/openapi/index.d.ts +0 -2
- package/dist/portable/openapi/input-schema.d.ts +0 -2
- package/dist/portable/openapi/merged-parameters.d.ts +0 -2
- package/dist/portable/openapi/operation-tool.d.ts +0 -3
- package/dist/portable/openapi/operations-of.d.ts +0 -2
- package/dist/portable/openapi/param-group.d.ts +0 -2
- package/dist/portable/openapi/parse-document.d.ts +0 -2
- package/dist/portable/openapi/path-segment.d.ts +0 -1
- package/dist/portable/openapi/read-openapi.d.ts +0 -6
- package/dist/portable/openapi/request-body-schema.d.ts +0 -2
- package/dist/portable/openapi/request-body.d.ts +0 -5
- package/dist/portable/openapi/request-headers.d.ts +0 -2
- package/dist/portable/openapi/request-url.d.ts +0 -2
- package/dist/portable/openapi/resolve-ref.d.ts +0 -1
- package/dist/portable/openapi/rewrite-refs.d.ts +0 -1
- package/dist/portable/openapi/schema.d.ts +0 -66
- package/dist/portable/openapi/spec-defaults.d.ts +0 -3
- package/dist/portable/openapi/tool-name.d.ts +0 -1
- package/dist/portable/openapi/types.d.ts +0 -27
- package/dist/portable/openapi/unique-names.d.ts +0 -1
- package/dist/portable/openapi/yaml-value.d.ts +0 -1
- package/dist/portable/read-capped.d.ts +0 -4
- package/dist/portable/read-tools.d.ts +0 -2
- package/dist/portable/stale-tool-names.d.ts +0 -2
- package/dist/portable/text-result.d.ts +0 -5
- package/dist/portable/tool-rows-of.d.ts +0 -2
- package/dist/portable/types.d.ts +0 -92
package/README.md
CHANGED
|
@@ -1,65 +1,19 @@
|
|
|
1
|
-
# anyknown/mcp
|
|
1
|
+
# @anyknown/mcp
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Each server has one `auth`: `none`, `bearer`, `api_key` (a header or query parameter whose name comes with create or from the spec's `apiKey` security scheme), `basic` or `oauth`; `mcp` servers take only `oauth`, `bearer` and `none`. OAuth always uses PKCE and product's `/api/mcp/callback` as the redirect URI:
|
|
6
|
-
|
|
7
|
-
- `mcp` discovers the authorization server from the 401 challenge's resource metadata (or the server's well-known protected resource URL), identifies itself with a client ID metadata document when the server supports it and dynamic registration otherwise, sends `resource`, and rediscovers on refresh.
|
|
8
|
-
- `openapi` and `graphql` use the user's own OAuth app. The client id and optional client secret come with connect; the authorize and token endpoints and the scopes come with create, or else from the spec's `oauth2` authorization code flow or its `openIdConnect` discovery document, and it is `invalid` when neither has them. The hub sends no `resource`, doesn't check `iss` (there is no issuer to compare), authenticates with `client_secret_basic` when there is a secret, and refreshes against the stored token endpoint without discovery.
|
|
9
|
-
|
|
10
|
-
It has no public URL. The only way in is product's `MCP` service binding, which calls the `Hub` `WorkerEntrypoint` over RPC (`src/rpc/`). Product owns authentication, scope checks (`mcp:use`, `product:admin`), request validation, activity and the OAuth cookie; the hub trusts the `userId` product passes.
|
|
11
|
-
|
|
12
|
-
Tokens, API keys, basic credentials and OAuth client secrets are sealed to the user's public key under the server id and opened only through product's `KeyringMcp` entrypoint (`KEYRING`, a service binding to `product` / `product-staging` that exposes only `seal` / `open` for kind `mcp`), so that entrypoint has to be deployed before this worker. The OAuth cookie carries the client id but never the secret; the hub opens the client secret itself when it exchanges the code. Disconnecting or removing a server drops its OAuth client along with its credential. A locked Keyring is `key_locked` (423); a user with no public key yet is `no_user_key` (409).
|
|
13
|
-
|
|
14
|
-
## Where tools come from
|
|
15
|
-
|
|
16
|
-
`spec_url` is where the hub reads a server's tools: an `openapi` server's spec URL, a `graphql` server's endpoint (introspection), or `null` when the tools come from an uploaded document (an OpenAPI document or GraphQL SDL). `mcp` servers always have `null` and read `tools/list`.
|
|
17
|
-
|
|
18
|
-
- `openapi` servers, uploaded `graphql` ones and introspected `graphql` ones with `none`, `bearer`, `api_key` or `basic` are read at create, the last with the credentials sent along with it. The server row, its tools and the sealed credential are written in one batch after the read succeeds; a failed read returns its error and writes nothing. `mcp` servers and introspected `graphql` ones with `oauth` are read after connect, the OAuth ones in the callback once the code is exchanged.
|
|
19
|
-
- Connect, or for OAuth its callback, re-reads servers that have a `spec_url` and `mcp` servers, and a failed re-read doesn't fail it; uploaded ones aren't re-read and return their current tool count. An introspected `graphql` server is the exception: it is read with the new credentials first, and they are stored only when that read succeeds, so a failed connect keeps the old ones.
|
|
20
|
-
- Refresh without `document` re-reads servers that have a `spec_url` and `mcp` servers, and is `invalid` for uploaded ones. Refresh with `document` reads the upload instead, without credentials, so it works before the server is connected; when that read succeeds `spec_url` becomes `null`, whatever it was, and the server reads from uploads from then on. An `mcp` server with `document` is `invalid`.
|
|
21
|
-
- Introspection turned off means uploading SDL. An introspection answer that is a GraphQL response (JSON with `errors` and no `data.__schema`) is `no_introspection` (412) whatever its status; an upstream 401 is `mcp_not_connected` (412); anything else is `mcp_upstream_error` (502). Such a server never gets connected: create writes nothing, connect keeps the old credentials, and the OAuth callback drops the new token while the server row stays. Uploading the SDL with refresh sets `spec_url` to `null`, after which the OAuth callback no longer introspects.
|
|
22
|
-
- Every read stores how many operations or root fields it skipped in `mcp_server.dropped`, even when it found no tools: OpenAPI operations it can't call (a required cookie parameter, a body that is neither JSON nor a form, a body on GET or HEAD), input schemas over 64 KB, and everything past 500 tools.
|
|
23
|
-
- A read that finds no tools writes no tool rows. Otherwise, on the user's own servers (every `openapi` and `graphql` server, and the `mcp` servers they added) the sync upserts the tools it read and deletes the ones that vanished, only rows owned by that user, up to 90 names per statement. Catalogue servers' tools are shared by everyone, so their sync only upserts.
|
|
24
|
-
|
|
25
|
-
## Outbound fetch
|
|
26
|
-
|
|
27
|
-
Every request the hub sends goes through `guardedFetch` (`src/guard/`): MCP calls, spec and discovery documents, introspection, API calls, and OAuth discovery, registration, code exchange and refresh. It allows only `https`, refuses `anyknown.com`, `anyknown.app` and their subdomains (`invalid`, 400), and follows redirects itself: up to 3 same-origin hops, checking each one again. A cross-origin redirect, or a fourth one, comes back to the caller as the 3xx, so credentials never reach another origin. Create checks `url` and `spec_url` the same way before it fetches anything, and the OAuth endpoints before it writes anything.
|
|
28
|
-
|
|
29
|
-
Documents over these sizes are `invalid` (400), whether fetched or uploaded:
|
|
30
|
-
|
|
31
|
-
| Document | Limit |
|
|
32
|
-
| --------------------------------- | ------ |
|
|
33
|
-
| OpenAPI as JSON (starts with `{`) | 4 MB |
|
|
34
|
-
| OpenAPI as YAML | 512 KB |
|
|
35
|
-
| GraphQL SDL | 512 KB |
|
|
36
|
-
| Introspection answer | 8 MB |
|
|
37
|
-
|
|
38
|
-
`openapi` and `graphql` call results keep the first 50 KB of the body and say where they were cut.
|
|
39
|
-
|
|
40
|
-
## Environments
|
|
41
|
-
|
|
42
|
-
| | Worker | D1 | `PRODUCT_BASE_URL` |
|
|
43
|
-
| ---------- | ------------- | ------------- | ---------------------------------- |
|
|
44
|
-
| production | `mcp` | `mcp` | `https://app.anyknown.com` |
|
|
45
|
-
| staging | `mcp-staging` | `mcp-staging` | `https://staging-app.anyknown.com` |
|
|
46
|
-
|
|
47
|
-
`PRODUCT_BASE_URL` is product's app host, not the hub's: the OAuth `redirect_uri` (`/api/mcp/callback`) and client id (`/api/mcp/client-metadata`) live there.
|
|
48
|
-
|
|
49
|
-
## Dev
|
|
3
|
+
TypeScript types for the RPC interface of the anyknown MCP hub, which other Workers call through a service binding. The package ships type declarations only, with no runtime code.
|
|
50
4
|
|
|
51
5
|
```sh
|
|
52
|
-
pnpm
|
|
53
|
-
cp .dev.vars.example .dev.vars
|
|
54
|
-
pnpm dev
|
|
6
|
+
pnpm add -D @anyknown/mcp
|
|
55
7
|
```
|
|
56
8
|
|
|
57
|
-
|
|
9
|
+
```ts
|
|
10
|
+
import type { McpHubRpc } from "@anyknown/mcp";
|
|
58
11
|
|
|
59
|
-
|
|
12
|
+
interface Env {
|
|
13
|
+
MCP: Service<McpHubRpc>;
|
|
14
|
+
}
|
|
60
15
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## Deploy
|
|
16
|
+
const result = await env.MCP.search(userId, { q: "calendar" });
|
|
17
|
+
```
|
|
64
18
|
|
|
65
|
-
|
|
19
|
+
Working on the hub itself? See [docs/hub.md](docs/hub.md).
|
package/dist/catalog/types.d.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type McpKind = "mcp" | "openapi" | "graphql";
|
|
2
|
+
export type UpstreamAuth = {
|
|
3
|
+
type: "none";
|
|
4
|
+
} | {
|
|
5
|
+
type: "bearer";
|
|
6
|
+
token: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: "api_key";
|
|
9
|
+
in: "header" | "query";
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "basic";
|
|
14
|
+
username: string;
|
|
15
|
+
password: string;
|
|
16
|
+
};
|
|
17
|
+
export type ToolRow = {
|
|
18
|
+
server_id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
title: string | null;
|
|
21
|
+
description: string;
|
|
22
|
+
input_schema: string;
|
|
23
|
+
annotations: string | null;
|
|
24
|
+
call: string | null;
|
|
25
|
+
owner: string | null;
|
|
26
|
+
updated_at: number;
|
|
27
|
+
};
|
package/dist/public.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AdminServerItem, ApiKeySettings, CallInput, CompleteOauthInput, ConnectInput, ConnectResult, CreatedServer, CreateServerInput, DescribedItem, HubResult, McpServerRow, OauthSettings,
|
|
1
|
+
export type { AdminServerItem, ApiKeySettings, CallInput, CompleteOauthInput, ConnectInput, ConnectResult, CreatedServer, CreateServerInput, DescribedItem, HubResult, McpServerRow, OauthSettings, SearchInput, ServerItem, ToolHit, ToolItem, Transient, } from "./rpc/types";
|
|
2
2
|
export type { McpHubRpc } from "./rpc/hub-rpc";
|
|
3
3
|
export type { McpAuth, McpConnectionStatus, McpKind } from "./schema";
|
|
4
4
|
export type { McpErrorCode } from "./errors";
|
package/dist/rpc/hub-rpc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminServerInput, AdminServerItem, CallInput, CompleteOauthInput, ConnectInput, ConnectResult, CreatedServer, CreateServerInput, DescribedItem, HubResult, McpServerRow,
|
|
1
|
+
import type { AdminServerInput, AdminServerItem, CallInput, CompleteOauthInput, ConnectInput, ConnectResult, CreatedServer, CreateServerInput, DescribedItem, HubResult, McpServerRow, SearchInput, ServerItem, ToolHit, ToolItem } from "./types";
|
|
2
2
|
export interface McpHubRpc {
|
|
3
3
|
search(userId: string, input: SearchInput): Promise<HubResult<ToolHit[]>>;
|
|
4
4
|
describe(userId: string, tools: string[]): Promise<HubResult<{
|
|
@@ -10,7 +10,6 @@ export interface McpHubRpc {
|
|
|
10
10
|
serverTools(userId: string, serverId: string): Promise<HubResult<{
|
|
11
11
|
items: ToolItem[];
|
|
12
12
|
}>>;
|
|
13
|
-
addServer(userId: string, input: OwnServerInput): Promise<McpServerRow>;
|
|
14
13
|
createServer(userId: string, input: CreateServerInput): Promise<HubResult<CreatedServer>>;
|
|
15
14
|
connectServer(userId: string, serverId: string, input: ConnectInput): Promise<HubResult<ConnectResult>>;
|
|
16
15
|
completeOauth(userId: string, input: CompleteOauthInput): Promise<HubResult<{
|
package/dist/rpc/types.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type Transient = {
|
|
|
20
20
|
token_endpoint: string;
|
|
21
21
|
resource: string;
|
|
22
22
|
client_id: string;
|
|
23
|
+
client_secret_sealed?: string | null;
|
|
23
24
|
exp: number;
|
|
24
25
|
};
|
|
25
26
|
export type SearchInput = {
|
|
@@ -37,6 +38,7 @@ export type DescribedItem = {
|
|
|
37
38
|
description: string;
|
|
38
39
|
input_schema: unknown;
|
|
39
40
|
annotations: unknown;
|
|
41
|
+
resource: string | null;
|
|
40
42
|
};
|
|
41
43
|
export type ServerItem = {
|
|
42
44
|
id: string;
|
|
@@ -59,11 +61,6 @@ export type ToolItem = {
|
|
|
59
61
|
description: string;
|
|
60
62
|
annotations: unknown;
|
|
61
63
|
};
|
|
62
|
-
export type OwnServerInput = {
|
|
63
|
-
name: string;
|
|
64
|
-
url: string;
|
|
65
|
-
auth: McpAuth;
|
|
66
|
-
};
|
|
67
64
|
export type ApiKeySettings = {
|
|
68
65
|
in: "header" | "query";
|
|
69
66
|
name: string;
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { McpKind, ToolRow } from "./portable/types";
|
|
2
|
-
export { KINDS } from "./portable/constants";
|
|
1
|
+
import type { McpKind, ToolRow } from "./portable/public-types";
|
|
3
2
|
export type { McpKind };
|
|
4
3
|
export declare const AUTH_KINDS: readonly ["oauth", "bearer", "api_key", "basic", "none"];
|
|
5
4
|
export type McpAuth = (typeof AUTH_KINDS)[number];
|
package/package.json
CHANGED
package/dist/client/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { DEFAULT_TIMEOUT_MS, MAX_TIMEOUT_MS, PROTOCOL_VERSION } from "./constants";
|
|
2
|
-
export { handshake } from "./handshake";
|
|
3
|
-
export { notify } from "./notify";
|
|
4
|
-
export { parseChallenge } from "./parse-challenge";
|
|
5
|
-
export { rpc } from "./rpc";
|
|
6
|
-
export type { Handshake, RpcResult, Transport } from "./types";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function joinedDataLines(block: string): string;
|
package/dist/client/notify.d.ts
DELETED
package/dist/client/rpc.d.ts
DELETED
package/dist/client/send.d.ts
DELETED
package/dist/client/types.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type Transport = {
|
|
2
|
-
url: string;
|
|
3
|
-
token?: string | null;
|
|
4
|
-
sessionId?: string | null;
|
|
5
|
-
protocolVersion?: string | null;
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
fetchImpl?: typeof fetch;
|
|
8
|
-
};
|
|
9
|
-
export type RpcResult = {
|
|
10
|
-
result: unknown;
|
|
11
|
-
sessionId: string | null;
|
|
12
|
-
};
|
|
13
|
-
export type JsonRpcMessage = {
|
|
14
|
-
jsonrpc?: string;
|
|
15
|
-
id?: number | string | null;
|
|
16
|
-
result?: unknown;
|
|
17
|
-
error?: {
|
|
18
|
-
code?: number;
|
|
19
|
-
message?: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export type Handshake = {
|
|
23
|
-
sessionId: string | null;
|
|
24
|
-
protocolVersion: string | null;
|
|
25
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { McpSession } from "./mcp/types";
|
|
2
|
-
export declare const KINDS: readonly ["mcp", "openapi", "graphql"];
|
|
3
|
-
export declare const RESULT_TEXT_MAX = 50000;
|
|
4
|
-
export declare const JSON_MAX_BYTES = 4000000;
|
|
5
|
-
export declare const YAML_MAX_BYTES = 512000;
|
|
6
|
-
export declare const SDL_MAX_BYTES = 512000;
|
|
7
|
-
export declare const INTROSPECTION_MAX_BYTES = 8000000;
|
|
8
|
-
export declare const TOOLS_MAX = 500;
|
|
9
|
-
export declare const INPUT_SCHEMA_MAX = 64000;
|
|
10
|
-
export declare const DESCRIPTION_MAX = 1000;
|
|
11
|
-
export declare const TOOL_NAME_MAX = 64;
|
|
12
|
-
export declare const ARG_ERRORS_MAX = 5;
|
|
13
|
-
export declare const SUMMARY_KEYWORDS: Set<string>;
|
|
14
|
-
export declare const DELETE_BATCH = 90;
|
|
15
|
-
export declare const MAX_PAGES = 20;
|
|
16
|
-
export declare const NO_SESSION: McpSession;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function fetchDocument(url: string, fetchImpl: typeof fetch, max: number): Promise<string>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type GraphQLArgument, type GraphQLInputField } from "graphql";
|
|
2
|
-
import type { UsedTypes } from "./types";
|
|
3
|
-
type InputValue = GraphQLArgument | GraphQLInputField;
|
|
4
|
-
export declare function argsSchema(values: readonly InputValue[], used: UsedTypes): Record<string, unknown>;
|
|
5
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const SCALAR_SCHEMAS: Map<string, Record<string, unknown>>;
|
|
2
|
-
export declare const OPERATION_ANNOTATIONS: {
|
|
3
|
-
query: {
|
|
4
|
-
readOnlyHint: boolean;
|
|
5
|
-
destructiveHint: boolean;
|
|
6
|
-
};
|
|
7
|
-
mutation: {
|
|
8
|
-
readOnlyHint: boolean;
|
|
9
|
-
destructiveHint: boolean;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export declare const GRAPHQL_HEADERS: {
|
|
13
|
-
"content-type": string;
|
|
14
|
-
accept: string;
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function jsonOf(text: string): unknown;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function orNull(schema: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IntrospectionSchema } from "graphql";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
export declare const introspectionAnswerSchema: z.ZodObject<{
|
|
4
|
-
data: z.ZodObject<{
|
|
5
|
-
__schema: z.ZodCustom<IntrospectionSchema, IntrospectionSchema>;
|
|
6
|
-
}, z.core.$strip>;
|
|
7
|
-
}, z.core.$strip>;
|
|
8
|
-
export declare const errorsAnswerSchema: z.ZodObject<{
|
|
9
|
-
errors: z.ZodArray<z.ZodUnknown>;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
export declare const failedAnswerSchema: z.ZodObject<{
|
|
12
|
-
errors: z.ZodArray<z.ZodUnknown>;
|
|
13
|
-
data: z.ZodOptional<z.ZodNull>;
|
|
14
|
-
}, z.core.$strip>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { GraphQLEnumType, GraphQLField, GraphQLInputObjectType } from "graphql";
|
|
2
|
-
import type { GraphqlCall } from "../types";
|
|
3
|
-
export type GraphqlOperation = GraphqlCall["operation"];
|
|
4
|
-
export type RootField = [GraphqlOperation, GraphQLField<unknown, unknown>];
|
|
5
|
-
export type UsedTypes = Map<string, GraphQLEnumType | GraphQLInputObjectType>;
|
|
6
|
-
export type GraphqlArgs = {
|
|
7
|
-
args?: Record<string, unknown>;
|
|
8
|
-
selection?: string;
|
|
9
|
-
};
|
package/dist/portable/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { applyAuth } from "./apply-auth";
|
|
2
|
-
export { callTool } from "./call-tool";
|
|
3
|
-
export { ARG_ERRORS_MAX, DELETE_BATCH, DESCRIPTION_MAX, INPUT_SCHEMA_MAX, INTROSPECTION_MAX_BYTES, JSON_MAX_BYTES, KINDS, MAX_PAGES, NO_SESSION, RESULT_TEXT_MAX, SDL_MAX_BYTES, TOOL_NAME_MAX, TOOLS_MAX, YAML_MAX_BYTES, } from "./constants";
|
|
4
|
-
export { callGraphql, readGraphql } from "./graphql";
|
|
5
|
-
export { callMcpTool, listMcpTools, mcpRequest } from "./mcp";
|
|
6
|
-
export type { McpSession } from "./mcp";
|
|
7
|
-
export { callOpenApi, readOpenApi } from "./openapi";
|
|
8
|
-
export { authorizeUrl, discover, exchangeCode, issuerMismatch, pkce, randomState, refreshTokens, registerClient, } from "./oauth";
|
|
9
|
-
export type { Discovery, Tokens } from "./oauth";
|
|
10
|
-
export { readCapped } from "./read-capped";
|
|
11
|
-
export { readTools } from "./read-tools";
|
|
12
|
-
export { staleToolNames } from "./stale-tool-names";
|
|
13
|
-
export { textResult } from "./text-result";
|
|
14
|
-
export { toolRowsOf } from "./tool-rows-of";
|
|
15
|
-
export type { CallToolInput, GraphqlCall, McpKind, OpenApiCall, ReadResult, ReadToolsInput, SpecDefaults, ToolResult, ToolRow, Upstream, UpstreamAuth, UpstreamTool, } from "./types";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Upstream } from "../types";
|
|
2
|
-
import type { McpSession } from "./types";
|
|
3
|
-
export declare function mcpRequest(upstream: Upstream, session: McpSession, method: string, params?: Record<string, unknown>): Promise<{
|
|
4
|
-
result: unknown;
|
|
5
|
-
session: McpSession;
|
|
6
|
-
}>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const toolsListSchema: z.ZodObject<{
|
|
3
|
-
tools: z.ZodArray<z.ZodObject<{
|
|
4
|
-
name: z.ZodString;
|
|
5
|
-
title: z.ZodOptional<z.ZodString>;
|
|
6
|
-
description: z.ZodOptional<z.ZodString>;
|
|
7
|
-
inputSchema: z.ZodOptional<z.ZodUnknown>;
|
|
8
|
-
annotations: z.ZodOptional<z.ZodUnknown>;
|
|
9
|
-
}, z.core.$strip>>;
|
|
10
|
-
nextCursor: z.ZodOptional<z.ZodString>;
|
|
11
|
-
}, z.core.$strip>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const b64url: (bytes: Uint8Array) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function clientBasic(clientId: string, clientSecret: string | null | undefined): string | null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const TIMEOUT_MS = 10000;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Discovery, Tokens } from "./types";
|
|
2
|
-
export declare function exchangeCode(args: {
|
|
3
|
-
discovery: Discovery;
|
|
4
|
-
clientId: string;
|
|
5
|
-
clientSecret?: string | null;
|
|
6
|
-
redirectUri: string;
|
|
7
|
-
code: string;
|
|
8
|
-
verifier: string;
|
|
9
|
-
}, fetchImpl?: typeof fetch): Promise<Tokens>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { authorizeUrl } from "./authorize-url";
|
|
2
|
-
export { discover } from "./discover";
|
|
3
|
-
export { exchangeCode } from "./exchange-code";
|
|
4
|
-
export { issuerMismatch } from "./issuer-mismatch";
|
|
5
|
-
export { metadataUrls } from "./metadata-urls";
|
|
6
|
-
export { pkce } from "./pkce";
|
|
7
|
-
export { protectedResourceUrl } from "./protected-resource-url";
|
|
8
|
-
export { randomState } from "./random-state";
|
|
9
|
-
export { refreshTokens } from "./refresh-tokens";
|
|
10
|
-
export { registerClient } from "./register-client";
|
|
11
|
-
export type { Discovery, Tokens } from "./types";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function issuerMismatch(expected: string, iss: string | null | undefined): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function metadataUrls(issuer: string): string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function protectedResourceUrl(resource: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function randomState(): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function readMetadata(issuer: string, fetchImpl: typeof fetch): Promise<{
|
|
2
|
-
issuer: string;
|
|
3
|
-
authorization_endpoint: string;
|
|
4
|
-
token_endpoint: string;
|
|
5
|
-
registration_endpoint?: string | undefined;
|
|
6
|
-
scopes_supported?: string[] | undefined;
|
|
7
|
-
client_id_metadata_document_supported?: boolean | undefined;
|
|
8
|
-
} | null>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const prmSchema: z.ZodObject<{
|
|
3
|
-
resource: z.ZodOptional<z.ZodString>;
|
|
4
|
-
authorization_servers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
|
-
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
-
}, z.core.$strip>;
|
|
7
|
-
export declare const metadataSchema: z.ZodObject<{
|
|
8
|
-
issuer: z.ZodString;
|
|
9
|
-
authorization_endpoint: z.ZodString;
|
|
10
|
-
token_endpoint: z.ZodString;
|
|
11
|
-
registration_endpoint: z.ZodOptional<z.ZodString>;
|
|
12
|
-
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
-
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
-
}, z.core.$strip>;
|
|
15
|
-
export declare const tokenSchema: z.ZodObject<{
|
|
16
|
-
access_token: z.ZodString;
|
|
17
|
-
refresh_token: z.ZodOptional<z.ZodString>;
|
|
18
|
-
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
19
|
-
scope: z.ZodOptional<z.ZodString>;
|
|
20
|
-
}, z.core.$strip>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
import type { tokenSchema } from "./schema";
|
|
3
|
-
export type Tokens = z.infer<typeof tokenSchema>;
|
|
4
|
-
export type Discovery = {
|
|
5
|
-
resource: string;
|
|
6
|
-
issuer: string;
|
|
7
|
-
authorizationEndpoint: string;
|
|
8
|
-
tokenEndpoint: string;
|
|
9
|
-
registrationEndpoint: string | null;
|
|
10
|
-
scope: string | null;
|
|
11
|
-
clientIdMetadataSupported: boolean;
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function appendParams(params: URLSearchParams, values: unknown): void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const OPERATION_METHODS: Set<string>;
|
|
2
|
-
export declare const READ_ONLY_METHODS: Set<string>;
|
|
3
|
-
export declare const BODYLESS_METHODS: Set<string>;
|
|
4
|
-
export declare const BODY_TYPES: readonly [readonly ["application/json", "json"], readonly ["application/x-www-form-urlencoded", "form"]];
|
|
5
|
-
export declare const IGNORED_HEADERS: Set<string>;
|
|
6
|
-
export declare const RESERVED_HEADERS: RegExp;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function pathSegment(value: unknown): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveRef(document: unknown, node: unknown): unknown;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function rewriteRefs(node: unknown, used: Set<string>): unknown;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const documentSchema: z.ZodObject<{
|
|
3
|
-
paths: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
4
|
-
components: z.ZodOptional<z.ZodObject<{
|
|
5
|
-
schemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
6
|
-
securitySchemes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
7
|
-
}, z.core.$loose>>;
|
|
8
|
-
}, z.core.$loose>;
|
|
9
|
-
export declare const pathItemObjectSchema: z.ZodObject<{
|
|
10
|
-
parameters: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
11
|
-
}, z.core.$loose>;
|
|
12
|
-
export declare const operationObjectSchema: z.ZodObject<{
|
|
13
|
-
operationId: z.ZodOptional<z.ZodString>;
|
|
14
|
-
summary: z.ZodOptional<z.ZodString>;
|
|
15
|
-
description: z.ZodOptional<z.ZodString>;
|
|
16
|
-
parameters: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
17
|
-
requestBody: z.ZodOptional<z.ZodUnknown>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
export declare const parameterObjectSchema: z.ZodObject<{
|
|
20
|
-
name: z.ZodString;
|
|
21
|
-
in: z.ZodEnum<{
|
|
22
|
-
cookie: "cookie";
|
|
23
|
-
header: "header";
|
|
24
|
-
path: "path";
|
|
25
|
-
query: "query";
|
|
26
|
-
}>;
|
|
27
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
-
description: z.ZodOptional<z.ZodString>;
|
|
29
|
-
schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
export declare const requestBodyObjectSchema: z.ZodObject<{
|
|
32
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
-
content: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
34
|
-
schema: z.ZodOptional<z.ZodUnknown>;
|
|
35
|
-
}, z.core.$strip>>;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
export declare const refObjectSchema: z.ZodObject<{
|
|
38
|
-
$ref: z.ZodString;
|
|
39
|
-
}, z.core.$strip>;
|
|
40
|
-
export declare const apiKeySchemeSchema: z.ZodObject<{
|
|
41
|
-
type: z.ZodLiteral<"apiKey">;
|
|
42
|
-
in: z.ZodEnum<{
|
|
43
|
-
header: "header";
|
|
44
|
-
query: "query";
|
|
45
|
-
}>;
|
|
46
|
-
name: z.ZodString;
|
|
47
|
-
}, z.core.$strip>;
|
|
48
|
-
export declare const oauth2SchemeSchema: z.ZodObject<{
|
|
49
|
-
type: z.ZodLiteral<"oauth2">;
|
|
50
|
-
flows: z.ZodObject<{
|
|
51
|
-
authorizationCode: z.ZodObject<{
|
|
52
|
-
authorizationUrl: z.ZodString;
|
|
53
|
-
tokenUrl: z.ZodString;
|
|
54
|
-
scopes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
55
|
-
}, z.core.$strip>;
|
|
56
|
-
}, z.core.$strip>;
|
|
57
|
-
}, z.core.$strip>;
|
|
58
|
-
export declare const openIdSchemeSchema: z.ZodObject<{
|
|
59
|
-
type: z.ZodLiteral<"openIdConnect">;
|
|
60
|
-
openIdConnectUrl: z.ZodString;
|
|
61
|
-
}, z.core.$strip>;
|
|
62
|
-
export declare const discoverySchema: z.ZodObject<{
|
|
63
|
-
authorization_endpoint: z.ZodString;
|
|
64
|
-
token_endpoint: z.ZodString;
|
|
65
|
-
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
66
|
-
}, z.core.$strip>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function toolName(operationId: string | undefined, method: string, path: string): string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
import type { OpenApiCall } from "../types";
|
|
3
|
-
import type { documentSchema, parameterObjectSchema } from "./schema";
|
|
4
|
-
export type OpenApiDocument = z.infer<typeof documentSchema>;
|
|
5
|
-
export type Parameter = z.infer<typeof parameterObjectSchema>;
|
|
6
|
-
export type ParamPlace = Exclude<Parameter["in"], "cookie">;
|
|
7
|
-
export type ParamGroup = {
|
|
8
|
-
schema: unknown;
|
|
9
|
-
required: boolean;
|
|
10
|
-
};
|
|
11
|
-
export type RequestBody = {
|
|
12
|
-
kind: OpenApiCall["body"];
|
|
13
|
-
schema: unknown;
|
|
14
|
-
required: boolean;
|
|
15
|
-
};
|
|
16
|
-
export type OperationSource = {
|
|
17
|
-
path: string;
|
|
18
|
-
method: string;
|
|
19
|
-
pathParameters: unknown[];
|
|
20
|
-
operation: unknown;
|
|
21
|
-
};
|
|
22
|
-
export type OpenApiArgs = {
|
|
23
|
-
path?: Record<string, unknown>;
|
|
24
|
-
query?: Record<string, unknown>;
|
|
25
|
-
header?: Record<string, unknown>;
|
|
26
|
-
body?: unknown;
|
|
27
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function uniqueNames(names: string[]): string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function yamlValue(text: string): unknown;
|
package/dist/portable/types.d.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { KINDS } from "./constants";
|
|
2
|
-
import type { McpSession } from "./mcp/types";
|
|
3
|
-
export type McpKind = (typeof KINDS)[number];
|
|
4
|
-
export type UpstreamAuth = {
|
|
5
|
-
type: "none";
|
|
6
|
-
} | {
|
|
7
|
-
type: "bearer";
|
|
8
|
-
token: string;
|
|
9
|
-
} | {
|
|
10
|
-
type: "api_key";
|
|
11
|
-
in: "header" | "query";
|
|
12
|
-
name: string;
|
|
13
|
-
value: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: "basic";
|
|
16
|
-
username: string;
|
|
17
|
-
password: string;
|
|
18
|
-
};
|
|
19
|
-
export type Upstream = {
|
|
20
|
-
url: string;
|
|
21
|
-
auth: UpstreamAuth;
|
|
22
|
-
fetch: typeof fetch;
|
|
23
|
-
timeoutMs?: number;
|
|
24
|
-
};
|
|
25
|
-
export type UpstreamTool = {
|
|
26
|
-
name: string;
|
|
27
|
-
title: string | null;
|
|
28
|
-
description: string;
|
|
29
|
-
input_schema: unknown;
|
|
30
|
-
annotations: unknown;
|
|
31
|
-
call: unknown;
|
|
32
|
-
};
|
|
33
|
-
export type ToolResult = {
|
|
34
|
-
content: [{
|
|
35
|
-
type: "text";
|
|
36
|
-
text: string;
|
|
37
|
-
}];
|
|
38
|
-
isError: boolean;
|
|
39
|
-
};
|
|
40
|
-
export type OpenApiCall = {
|
|
41
|
-
method: string;
|
|
42
|
-
path: string;
|
|
43
|
-
body: "json" | "form" | null;
|
|
44
|
-
};
|
|
45
|
-
export type GraphqlCall = {
|
|
46
|
-
operation: "query" | "mutation";
|
|
47
|
-
field: string;
|
|
48
|
-
arg_types: Record<string, string>;
|
|
49
|
-
selection: string;
|
|
50
|
-
};
|
|
51
|
-
export type SpecDefaults = {
|
|
52
|
-
api_key?: {
|
|
53
|
-
in: "header" | "query";
|
|
54
|
-
name: string;
|
|
55
|
-
};
|
|
56
|
-
oauth?: {
|
|
57
|
-
authorize_url: string;
|
|
58
|
-
token_url: string;
|
|
59
|
-
scopes: string[];
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
export type ReadResult = {
|
|
63
|
-
tools: UpstreamTool[];
|
|
64
|
-
dropped: number;
|
|
65
|
-
defaults: SpecDefaults;
|
|
66
|
-
session: McpSession | null;
|
|
67
|
-
};
|
|
68
|
-
export type ToolRow = {
|
|
69
|
-
server_id: string;
|
|
70
|
-
name: string;
|
|
71
|
-
title: string | null;
|
|
72
|
-
description: string;
|
|
73
|
-
input_schema: string;
|
|
74
|
-
annotations: string | null;
|
|
75
|
-
call: string | null;
|
|
76
|
-
owner: string | null;
|
|
77
|
-
updated_at: number;
|
|
78
|
-
};
|
|
79
|
-
export type ReadToolsInput = {
|
|
80
|
-
kind: McpKind;
|
|
81
|
-
upstream: Upstream;
|
|
82
|
-
session: McpSession;
|
|
83
|
-
spec_url: string | null;
|
|
84
|
-
document?: string;
|
|
85
|
-
};
|
|
86
|
-
export type CallToolInput = {
|
|
87
|
-
kind: McpKind;
|
|
88
|
-
upstream: Upstream;
|
|
89
|
-
session: McpSession;
|
|
90
|
-
tool: Pick<ToolRow, "name" | "input_schema" | "call">;
|
|
91
|
-
args: unknown;
|
|
92
|
-
};
|