@engini/sdk 0.16.0 → 0.18.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 +24 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.js +4 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +10 -0
- package/dist/http.d.ts +24 -4
- package/dist/http.js +44 -7
- package/dist/index.d.ts +5 -2
- package/dist/index.js +4 -2
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.js +1 -0
- package/dist/resources/mcp.d.ts +51 -0
- package/dist/resources/mcp.js +101 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +6 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -31,6 +31,17 @@ JWT auth is the fallback: `new Engini({ token: "<jwt>", companyToken: "<id>" })`
|
|
|
31
31
|
`ENGINI_API_TOKEN` / `ENGINI_COMPANY_TOKEN`. With an API key the company is bound to the key,
|
|
32
32
|
so no company token is needed. Point at another host with `new Engini({ …, baseUrl })`.
|
|
33
33
|
|
|
34
|
+
Every request carries a `User-Agent` identifying this SDK and its runtime (e.g.
|
|
35
|
+
`engini-sdk-ts/0.13.0 node/20.11.0 darwin-arm64`). If you're embedding the SDK inside your own
|
|
36
|
+
product, prepend your own token with `userAgentPrefix`:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const client = new Engini({ apiKey: "eng_…", userAgentPrefix: "my-product/1.4.0" });
|
|
40
|
+
// -> "my-product/1.4.0 engini-sdk-ts/0.13.0 node/20.11.0 darwin-arm64"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`userAgentPrefix` only *prepends* a token — it can't override or remove the SDK's own identity.
|
|
44
|
+
|
|
34
45
|
## Use with an LLM
|
|
35
46
|
|
|
36
47
|
`Provider` adapters wrap canonical schemas into vendor tool definitions **client-side, with no
|
|
@@ -48,6 +59,19 @@ const openaiTools = client.provider.wrapTools(await toolset.tools()); // plain
|
|
|
48
59
|
const results = await toolset.handleToolCalls(llmResponse); // runs the calls, returns results
|
|
49
60
|
```
|
|
50
61
|
|
|
62
|
+
`client.mcp` inspects and maintains the account's MCP servers — the endpoints Engini
|
|
63
|
+
*exposes* over the Model Context Protocol:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const servers = await client.mcp.list(); // includes deactivated ones
|
|
67
|
+
await client.mcp.deactivate(servers[0].mcpServerToken); // reversible; sends only isActive
|
|
68
|
+
const tools = await client.mcp.availableTools(token, 2139); // candidates for toolSlugs
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`update()` replaces `connections`/`workflows` rather than merging them, and every
|
|
72
|
+
connection entry needs an explicit `connectionId` (MCP servers are account-wide, so there
|
|
73
|
+
is no per-user default). There is no `create`/`delete`: those stay in the engini.io UI.
|
|
74
|
+
|
|
51
75
|
`client.toolset(...)` builds a local toolset (no I/O until used) or loads a server one via
|
|
52
76
|
`client.toolset({ toolsetId })`.
|
|
53
77
|
|
package/dist/client.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Provider } from "./providers/base.js";
|
|
|
4
4
|
import { ToolsResource } from "./resources/tools.js";
|
|
5
5
|
import { ConnectionsResource } from "./resources/connections.js";
|
|
6
6
|
import { ToolsetsResource } from "./resources/toolsets.js";
|
|
7
|
+
import { McpResource } from "./resources/mcp.js";
|
|
7
8
|
import { ApplicationsResource } from "./resources/applications.js";
|
|
8
9
|
import { AuthResource } from "./resources/auth.js";
|
|
9
10
|
import { Toolset, type ConnectionBinding } from "./toolset.js";
|
|
@@ -34,12 +35,20 @@ export interface EnginiOptions {
|
|
|
34
35
|
* host).
|
|
35
36
|
*/
|
|
36
37
|
verify?: Verify;
|
|
38
|
+
/**
|
|
39
|
+
* Product token to prepend to the SDK's own `User-Agent` (e.g. `engini-cli/0.13.0`).
|
|
40
|
+
* The SDK always emits its own identity plus runtime tokens; this only adds a
|
|
41
|
+
* prefix — it cannot override or remove them. Rejected if it contains a
|
|
42
|
+
* control character or exceeds 128 characters.
|
|
43
|
+
*/
|
|
44
|
+
userAgentPrefix?: string;
|
|
37
45
|
}
|
|
38
46
|
/** Engini SDK client — the single public entry point. */
|
|
39
47
|
export declare class Engini {
|
|
40
48
|
readonly tools: ToolsResource;
|
|
41
49
|
readonly connections: ConnectionsResource;
|
|
42
50
|
readonly toolsets: ToolsetsResource;
|
|
51
|
+
readonly mcp: McpResource;
|
|
43
52
|
readonly applications: ApplicationsResource;
|
|
44
53
|
readonly auth: AuthResource;
|
|
45
54
|
readonly provider: Provider;
|
package/dist/client.js
CHANGED
|
@@ -5,6 +5,7 @@ import { OpenAIProvider } from "./providers/openai.js";
|
|
|
5
5
|
import { ToolsResource } from "./resources/tools.js";
|
|
6
6
|
import { ConnectionsResource } from "./resources/connections.js";
|
|
7
7
|
import { ToolsetsResource } from "./resources/toolsets.js";
|
|
8
|
+
import { McpResource } from "./resources/mcp.js";
|
|
8
9
|
import { ApplicationsResource } from "./resources/applications.js";
|
|
9
10
|
import { AuthResource } from "./resources/auth.js";
|
|
10
11
|
import { Toolset } from "./toolset.js";
|
|
@@ -14,6 +15,7 @@ export class Engini {
|
|
|
14
15
|
tools;
|
|
15
16
|
connections;
|
|
16
17
|
toolsets;
|
|
18
|
+
mcp;
|
|
17
19
|
applications;
|
|
18
20
|
auth;
|
|
19
21
|
provider;
|
|
@@ -60,11 +62,13 @@ export class Engini {
|
|
|
60
62
|
this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
61
63
|
this._transport = buildClient(this.baseUrl, auth, companyToken, {
|
|
62
64
|
verify: options.verify ?? true,
|
|
65
|
+
userAgentPrefix: options.userAgentPrefix,
|
|
63
66
|
});
|
|
64
67
|
this.provider = options.provider ?? new OpenAIProvider();
|
|
65
68
|
this.tools = new ToolsResource(this);
|
|
66
69
|
this.connections = new ConnectionsResource(this);
|
|
67
70
|
this.toolsets = new ToolsetsResource(this);
|
|
71
|
+
this.mcp = new McpResource(this);
|
|
68
72
|
this.applications = new ApplicationsResource(this);
|
|
69
73
|
this.auth = new AuthResource(this);
|
|
70
74
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -48,6 +48,16 @@ export declare class EnginiToolsetError extends EnginiError {
|
|
|
48
48
|
*/
|
|
49
49
|
export declare class EnginiToolsetNotFoundError extends EnginiToolsetError {
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Unknown MCP server token (a 404 remapped for a friendlier message by
|
|
53
|
+
* `McpResource.get`/`update`/`availableTools`). Mirrors the Python SDK's
|
|
54
|
+
* `EnginiMcpServerNotFoundError` so both sides map to the same CLI exit code.
|
|
55
|
+
* Unlike the toolset case there is no wider sibling error to sit under: an MCP
|
|
56
|
+
* server is addressed only by token, so there is no ambiguous-name resolution
|
|
57
|
+
* to distinguish it from.
|
|
58
|
+
*/
|
|
59
|
+
export declare class EnginiMcpServerNotFoundError extends EnginiError {
|
|
60
|
+
}
|
|
51
61
|
/** A polled asynchronous job (e.g. a connection refresh) did not finish in time. */
|
|
52
62
|
export declare class EnginiTimeoutError extends EnginiError {
|
|
53
63
|
}
|
package/dist/errors.js
CHANGED
|
@@ -51,6 +51,16 @@ export class EnginiToolsetError extends EnginiError {
|
|
|
51
51
|
*/
|
|
52
52
|
export class EnginiToolsetNotFoundError extends EnginiToolsetError {
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Unknown MCP server token (a 404 remapped for a friendlier message by
|
|
56
|
+
* `McpResource.get`/`update`/`availableTools`). Mirrors the Python SDK's
|
|
57
|
+
* `EnginiMcpServerNotFoundError` so both sides map to the same CLI exit code.
|
|
58
|
+
* Unlike the toolset case there is no wider sibling error to sit under: an MCP
|
|
59
|
+
* server is addressed only by token, so there is no ambiguous-name resolution
|
|
60
|
+
* to distinguish it from.
|
|
61
|
+
*/
|
|
62
|
+
export class EnginiMcpServerNotFoundError extends EnginiError {
|
|
63
|
+
}
|
|
54
64
|
/** A polled asynchronous job (e.g. a connection refresh) did not finish in time. */
|
|
55
65
|
export class EnginiTimeoutError extends EnginiError {
|
|
56
66
|
}
|
package/dist/http.d.ts
CHANGED
|
@@ -16,10 +16,29 @@ export type Verify = boolean | string | Dispatcher;
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function tlsDispatcher(verify: Verify): Dispatcher | undefined;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
19
|
+
* Compose the SDK's `User-Agent`. The SDK always emits its own identity plus
|
|
20
|
+
* runtime tokens; a caller (the CLI, or any embedder) may only *prepend* its
|
|
21
|
+
* own product token via `prefix` — there is no way to override or remove the
|
|
22
|
+
* SDK's own token.
|
|
23
|
+
*
|
|
24
|
+
* `prefix` is validated rather than trusted: `Headers` would throw a bare
|
|
25
|
+
* `TypeError` on a control character, which would escape the SDK's typed-error
|
|
26
|
+
* contract, so it's rejected here with `EnginiClientError` instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare function composeUserAgent(prefix?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Build the generated transport with a `User-Agent`, auth, and optional
|
|
31
|
+
* account headers. `createEnginiClient` accepts only `{ baseUrl, token }`, so
|
|
32
|
+
* these are applied as default headers via `setConfig` (mirrors Python's
|
|
33
|
+
* `build_client`).
|
|
34
|
+
*
|
|
35
|
+
* Headers are assembled on a real `Headers` object — never via object spread.
|
|
36
|
+
* Spread is case-sensitive but `Headers.set` is case-insensitive/last-write-wins,
|
|
37
|
+
* so spreading would let a case-duplicate key (e.g. a stray `X-API-KEY`) survive
|
|
38
|
+
* into `mergeHeaders` (`@engini/client`'s `utils.gen.ts`) and beat the real
|
|
39
|
+
* credential. The composed `User-Agent` is set **last**, after auth's own
|
|
40
|
+
* headers, so a custom `Auth` implementation can't shadow the SDK's identity —
|
|
41
|
+
* matching `composeUserAgent`'s contract that it can't be overridden.
|
|
23
42
|
*
|
|
24
43
|
* `options.verify` controls TLS verification: when it resolves to a dispatcher
|
|
25
44
|
* (i.e. anything other than the default `true`), a custom `fetch` is installed
|
|
@@ -27,6 +46,7 @@ export declare function tlsDispatcher(verify: Verify): Dispatcher | undefined;
|
|
|
27
46
|
*/
|
|
28
47
|
export declare function buildClient(baseUrl: string, auth: Auth, companyToken?: string, options?: {
|
|
29
48
|
verify?: Verify;
|
|
49
|
+
userAgentPrefix?: string;
|
|
30
50
|
}): Transport;
|
|
31
51
|
/** A generated operation function (hey-api), invoked with `{ client, ... }`. */
|
|
32
52
|
type Operation<O, R> = (options: O & {
|
package/dist/http.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
8
|
import { Agent } from "undici";
|
|
9
9
|
import { createEnginiClient } from "@engini/client";
|
|
10
|
-
import { EnginiAPIError, EnginiAuthError, EnginiConflictError, EnginiNetworkError, EnginiNotFoundError, EnginiRateLimitError, EnginiServerError, EnginiValidationError, } from "./errors.js";
|
|
10
|
+
import { EnginiAPIError, EnginiAuthError, EnginiClientError, EnginiConflictError, EnginiNetworkError, EnginiNotFoundError, EnginiRateLimitError, EnginiServerError, EnginiValidationError, } from "./errors.js";
|
|
11
|
+
import { VERSION } from "./version.js";
|
|
11
12
|
/**
|
|
12
13
|
* Map a `verify` setting onto an undici `Dispatcher`, or `undefined` to keep the
|
|
13
14
|
* default verification. Node's `fetch` has no `verify_ssl` equivalent — TLS
|
|
@@ -31,11 +32,44 @@ const STATUS_TO_ERROR = {
|
|
|
31
32
|
422: EnginiValidationError,
|
|
32
33
|
429: EnginiRateLimitError,
|
|
33
34
|
};
|
|
35
|
+
const USER_AGENT_MAX_LEN = 128;
|
|
36
|
+
// CR/LF/NUL would let a prefix smuggle a second header line or split the value.
|
|
37
|
+
const USER_AGENT_CONTROL_CHAR_RE = /[\r\n\0]/;
|
|
34
38
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `
|
|
38
|
-
*
|
|
39
|
+
* Compose the SDK's `User-Agent`. The SDK always emits its own identity plus
|
|
40
|
+
* runtime tokens; a caller (the CLI, or any embedder) may only *prepend* its
|
|
41
|
+
* own product token via `prefix` — there is no way to override or remove the
|
|
42
|
+
* SDK's own token.
|
|
43
|
+
*
|
|
44
|
+
* `prefix` is validated rather than trusted: `Headers` would throw a bare
|
|
45
|
+
* `TypeError` on a control character, which would escape the SDK's typed-error
|
|
46
|
+
* contract, so it's rejected here with `EnginiClientError` instead.
|
|
47
|
+
*/
|
|
48
|
+
export function composeUserAgent(prefix) {
|
|
49
|
+
if (prefix !== undefined) {
|
|
50
|
+
if (USER_AGENT_CONTROL_CHAR_RE.test(prefix)) {
|
|
51
|
+
throw new EnginiClientError("userAgentPrefix must not contain control characters.");
|
|
52
|
+
}
|
|
53
|
+
if (prefix.length > USER_AGENT_MAX_LEN) {
|
|
54
|
+
throw new EnginiClientError(`userAgentPrefix must be at most ${USER_AGENT_MAX_LEN} characters.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const runtime = `engini-sdk-ts/${VERSION} node/${process.versions.node} ${process.platform}-${process.arch}`;
|
|
58
|
+
return prefix ? `${prefix} ${runtime}` : runtime;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build the generated transport with a `User-Agent`, auth, and optional
|
|
62
|
+
* account headers. `createEnginiClient` accepts only `{ baseUrl, token }`, so
|
|
63
|
+
* these are applied as default headers via `setConfig` (mirrors Python's
|
|
64
|
+
* `build_client`).
|
|
65
|
+
*
|
|
66
|
+
* Headers are assembled on a real `Headers` object — never via object spread.
|
|
67
|
+
* Spread is case-sensitive but `Headers.set` is case-insensitive/last-write-wins,
|
|
68
|
+
* so spreading would let a case-duplicate key (e.g. a stray `X-API-KEY`) survive
|
|
69
|
+
* into `mergeHeaders` (`@engini/client`'s `utils.gen.ts`) and beat the real
|
|
70
|
+
* credential. The composed `User-Agent` is set **last**, after auth's own
|
|
71
|
+
* headers, so a custom `Auth` implementation can't shadow the SDK's identity —
|
|
72
|
+
* matching `composeUserAgent`'s contract that it can't be overridden.
|
|
39
73
|
*
|
|
40
74
|
* `options.verify` controls TLS verification: when it resolves to a dispatcher
|
|
41
75
|
* (i.e. anything other than the default `true`), a custom `fetch` is installed
|
|
@@ -43,9 +77,12 @@ const STATUS_TO_ERROR = {
|
|
|
43
77
|
*/
|
|
44
78
|
export function buildClient(baseUrl, auth, companyToken, options = {}) {
|
|
45
79
|
const client = createEnginiClient({ baseUrl });
|
|
46
|
-
const headers =
|
|
80
|
+
const headers = new Headers();
|
|
81
|
+
for (const [key, value] of Object.entries(auth.apply({})))
|
|
82
|
+
headers.set(key, value);
|
|
47
83
|
if (companyToken !== undefined)
|
|
48
|
-
headers
|
|
84
|
+
headers.set("companytoken", companyToken);
|
|
85
|
+
headers.set("user-agent", composeUserAgent(options.userAgentPrefix));
|
|
49
86
|
const dispatcher = tlsDispatcher(options.verify ?? true);
|
|
50
87
|
const fetchOverride = dispatcher === undefined
|
|
51
88
|
? undefined
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ export { Engini, DEFAULT_BASE_URL } from "./client.js";
|
|
|
2
2
|
export type { EnginiOptions } from "./client.js";
|
|
3
3
|
export { ApiKeyAuth, BearerAuth, ENV_API_KEY_VAR, ENV_TOKEN_VAR, ENV_COMPANY_TOKEN_VAR, } from "./auth.js";
|
|
4
4
|
export type { Auth } from "./auth.js";
|
|
5
|
+
export { composeUserAgent } from "./http.js";
|
|
5
6
|
export type { Verify } from "./http.js";
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
7
|
+
export { VERSION } from "./version.js";
|
|
8
|
+
export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, EnginiNotFoundError, EnginiValidationError, EnginiRateLimitError, EnginiConflictError, EnginiServerError, EnginiClientError, EnginiConnectionError, EnginiToolsetError, EnginiToolsetNotFoundError, EnginiMcpServerNotFoundError, EnginiTimeoutError, EnginiToolExecutionError, } from "./errors.js";
|
|
9
|
+
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, ApplicationsResource, refreshFailed, } from "./resources/index.js";
|
|
8
10
|
export type { ToolsGetOptions, ToolsExecuteOptions, ApplicationsListOptions } from "./resources/index.js";
|
|
9
11
|
export { Toolset } from "./toolset.js";
|
|
10
12
|
export type { ConnectionBinding, ToolsetExecuteOptions } from "./toolset.js";
|
|
@@ -12,6 +14,7 @@ export { File } from "./files.js";
|
|
|
12
14
|
export type { FileWire } from "./files.js";
|
|
13
15
|
export type { ToolSchema, Filter, Sort, ToolExecuteResult, Application, ApplicationDetail, Connection, ConnectionDetail, ConnectionObject, WhoAmI, } from "./types.js";
|
|
14
16
|
export type { ToolsetConnectionDto, ToolsetConnectionRequest, ToolsetDto } from "@engini/client";
|
|
17
|
+
export type { McpServerPublicDto, McpServerConnectionDto, McpServerConnectionRequest, McpServerWorkflowDto, McpServerWorkflowRequest, McpAvailableToolDto, } from "@engini/client";
|
|
15
18
|
export type { Provider, ToolCall, ToolResultOptions } from "./providers/base.js";
|
|
16
19
|
export { OpenAIProvider } from "./providers/openai.js";
|
|
17
20
|
export type { OpenAIToolDef, OpenAIFunctionDef } from "./providers/openai.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { Engini, DEFAULT_BASE_URL } from "./client.js";
|
|
2
2
|
export { ApiKeyAuth, BearerAuth, ENV_API_KEY_VAR, ENV_TOKEN_VAR, ENV_COMPANY_TOKEN_VAR, } from "./auth.js";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { composeUserAgent } from "./http.js";
|
|
4
|
+
export { VERSION } from "./version.js";
|
|
5
|
+
export { EnginiError, EnginiNetworkError, EnginiAPIError, EnginiAuthError, EnginiNotFoundError, EnginiValidationError, EnginiRateLimitError, EnginiConflictError, EnginiServerError, EnginiClientError, EnginiConnectionError, EnginiToolsetError, EnginiToolsetNotFoundError, EnginiMcpServerNotFoundError, EnginiTimeoutError, EnginiToolExecutionError, } from "./errors.js";
|
|
6
|
+
export { ToolsResource, ConnectionsResource, ToolsetsResource, McpResource, ApplicationsResource, refreshFailed, } from "./resources/index.js";
|
|
5
7
|
export { Toolset } from "./toolset.js";
|
|
6
8
|
export { File } from "./files.js";
|
|
7
9
|
export { OpenAIProvider } from "./providers/openai.js";
|
|
@@ -2,5 +2,6 @@ export { ToolsResource } from "./tools.js";
|
|
|
2
2
|
export type { ToolsGetOptions, ToolsExecuteOptions } from "./tools.js";
|
|
3
3
|
export { ConnectionsResource, refreshFailed } from "./connections.js";
|
|
4
4
|
export { ToolsetsResource } from "./toolsets.js";
|
|
5
|
+
export { McpResource } from "./mcp.js";
|
|
5
6
|
export { ApplicationsResource } from "./applications.js";
|
|
6
7
|
export type { ApplicationsListOptions } from "./applications.js";
|
package/dist/resources/index.js
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP servers resource — inspect and maintain account-wide MCP servers.
|
|
3
|
+
*
|
|
4
|
+
* An MCP server is the endpoint Engini *exposes* over the Model Context Protocol,
|
|
5
|
+
* carrying a chosen set of tools and workflows. It is not the `MCPClient`
|
|
6
|
+
* connection kind, which is Engini *consuming* someone else's MCP server.
|
|
7
|
+
*
|
|
8
|
+
* Authoring and deletion stay in the engini.io UI: this resource deliberately has
|
|
9
|
+
* no `create` and no `delete`.
|
|
10
|
+
*/
|
|
11
|
+
import { type McpServerPublicDto, type McpServerConnectionRequest, type McpServerWorkflowRequest, type McpAvailableToolDto } from "@engini/client";
|
|
12
|
+
import { type Transport } from "../http.js";
|
|
13
|
+
/** Minimal client surface this resource needs (satisfied by `Engini`). */
|
|
14
|
+
export interface McpClient {
|
|
15
|
+
_transport: Transport;
|
|
16
|
+
}
|
|
17
|
+
export declare class McpResource {
|
|
18
|
+
private readonly client;
|
|
19
|
+
constructor(client: McpClient);
|
|
20
|
+
/**
|
|
21
|
+
* Every MCP server on the account, paginated.
|
|
22
|
+
*
|
|
23
|
+
* Account-wide, not per-user: an Engini API key sees every MCP server in the
|
|
24
|
+
* account. Deactivated servers are included, with `isActive` reporting state.
|
|
25
|
+
*/
|
|
26
|
+
list(): Promise<McpServerPublicDto[]>;
|
|
27
|
+
get(mcpServerToken: string): Promise<McpServerPublicDto>;
|
|
28
|
+
/**
|
|
29
|
+
* Update an MCP server. `PATCH /v1/mcpservers/{mcpServerToken}` replaces, it does
|
|
30
|
+
* not merge: an omitted member (`undefined`) leaves it unchanged, while a supplied
|
|
31
|
+
* `connections`/`workflows` list replaces the whole set. To add one connection,
|
|
32
|
+
* read the current set, append, and send the result — sending a single-element
|
|
33
|
+
* list drops every other entry.
|
|
34
|
+
*
|
|
35
|
+
* `isAnonymousAllowed` is read-only on this API and is always preserved. Every
|
|
36
|
+
* connection entry must carry an explicit `connectionId`: MCP servers are
|
|
37
|
+
* account-wide, so there is no per-user default connection to fall back on.
|
|
38
|
+
*/
|
|
39
|
+
update(mcpServerToken: string, params: {
|
|
40
|
+
name?: string;
|
|
41
|
+
isActive?: boolean;
|
|
42
|
+
connections?: McpServerConnectionRequest[];
|
|
43
|
+
workflows?: McpServerWorkflowRequest[];
|
|
44
|
+
}): Promise<McpServerPublicDto>;
|
|
45
|
+
/** Turn an MCP server on. Sends only the scalar, so nothing else is touched. */
|
|
46
|
+
activate(mcpServerToken: string): Promise<McpServerPublicDto>;
|
|
47
|
+
/** Turn an MCP server off. Reversible — a deactivated server still lists and fetches. */
|
|
48
|
+
deactivate(mcpServerToken: string): Promise<McpServerPublicDto>;
|
|
49
|
+
/** The tools a connection offers, i.e. the candidates for its `toolSlugs`. */
|
|
50
|
+
availableTools(mcpServerToken: string, connectionId: number): Promise<McpAvailableToolDto[]>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP servers resource — inspect and maintain account-wide MCP servers.
|
|
3
|
+
*
|
|
4
|
+
* An MCP server is the endpoint Engini *exposes* over the Model Context Protocol,
|
|
5
|
+
* carrying a chosen set of tools and workflows. It is not the `MCPClient`
|
|
6
|
+
* connection kind, which is Engini *consuming* someone else's MCP server.
|
|
7
|
+
*
|
|
8
|
+
* Authoring and deletion stay in the engini.io UI: this resource deliberately has
|
|
9
|
+
* no `create` and no `delete`.
|
|
10
|
+
*/
|
|
11
|
+
import { mcpServersListMcpServers, mcpServersGetMcpServer, mcpServersUpdateMcpServer, mcpServersGetAvailableTools, } from "@engini/client";
|
|
12
|
+
import { call } from "../http.js";
|
|
13
|
+
import { paginate, collect } from "../pagination.js";
|
|
14
|
+
import { EnginiNotFoundError, EnginiMcpServerNotFoundError } from "../errors.js";
|
|
15
|
+
export class McpResource {
|
|
16
|
+
client;
|
|
17
|
+
constructor(client) {
|
|
18
|
+
this.client = client;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Every MCP server on the account, paginated.
|
|
22
|
+
*
|
|
23
|
+
* Account-wide, not per-user: an Engini API key sees every MCP server in the
|
|
24
|
+
* account. Deactivated servers are included, with `isActive` reporting state.
|
|
25
|
+
*/
|
|
26
|
+
async list() {
|
|
27
|
+
const transport = this.client._transport;
|
|
28
|
+
return collect(paginate((offset, top) => call(mcpServersListMcpServers, { client: transport, query: { offset, top } })));
|
|
29
|
+
}
|
|
30
|
+
async get(mcpServerToken) {
|
|
31
|
+
try {
|
|
32
|
+
return await call(mcpServersGetMcpServer, {
|
|
33
|
+
client: this.client._transport,
|
|
34
|
+
path: { mcpServerToken },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
if (err instanceof EnginiNotFoundError) {
|
|
39
|
+
// The token is secret-equivalent (it is the SSE URL component), so unlike
|
|
40
|
+
// the toolset equivalent this message does not echo it back.
|
|
41
|
+
throw new EnginiMcpServerNotFoundError("Unknown MCP server token.");
|
|
42
|
+
}
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Update an MCP server. `PATCH /v1/mcpservers/{mcpServerToken}` replaces, it does
|
|
48
|
+
* not merge: an omitted member (`undefined`) leaves it unchanged, while a supplied
|
|
49
|
+
* `connections`/`workflows` list replaces the whole set. To add one connection,
|
|
50
|
+
* read the current set, append, and send the result — sending a single-element
|
|
51
|
+
* list drops every other entry.
|
|
52
|
+
*
|
|
53
|
+
* `isAnonymousAllowed` is read-only on this API and is always preserved. Every
|
|
54
|
+
* connection entry must carry an explicit `connectionId`: MCP servers are
|
|
55
|
+
* account-wide, so there is no per-user default connection to fall back on.
|
|
56
|
+
*/
|
|
57
|
+
async update(mcpServerToken, params) {
|
|
58
|
+
try {
|
|
59
|
+
return await call(mcpServersUpdateMcpServer, {
|
|
60
|
+
client: this.client._transport,
|
|
61
|
+
path: { mcpServerToken },
|
|
62
|
+
body: {
|
|
63
|
+
name: params.name,
|
|
64
|
+
isActive: params.isActive,
|
|
65
|
+
connections: params.connections,
|
|
66
|
+
workflows: params.workflows,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
if (err instanceof EnginiNotFoundError) {
|
|
72
|
+
throw new EnginiMcpServerNotFoundError("Unknown MCP server token.");
|
|
73
|
+
}
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Turn an MCP server on. Sends only the scalar, so nothing else is touched. */
|
|
78
|
+
async activate(mcpServerToken) {
|
|
79
|
+
return this.update(mcpServerToken, { isActive: true });
|
|
80
|
+
}
|
|
81
|
+
/** Turn an MCP server off. Reversible — a deactivated server still lists and fetches. */
|
|
82
|
+
async deactivate(mcpServerToken) {
|
|
83
|
+
return this.update(mcpServerToken, { isActive: false });
|
|
84
|
+
}
|
|
85
|
+
/** The tools a connection offers, i.e. the candidates for its `toolSlugs`. */
|
|
86
|
+
async availableTools(mcpServerToken, connectionId) {
|
|
87
|
+
try {
|
|
88
|
+
return await call(mcpServersGetAvailableTools, {
|
|
89
|
+
client: this.client._transport,
|
|
90
|
+
path: { mcpServerToken },
|
|
91
|
+
query: { connectionId },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (err instanceof EnginiNotFoundError) {
|
|
96
|
+
throw new EnginiMcpServerNotFoundError(`Unknown MCP server token, or connection ${connectionId} is not on this account.`);
|
|
97
|
+
}
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engini/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Engini SDK — agent-first ergonomic layer over the Engini Public API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,12 +18,16 @@
|
|
|
18
18
|
"directory": "ts/packages/sdk"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
+
"generate-version": "node scripts/generate-version.mjs",
|
|
22
|
+
"pretypecheck": "npm run generate-version",
|
|
23
|
+
"prebuild": "npm run generate-version",
|
|
24
|
+
"pretest": "npm run generate-version",
|
|
21
25
|
"typecheck": "tsc --noEmit",
|
|
22
26
|
"build": "tsc",
|
|
23
27
|
"test": "vitest run"
|
|
24
28
|
},
|
|
25
29
|
"dependencies": {
|
|
26
|
-
"@engini/client": "0.
|
|
30
|
+
"@engini/client": "0.7.0",
|
|
27
31
|
"undici": "^6.0.0"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|