@s2-dev/streamstore 0.3.17 → 0.5.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 +53 -1
- package/bin/mcp-server.js +43469 -0
- package/bin/mcp-server.js.map +358 -0
- package/funcs/accountCreateBasin.d.ts +2 -1
- package/funcs/accountCreateBasin.d.ts.map +1 -1
- package/funcs/accountCreateBasin.js +11 -6
- package/funcs/accountCreateBasin.js.map +1 -1
- package/funcs/accountDeleteBasin.d.ts +2 -1
- package/funcs/accountDeleteBasin.d.ts.map +1 -1
- package/funcs/accountDeleteBasin.js +11 -6
- package/funcs/accountDeleteBasin.js.map +1 -1
- package/funcs/accountGetBasinConfig.d.ts +2 -1
- package/funcs/accountGetBasinConfig.d.ts.map +1 -1
- package/funcs/accountGetBasinConfig.js +11 -6
- package/funcs/accountGetBasinConfig.js.map +1 -1
- package/funcs/accountListBasins.d.ts +2 -1
- package/funcs/accountListBasins.d.ts.map +1 -1
- package/funcs/accountListBasins.js +22 -12
- package/funcs/accountListBasins.js.map +1 -1
- package/funcs/accountReconfigureBasin.d.ts +2 -1
- package/funcs/accountReconfigureBasin.d.ts.map +1 -1
- package/funcs/accountReconfigureBasin.js +11 -6
- package/funcs/accountReconfigureBasin.js.map +1 -1
- package/funcs/basinCreateStream.d.ts +2 -1
- package/funcs/basinCreateStream.d.ts.map +1 -1
- package/funcs/basinCreateStream.js +11 -6
- package/funcs/basinCreateStream.js.map +1 -1
- package/funcs/basinDeleteStream.d.ts +2 -1
- package/funcs/basinDeleteStream.d.ts.map +1 -1
- package/funcs/basinDeleteStream.js +11 -6
- package/funcs/basinDeleteStream.js.map +1 -1
- package/funcs/basinGetStreamConfig.d.ts +2 -1
- package/funcs/basinGetStreamConfig.d.ts.map +1 -1
- package/funcs/basinGetStreamConfig.js +11 -6
- package/funcs/basinGetStreamConfig.js.map +1 -1
- package/funcs/basinListStreams.d.ts +2 -1
- package/funcs/basinListStreams.d.ts.map +1 -1
- package/funcs/basinListStreams.js +22 -12
- package/funcs/basinListStreams.js.map +1 -1
- package/funcs/basinReconfigureStream.d.ts +2 -1
- package/funcs/basinReconfigureStream.d.ts.map +1 -1
- package/funcs/basinReconfigureStream.js +11 -6
- package/funcs/basinReconfigureStream.js.map +1 -1
- package/funcs/streamAppend.d.ts +2 -1
- package/funcs/streamAppend.d.ts.map +1 -1
- package/funcs/streamAppend.js +11 -6
- package/funcs/streamAppend.js.map +1 -1
- package/funcs/streamCheckTail.d.ts +2 -1
- package/funcs/streamCheckTail.d.ts.map +1 -1
- package/funcs/streamCheckTail.js +11 -6
- package/funcs/streamCheckTail.js.map +1 -1
- package/funcs/streamRead.d.ts +2 -1
- package/funcs/streamRead.d.ts.map +1 -1
- package/funcs/streamRead.js +11 -6
- package/funcs/streamRead.js.map +1 -1
- package/hooks/types.d.ts +1 -0
- package/hooks/types.d.ts.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +6 -6
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/lib/files.js.map +1 -1
- package/lib/primitives.d.ts +3 -0
- package/lib/primitives.d.ts.map +1 -1
- package/lib/primitives.js +7 -0
- package/lib/primitives.js.map +1 -1
- package/lib/sdks.d.ts +1 -1
- package/lib/sdks.d.ts.map +1 -1
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js.map +1 -1
- package/mcp-server/build.d.mts.map +1 -0
- package/mcp-server/build.mjs +14 -0
- package/mcp-server/build.mjs.map +1 -0
- package/mcp-server/cli/start/command.d.ts +2 -0
- package/mcp-server/cli/start/command.d.ts.map +1 -0
- package/mcp-server/cli/start/command.js +129 -0
- package/mcp-server/cli/start/command.js.map +1 -0
- package/mcp-server/cli/start/impl.d.ts +17 -0
- package/mcp-server/cli/start/impl.d.ts.map +1 -0
- package/mcp-server/cli/start/impl.js +102 -0
- package/mcp-server/cli/start/impl.js.map +1 -0
- package/mcp-server/cli.d.ts +6 -0
- package/mcp-server/cli.d.ts.map +1 -0
- package/mcp-server/cli.js +10 -0
- package/mcp-server/cli.js.map +1 -0
- package/mcp-server/console-logger.d.ts +7 -0
- package/mcp-server/console-logger.d.ts.map +1 -0
- package/mcp-server/console-logger.js +59 -0
- package/mcp-server/console-logger.js.map +1 -0
- package/mcp-server/mcp-server.d.ts +2 -0
- package/mcp-server/mcp-server.d.ts.map +1 -0
- package/mcp-server/mcp-server.js +29 -0
- package/mcp-server/mcp-server.js.map +1 -0
- package/mcp-server/resources.d.ts +27 -0
- package/mcp-server/resources.d.ts.map +1 -0
- package/mcp-server/resources.js +51 -0
- package/mcp-server/resources.js.map +1 -0
- package/mcp-server/scopes.d.ts +3 -0
- package/mcp-server/scopes.d.ts.map +1 -0
- package/mcp-server/scopes.js +11 -0
- package/mcp-server/scopes.js.map +1 -0
- package/mcp-server/server.d.ts +12 -0
- package/mcp-server/server.d.ts.map +1 -0
- package/mcp-server/server.js +51 -0
- package/mcp-server/server.js.map +1 -0
- package/mcp-server/shared.d.ts +7 -0
- package/mcp-server/shared.d.ts.map +1 -0
- package/mcp-server/shared.js +98 -0
- package/mcp-server/shared.js.map +1 -0
- package/mcp-server/tools/accountCreateBasin.d.ts +8 -0
- package/mcp-server/tools/accountCreateBasin.d.ts.map +1 -0
- package/mcp-server/tools/accountCreateBasin.js +63 -0
- package/mcp-server/tools/accountCreateBasin.js.map +1 -0
- package/mcp-server/tools/accountDeleteBasin.d.ts +8 -0
- package/mcp-server/tools/accountDeleteBasin.d.ts.map +1 -0
- package/mcp-server/tools/accountDeleteBasin.js +62 -0
- package/mcp-server/tools/accountDeleteBasin.js.map +1 -0
- package/mcp-server/tools/accountGetBasinConfig.d.ts +8 -0
- package/mcp-server/tools/accountGetBasinConfig.d.ts.map +1 -0
- package/mcp-server/tools/accountGetBasinConfig.js +63 -0
- package/mcp-server/tools/accountGetBasinConfig.js.map +1 -0
- package/mcp-server/tools/accountListBasins.d.ts +8 -0
- package/mcp-server/tools/accountListBasins.d.ts.map +1 -0
- package/mcp-server/tools/accountListBasins.js +63 -0
- package/mcp-server/tools/accountListBasins.js.map +1 -0
- package/mcp-server/tools/accountReconfigureBasin.d.ts +8 -0
- package/mcp-server/tools/accountReconfigureBasin.d.ts.map +1 -0
- package/mcp-server/tools/accountReconfigureBasin.js +63 -0
- package/mcp-server/tools/accountReconfigureBasin.js.map +1 -0
- package/mcp-server/tools/basinCreateStream.d.ts +8 -0
- package/mcp-server/tools/basinCreateStream.d.ts.map +1 -0
- package/mcp-server/tools/basinCreateStream.js +63 -0
- package/mcp-server/tools/basinCreateStream.js.map +1 -0
- package/mcp-server/tools/basinDeleteStream.d.ts +8 -0
- package/mcp-server/tools/basinDeleteStream.d.ts.map +1 -0
- package/mcp-server/tools/basinDeleteStream.js +62 -0
- package/mcp-server/tools/basinDeleteStream.js.map +1 -0
- package/mcp-server/tools/basinGetStreamConfig.d.ts +8 -0
- package/mcp-server/tools/basinGetStreamConfig.d.ts.map +1 -0
- package/mcp-server/tools/basinGetStreamConfig.js +63 -0
- package/mcp-server/tools/basinGetStreamConfig.js.map +1 -0
- package/mcp-server/tools/basinListStreams.d.ts +8 -0
- package/mcp-server/tools/basinListStreams.d.ts.map +1 -0
- package/mcp-server/tools/basinListStreams.js +63 -0
- package/mcp-server/tools/basinListStreams.js.map +1 -0
- package/mcp-server/tools/basinReconfigureStream.d.ts +8 -0
- package/mcp-server/tools/basinReconfigureStream.d.ts.map +1 -0
- package/mcp-server/tools/basinReconfigureStream.js +63 -0
- package/mcp-server/tools/basinReconfigureStream.js.map +1 -0
- package/mcp-server/tools/streamAppend.d.ts +8 -0
- package/mcp-server/tools/streamAppend.d.ts.map +1 -0
- package/mcp-server/tools/streamAppend.js +65 -0
- package/mcp-server/tools/streamAppend.js.map +1 -0
- package/mcp-server/tools/streamCheckTail.d.ts +8 -0
- package/mcp-server/tools/streamCheckTail.d.ts.map +1 -0
- package/mcp-server/tools/streamCheckTail.js +65 -0
- package/mcp-server/tools/streamCheckTail.js.map +1 -0
- package/mcp-server/tools/streamRead.d.ts +8 -0
- package/mcp-server/tools/streamRead.d.ts.map +1 -0
- package/mcp-server/tools/streamRead.js +65 -0
- package/mcp-server/tools/streamRead.js.map +1 -0
- package/mcp-server/tools.d.ts +25 -0
- package/mcp-server/tools.d.ts.map +1 -0
- package/mcp-server/tools.js +74 -0
- package/mcp-server/tools.js.map +1 -0
- package/models/components/endpoints.d.ts +67 -0
- package/models/components/endpoints.d.ts.map +1 -0
- package/models/components/endpoints.js +126 -0
- package/models/components/endpoints.js.map +1 -0
- package/package.json +17 -4
- package/src/funcs/accountCreateBasin.ts +38 -7
- package/src/funcs/accountDeleteBasin.ts +39 -7
- package/src/funcs/accountGetBasinConfig.ts +38 -7
- package/src/funcs/accountListBasins.ts +53 -10
- package/src/funcs/accountReconfigureBasin.ts +38 -7
- package/src/funcs/basinCreateStream.ts +38 -7
- package/src/funcs/basinDeleteStream.ts +39 -7
- package/src/funcs/basinGetStreamConfig.ts +38 -7
- package/src/funcs/basinListStreams.ts +53 -10
- package/src/funcs/basinReconfigureStream.ts +38 -7
- package/src/funcs/streamAppend.ts +38 -7
- package/src/funcs/streamCheckTail.ts +38 -7
- package/src/funcs/streamRead.ts +38 -7
- package/src/hooks/types.ts +1 -0
- package/src/lib/config.ts +6 -7
- package/src/lib/files.ts +1 -1
- package/src/lib/primitives.ts +14 -0
- package/src/lib/sdks.ts +1 -1
- package/src/lib/security.ts +0 -1
- package/src/mcp-server/cli/start/command.ts +98 -0
- package/src/mcp-server/cli/start/impl.ts +131 -0
- package/src/mcp-server/cli.ts +13 -0
- package/src/mcp-server/console-logger.ts +71 -0
- package/src/mcp-server/mcp-server.ts +26 -0
- package/src/mcp-server/resources.ts +96 -0
- package/src/mcp-server/scopes.ts +10 -0
- package/src/mcp-server/server.ts +60 -0
- package/src/mcp-server/shared.ts +75 -0
- package/src/mcp-server/tools/accountCreateBasin.ts +36 -0
- package/src/mcp-server/tools/accountDeleteBasin.ts +34 -0
- package/src/mcp-server/tools/accountGetBasinConfig.ts +36 -0
- package/src/mcp-server/tools/accountListBasins.ts +36 -0
- package/src/mcp-server/tools/accountReconfigureBasin.ts +36 -0
- package/src/mcp-server/tools/basinCreateStream.ts +36 -0
- package/src/mcp-server/tools/basinDeleteStream.ts +34 -0
- package/src/mcp-server/tools/basinGetStreamConfig.ts +36 -0
- package/src/mcp-server/tools/basinListStreams.ts +36 -0
- package/src/mcp-server/tools/basinReconfigureStream.ts +36 -0
- package/src/mcp-server/tools/streamAppend.ts +38 -0
- package/src/mcp-server/tools/streamCheckTail.ts +38 -0
- package/src/mcp-server/tools/streamRead.ts +38 -0
- package/src/mcp-server/tools.ts +116 -0
- package/src/models/components/endpoints.ts +159 -0
- package/src/types/async.ts +68 -0
- package/types/async.d.ts +23 -0
- package/types/async.d.ts.map +1 -0
- package/types/async.js +44 -0
- package/types/async.js.map +1 -0
|
@@ -23,6 +23,7 @@ import * as errors from "../models/errors/index.js";
|
|
|
23
23
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
24
|
import { AppendServerList } from "../models/operations/append.js";
|
|
25
25
|
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
27
|
import { Result } from "../types/fp.js";
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -31,11 +32,11 @@ import { Result } from "../types/fp.js";
|
|
|
31
32
|
* @remarks
|
|
32
33
|
* Append a batch of records to a stream.
|
|
33
34
|
*/
|
|
34
|
-
export
|
|
35
|
+
export function streamAppend(
|
|
35
36
|
client: S2Core,
|
|
36
37
|
request: operations.AppendRequest,
|
|
37
38
|
options?: RequestOptions,
|
|
38
|
-
):
|
|
39
|
+
): APIPromise<
|
|
39
40
|
Result<
|
|
40
41
|
components.AppendOutput,
|
|
41
42
|
| errors.ErrorResponse
|
|
@@ -49,6 +50,35 @@ export async function streamAppend(
|
|
|
49
50
|
| RequestTimeoutError
|
|
50
51
|
| ConnectionError
|
|
51
52
|
>
|
|
53
|
+
> {
|
|
54
|
+
return new APIPromise($do(
|
|
55
|
+
client,
|
|
56
|
+
request,
|
|
57
|
+
options,
|
|
58
|
+
));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function $do(
|
|
62
|
+
client: S2Core,
|
|
63
|
+
request: operations.AppendRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<
|
|
66
|
+
[
|
|
67
|
+
Result<
|
|
68
|
+
components.AppendOutput,
|
|
69
|
+
| errors.ErrorResponse
|
|
70
|
+
| errors.RetryableError
|
|
71
|
+
| errors.RetryableError
|
|
72
|
+
| APIError
|
|
73
|
+
| SDKValidationError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| InvalidRequestError
|
|
76
|
+
| RequestAbortedError
|
|
77
|
+
| RequestTimeoutError
|
|
78
|
+
| ConnectionError
|
|
79
|
+
>,
|
|
80
|
+
APICall,
|
|
81
|
+
]
|
|
52
82
|
> {
|
|
53
83
|
const parsed = safeParse(
|
|
54
84
|
request,
|
|
@@ -56,7 +86,7 @@ export async function streamAppend(
|
|
|
56
86
|
"Input validation failed",
|
|
57
87
|
);
|
|
58
88
|
if (!parsed.ok) {
|
|
59
|
-
return parsed;
|
|
89
|
+
return [parsed, { status: "invalid" }];
|
|
60
90
|
}
|
|
61
91
|
const payload = parsed.value;
|
|
62
92
|
const body = encodeJSON("body", payload.AppendInput, { explode: true });
|
|
@@ -89,6 +119,7 @@ export async function streamAppend(
|
|
|
89
119
|
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
90
120
|
|
|
91
121
|
const context = {
|
|
122
|
+
baseURL: baseURL ?? "",
|
|
92
123
|
operationID: "append",
|
|
93
124
|
oAuth2Scopes: [],
|
|
94
125
|
|
|
@@ -111,7 +142,7 @@ export async function streamAppend(
|
|
|
111
142
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
112
143
|
}, options);
|
|
113
144
|
if (!requestRes.ok) {
|
|
114
|
-
return requestRes;
|
|
145
|
+
return [requestRes, { status: "invalid" }];
|
|
115
146
|
}
|
|
116
147
|
const req = requestRes.value;
|
|
117
148
|
|
|
@@ -122,7 +153,7 @@ export async function streamAppend(
|
|
|
122
153
|
retryCodes: context.retryCodes,
|
|
123
154
|
});
|
|
124
155
|
if (!doResult.ok) {
|
|
125
|
-
return doResult;
|
|
156
|
+
return [doResult, { status: "request-error", request: req }];
|
|
126
157
|
}
|
|
127
158
|
const response = doResult.value;
|
|
128
159
|
|
|
@@ -151,8 +182,8 @@ export async function streamAppend(
|
|
|
151
182
|
M.fail("5XX"),
|
|
152
183
|
)(response, { extraFields: responseFields });
|
|
153
184
|
if (!result.ok) {
|
|
154
|
-
return result;
|
|
185
|
+
return [result, { status: "complete", request: req, response }];
|
|
155
186
|
}
|
|
156
187
|
|
|
157
|
-
return result;
|
|
188
|
+
return [result, { status: "complete", request: req, response }];
|
|
158
189
|
}
|
|
@@ -23,6 +23,7 @@ import * as errors from "../models/errors/index.js";
|
|
|
23
23
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
24
|
import { CheckTailServerList } from "../models/operations/checktail.js";
|
|
25
25
|
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
27
|
import { Result } from "../types/fp.js";
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -31,11 +32,11 @@ import { Result } from "../types/fp.js";
|
|
|
31
32
|
* @remarks
|
|
32
33
|
* Check the sequence number that will be assigned to the next record on a stream.
|
|
33
34
|
*/
|
|
34
|
-
export
|
|
35
|
+
export function streamCheckTail(
|
|
35
36
|
client: S2Core,
|
|
36
37
|
request: operations.CheckTailRequest,
|
|
37
38
|
options?: RequestOptions,
|
|
38
|
-
):
|
|
39
|
+
): APIPromise<
|
|
39
40
|
Result<
|
|
40
41
|
components.CheckTailResponse,
|
|
41
42
|
| errors.ErrorResponse
|
|
@@ -49,6 +50,35 @@ export async function streamCheckTail(
|
|
|
49
50
|
| RequestTimeoutError
|
|
50
51
|
| ConnectionError
|
|
51
52
|
>
|
|
53
|
+
> {
|
|
54
|
+
return new APIPromise($do(
|
|
55
|
+
client,
|
|
56
|
+
request,
|
|
57
|
+
options,
|
|
58
|
+
));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function $do(
|
|
62
|
+
client: S2Core,
|
|
63
|
+
request: operations.CheckTailRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<
|
|
66
|
+
[
|
|
67
|
+
Result<
|
|
68
|
+
components.CheckTailResponse,
|
|
69
|
+
| errors.ErrorResponse
|
|
70
|
+
| errors.RetryableError
|
|
71
|
+
| errors.RetryableError
|
|
72
|
+
| APIError
|
|
73
|
+
| SDKValidationError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| InvalidRequestError
|
|
76
|
+
| RequestAbortedError
|
|
77
|
+
| RequestTimeoutError
|
|
78
|
+
| ConnectionError
|
|
79
|
+
>,
|
|
80
|
+
APICall,
|
|
81
|
+
]
|
|
52
82
|
> {
|
|
53
83
|
const parsed = safeParse(
|
|
54
84
|
request,
|
|
@@ -56,7 +86,7 @@ export async function streamCheckTail(
|
|
|
56
86
|
"Input validation failed",
|
|
57
87
|
);
|
|
58
88
|
if (!parsed.ok) {
|
|
59
|
-
return parsed;
|
|
89
|
+
return [parsed, { status: "invalid" }];
|
|
60
90
|
}
|
|
61
91
|
const payload = parsed.value;
|
|
62
92
|
const body = null;
|
|
@@ -84,6 +114,7 @@ export async function streamCheckTail(
|
|
|
84
114
|
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
85
115
|
|
|
86
116
|
const context = {
|
|
117
|
+
baseURL: baseURL ?? "",
|
|
87
118
|
operationID: "check_tail",
|
|
88
119
|
oAuth2Scopes: [],
|
|
89
120
|
|
|
@@ -106,7 +137,7 @@ export async function streamCheckTail(
|
|
|
106
137
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
107
138
|
}, options);
|
|
108
139
|
if (!requestRes.ok) {
|
|
109
|
-
return requestRes;
|
|
140
|
+
return [requestRes, { status: "invalid" }];
|
|
110
141
|
}
|
|
111
142
|
const req = requestRes.value;
|
|
112
143
|
|
|
@@ -117,7 +148,7 @@ export async function streamCheckTail(
|
|
|
117
148
|
retryCodes: context.retryCodes,
|
|
118
149
|
});
|
|
119
150
|
if (!doResult.ok) {
|
|
120
|
-
return doResult;
|
|
151
|
+
return [doResult, { status: "request-error", request: req }];
|
|
121
152
|
}
|
|
122
153
|
const response = doResult.value;
|
|
123
154
|
|
|
@@ -146,8 +177,8 @@ export async function streamCheckTail(
|
|
|
146
177
|
M.fail("5XX"),
|
|
147
178
|
)(response, { extraFields: responseFields });
|
|
148
179
|
if (!result.ok) {
|
|
149
|
-
return result;
|
|
180
|
+
return [result, { status: "complete", request: req, response }];
|
|
150
181
|
}
|
|
151
182
|
|
|
152
|
-
return result;
|
|
183
|
+
return [result, { status: "complete", request: req, response }];
|
|
153
184
|
}
|
package/src/funcs/streamRead.ts
CHANGED
|
@@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js";
|
|
|
22
22
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
23
|
import * as operations from "../models/operations/index.js";
|
|
24
24
|
import { ReadServerList } from "../models/operations/read.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
26
|
import { Result } from "../types/fp.js";
|
|
26
27
|
|
|
27
28
|
export enum ReadAcceptEnum {
|
|
@@ -35,11 +36,11 @@ export enum ReadAcceptEnum {
|
|
|
35
36
|
* @remarks
|
|
36
37
|
* Retrieve a batch of records, or set `Accept: text/event-stream` to stream using server-sent events.
|
|
37
38
|
*/
|
|
38
|
-
export
|
|
39
|
+
export function streamRead(
|
|
39
40
|
client: S2Core,
|
|
40
41
|
request: operations.ReadRequest,
|
|
41
42
|
options?: RequestOptions & { acceptHeaderOverride?: ReadAcceptEnum },
|
|
42
|
-
):
|
|
43
|
+
): APIPromise<
|
|
43
44
|
Result<
|
|
44
45
|
operations.ReadResponse,
|
|
45
46
|
| errors.ErrorResponse
|
|
@@ -53,6 +54,35 @@ export async function streamRead(
|
|
|
53
54
|
| RequestTimeoutError
|
|
54
55
|
| ConnectionError
|
|
55
56
|
>
|
|
57
|
+
> {
|
|
58
|
+
return new APIPromise($do(
|
|
59
|
+
client,
|
|
60
|
+
request,
|
|
61
|
+
options,
|
|
62
|
+
));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function $do(
|
|
66
|
+
client: S2Core,
|
|
67
|
+
request: operations.ReadRequest,
|
|
68
|
+
options?: RequestOptions & { acceptHeaderOverride?: ReadAcceptEnum },
|
|
69
|
+
): Promise<
|
|
70
|
+
[
|
|
71
|
+
Result<
|
|
72
|
+
operations.ReadResponse,
|
|
73
|
+
| errors.ErrorResponse
|
|
74
|
+
| errors.RetryableError
|
|
75
|
+
| errors.RetryableError
|
|
76
|
+
| APIError
|
|
77
|
+
| SDKValidationError
|
|
78
|
+
| UnexpectedClientError
|
|
79
|
+
| InvalidRequestError
|
|
80
|
+
| RequestAbortedError
|
|
81
|
+
| RequestTimeoutError
|
|
82
|
+
| ConnectionError
|
|
83
|
+
>,
|
|
84
|
+
APICall,
|
|
85
|
+
]
|
|
56
86
|
> {
|
|
57
87
|
const parsed = safeParse(
|
|
58
88
|
request,
|
|
@@ -60,7 +90,7 @@ export async function streamRead(
|
|
|
60
90
|
"Input validation failed",
|
|
61
91
|
);
|
|
62
92
|
if (!parsed.ok) {
|
|
63
|
-
return parsed;
|
|
93
|
+
return [parsed, { status: "invalid" }];
|
|
64
94
|
}
|
|
65
95
|
const payload = parsed.value;
|
|
66
96
|
const body = null;
|
|
@@ -98,6 +128,7 @@ export async function streamRead(
|
|
|
98
128
|
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
99
129
|
|
|
100
130
|
const context = {
|
|
131
|
+
baseURL: baseURL ?? "",
|
|
101
132
|
operationID: "read",
|
|
102
133
|
oAuth2Scopes: [],
|
|
103
134
|
|
|
@@ -121,7 +152,7 @@ export async function streamRead(
|
|
|
121
152
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
122
153
|
}, options);
|
|
123
154
|
if (!requestRes.ok) {
|
|
124
|
-
return requestRes;
|
|
155
|
+
return [requestRes, { status: "invalid" }];
|
|
125
156
|
}
|
|
126
157
|
const req = requestRes.value;
|
|
127
158
|
|
|
@@ -132,7 +163,7 @@ export async function streamRead(
|
|
|
132
163
|
retryCodes: context.retryCodes,
|
|
133
164
|
});
|
|
134
165
|
if (!doResult.ok) {
|
|
135
|
-
return doResult;
|
|
166
|
+
return [doResult, { status: "request-error", request: req }];
|
|
136
167
|
}
|
|
137
168
|
const response = doResult.value;
|
|
138
169
|
|
|
@@ -162,8 +193,8 @@ export async function streamRead(
|
|
|
162
193
|
M.fail("5XX"),
|
|
163
194
|
)(response, { extraFields: responseFields });
|
|
164
195
|
if (!result.ok) {
|
|
165
|
-
return result;
|
|
196
|
+
return [result, { status: "complete", request: req, response }];
|
|
166
197
|
}
|
|
167
198
|
|
|
168
|
-
return result;
|
|
199
|
+
return [result, { status: "complete", request: req, response }];
|
|
169
200
|
}
|
package/src/hooks/types.ts
CHANGED
package/src/lib/config.ts
CHANGED
|
@@ -15,17 +15,17 @@ export const ServerList = [
|
|
|
15
15
|
] as const;
|
|
16
16
|
|
|
17
17
|
export type SDKOptions = {
|
|
18
|
-
bearerAuth?: string | (() => Promise<string>);
|
|
18
|
+
bearerAuth?: string | (() => Promise<string>) | undefined;
|
|
19
19
|
|
|
20
20
|
httpClient?: HTTPClient;
|
|
21
21
|
/**
|
|
22
22
|
* Allows overriding the default server used by the SDK
|
|
23
23
|
*/
|
|
24
|
-
serverIdx?: number;
|
|
24
|
+
serverIdx?: number | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* Allows overriding the default server URL used by the SDK
|
|
27
27
|
*/
|
|
28
|
-
serverURL?: string;
|
|
28
|
+
serverURL?: string | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Allows overriding the default retry config used by the SDK
|
|
31
31
|
*/
|
|
@@ -54,8 +54,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
54
54
|
export const SDK_METADATA = {
|
|
55
55
|
language: "typescript",
|
|
56
56
|
openapiDocVersion: "1.0.0",
|
|
57
|
-
sdkVersion: "0.
|
|
58
|
-
genVersion: "2.
|
|
59
|
-
userAgent:
|
|
60
|
-
"speakeasy-sdk/typescript 0.3.17 2.506.0 1.0.0 @s2-dev/streamstore",
|
|
57
|
+
sdkVersion: "0.5.0",
|
|
58
|
+
genVersion: "2.531.0",
|
|
59
|
+
userAgent: "speakeasy-sdk/typescript 0.5.0 2.531.0 1.0.0 @s2-dev/streamstore",
|
|
61
60
|
} as const;
|
package/src/lib/files.ts
CHANGED
package/src/lib/primitives.ts
CHANGED
|
@@ -134,3 +134,17 @@ export function compactMap<T>(
|
|
|
134
134
|
|
|
135
135
|
return out;
|
|
136
136
|
}
|
|
137
|
+
|
|
138
|
+
export function allRequired<V extends Record<string, unknown>>(
|
|
139
|
+
v: V,
|
|
140
|
+
):
|
|
141
|
+
| {
|
|
142
|
+
[K in keyof V]: NonNullable<V[K]>;
|
|
143
|
+
}
|
|
144
|
+
| undefined {
|
|
145
|
+
if (Object.values(v).every((x) => x == null)) {
|
|
146
|
+
return void 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return v as ReturnType<typeof allRequired<V>>;
|
|
150
|
+
}
|
package/src/lib/sdks.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class ClientSDK {
|
|
|
79
79
|
readonly #httpClient: HTTPClient;
|
|
80
80
|
readonly #hooks: SDKHooks;
|
|
81
81
|
readonly #logger?: Logger | undefined;
|
|
82
|
-
|
|
82
|
+
public readonly _baseURL: URL | null;
|
|
83
83
|
public readonly _options: SDKOptions & { hooks?: SDKHooks };
|
|
84
84
|
|
|
85
85
|
constructor(options: SDKOptions = {}) {
|
package/src/lib/security.ts
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { buildCommand } from "@stricli/core";
|
|
6
|
+
import { numberParser } from "@stricli/core";
|
|
7
|
+
import * as z from "zod";
|
|
8
|
+
import { consoleLoggerLevels } from "../../console-logger.js";
|
|
9
|
+
import { mcpScopes } from "../../scopes.js";
|
|
10
|
+
|
|
11
|
+
export const startCommand = buildCommand({
|
|
12
|
+
loader: async () => {
|
|
13
|
+
const { main } = await import("./impl.js");
|
|
14
|
+
return main;
|
|
15
|
+
},
|
|
16
|
+
parameters: {
|
|
17
|
+
flags: {
|
|
18
|
+
transport: {
|
|
19
|
+
kind: "enum",
|
|
20
|
+
brief: "The transport to use for communicating with the server",
|
|
21
|
+
default: "stdio",
|
|
22
|
+
values: ["stdio", "sse"],
|
|
23
|
+
},
|
|
24
|
+
port: {
|
|
25
|
+
kind: "parsed",
|
|
26
|
+
brief: "The port to use when the SSE transport is enabled",
|
|
27
|
+
default: "2718",
|
|
28
|
+
parse: (val: string) =>
|
|
29
|
+
z.coerce.number().int().gte(0).lt(65536).parse(val),
|
|
30
|
+
},
|
|
31
|
+
...(mcpScopes.length
|
|
32
|
+
? {
|
|
33
|
+
scope: {
|
|
34
|
+
kind: "enum",
|
|
35
|
+
brief:
|
|
36
|
+
"Mount tools/resources that match given scope (repeatable flag)",
|
|
37
|
+
values: mcpScopes,
|
|
38
|
+
variadic: true,
|
|
39
|
+
optional: true,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
: {}),
|
|
43
|
+
"bearer-auth": {
|
|
44
|
+
kind: "parsed",
|
|
45
|
+
brief: "Sets the bearerAuth auth field for the API",
|
|
46
|
+
optional: true,
|
|
47
|
+
parse: (value) => {
|
|
48
|
+
return z.string().parse(value);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
"server-url": {
|
|
52
|
+
kind: "parsed",
|
|
53
|
+
brief: "Overrides the default server URL used by the SDK",
|
|
54
|
+
optional: true,
|
|
55
|
+
parse: (value) => new URL(value).toString(),
|
|
56
|
+
},
|
|
57
|
+
"server-index": {
|
|
58
|
+
kind: "parsed",
|
|
59
|
+
brief: "Selects a predefined server used by the SDK",
|
|
60
|
+
optional: true,
|
|
61
|
+
parse: numberParser,
|
|
62
|
+
},
|
|
63
|
+
"log-level": {
|
|
64
|
+
kind: "enum",
|
|
65
|
+
brief: "The log level to use for the server",
|
|
66
|
+
default: "info",
|
|
67
|
+
values: consoleLoggerLevels,
|
|
68
|
+
},
|
|
69
|
+
env: {
|
|
70
|
+
kind: "parsed",
|
|
71
|
+
brief: "Environment variables made available to the server",
|
|
72
|
+
optional: true,
|
|
73
|
+
variadic: true,
|
|
74
|
+
parse: (val: string) => {
|
|
75
|
+
const sepIdx = val.indexOf("=");
|
|
76
|
+
if (sepIdx === -1) {
|
|
77
|
+
throw new Error("Invalid environment variable format");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const key = val.slice(0, sepIdx);
|
|
81
|
+
const value = val.slice(sepIdx + 1);
|
|
82
|
+
|
|
83
|
+
return [
|
|
84
|
+
z.string().nonempty({
|
|
85
|
+
message: "Environment variable key must be a non-empty string",
|
|
86
|
+
}).parse(key),
|
|
87
|
+
z.string().nonempty({
|
|
88
|
+
message: "Environment variable value must be a non-empty string",
|
|
89
|
+
}).parse(value),
|
|
90
|
+
] satisfies [string, string];
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
docs: {
|
|
96
|
+
brief: "Run the Model Context Protocol server",
|
|
97
|
+
},
|
|
98
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import express from "express";
|
|
8
|
+
import { SDKOptions } from "../../../lib/config.js";
|
|
9
|
+
import { LocalContext } from "../../cli.js";
|
|
10
|
+
import {
|
|
11
|
+
ConsoleLoggerLevel,
|
|
12
|
+
createConsoleLogger,
|
|
13
|
+
} from "../../console-logger.js";
|
|
14
|
+
import { MCPScope } from "../../scopes.js";
|
|
15
|
+
import { createMCPServer } from "../../server.js";
|
|
16
|
+
|
|
17
|
+
interface StartCommandFlags {
|
|
18
|
+
readonly transport: "stdio" | "sse";
|
|
19
|
+
readonly port: number;
|
|
20
|
+
readonly scope?: MCPScope[];
|
|
21
|
+
readonly "bearer-auth"?: string | undefined;
|
|
22
|
+
readonly "server-url"?: string;
|
|
23
|
+
readonly "server-index"?: SDKOptions["serverIdx"];
|
|
24
|
+
readonly "log-level": ConsoleLoggerLevel;
|
|
25
|
+
readonly env?: [string, string][];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function main(this: LocalContext, flags: StartCommandFlags) {
|
|
29
|
+
flags.env?.forEach(([key, value]) => {
|
|
30
|
+
process.env[key] = value;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
switch (flags.transport) {
|
|
34
|
+
case "stdio":
|
|
35
|
+
await startStdio(flags);
|
|
36
|
+
break;
|
|
37
|
+
case "sse":
|
|
38
|
+
await startSSE(flags);
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(`Invalid transport: ${flags.transport}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function startStdio(flags: StartCommandFlags) {
|
|
46
|
+
const logger = createConsoleLogger(flags["log-level"]);
|
|
47
|
+
const transport = new StdioServerTransport();
|
|
48
|
+
const server = createMCPServer({
|
|
49
|
+
logger,
|
|
50
|
+
scopes: flags.scope,
|
|
51
|
+
...{ bearerAuth: flags["bearer-auth"] },
|
|
52
|
+
serverURL: flags["server-url"],
|
|
53
|
+
serverIdx: flags["server-index"],
|
|
54
|
+
});
|
|
55
|
+
await server.connect(transport);
|
|
56
|
+
|
|
57
|
+
const abort = async () => {
|
|
58
|
+
await server.close();
|
|
59
|
+
process.exit(0);
|
|
60
|
+
};
|
|
61
|
+
process.on("SIGTERM", abort);
|
|
62
|
+
process.on("SIGINT", abort);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function startSSE(flags: StartCommandFlags) {
|
|
66
|
+
const logger = createConsoleLogger(flags["log-level"]);
|
|
67
|
+
const app = express();
|
|
68
|
+
const mcpServer = createMCPServer({
|
|
69
|
+
logger,
|
|
70
|
+
scopes: flags.scope,
|
|
71
|
+
...{ bearerAuth: flags["bearer-auth"] },
|
|
72
|
+
serverURL: flags["server-url"],
|
|
73
|
+
serverIdx: flags["server-index"],
|
|
74
|
+
});
|
|
75
|
+
let transport: SSEServerTransport | undefined;
|
|
76
|
+
const controller = new AbortController();
|
|
77
|
+
|
|
78
|
+
app.get("/sse", async (_req, res) => {
|
|
79
|
+
transport = new SSEServerTransport("/message", res);
|
|
80
|
+
|
|
81
|
+
await mcpServer.connect(transport);
|
|
82
|
+
|
|
83
|
+
mcpServer.server.onclose = async () => {
|
|
84
|
+
res.end();
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
app.post("/message", async (req, res) => {
|
|
89
|
+
if (!transport) {
|
|
90
|
+
throw new Error("Server transport not initialized");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await transport.handlePostMessage(req, res);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const httpServer = app.listen(flags.port, "0.0.0.0", () => {
|
|
97
|
+
const ha = httpServer.address();
|
|
98
|
+
const host = typeof ha === "string" ? ha : `${ha?.address}:${ha?.port}`;
|
|
99
|
+
logger.info("MCP HTTP server started", { host });
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
let closing = false;
|
|
103
|
+
controller.signal.addEventListener("abort", async () => {
|
|
104
|
+
if (closing) {
|
|
105
|
+
logger.info("Received second signal. Forcing shutdown.");
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
closing = true;
|
|
109
|
+
|
|
110
|
+
logger.info("Shutting down MCP server");
|
|
111
|
+
|
|
112
|
+
await mcpServer.close();
|
|
113
|
+
|
|
114
|
+
logger.info("Shutting down HTTP server");
|
|
115
|
+
|
|
116
|
+
const timer = setTimeout(() => {
|
|
117
|
+
logger.info("Forcing shutdown");
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}, 5000);
|
|
120
|
+
|
|
121
|
+
httpServer.close(() => {
|
|
122
|
+
clearTimeout(timer);
|
|
123
|
+
logger.info("Graceful shutdown complete");
|
|
124
|
+
process.exit(0);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const abort = () => controller.abort();
|
|
129
|
+
process.on("SIGTERM", abort);
|
|
130
|
+
process.on("SIGINT", abort);
|
|
131
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CommandContext, StricliProcess } from "@stricli/core";
|
|
6
|
+
|
|
7
|
+
export interface LocalContext extends CommandContext {
|
|
8
|
+
readonly process: StricliProcess;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function buildContext(process: NodeJS.Process): LocalContext {
|
|
12
|
+
return { process: process as StricliProcess };
|
|
13
|
+
}
|