@greensecurity/javascript-sdk 0.10.2 → 0.12.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 -0
- package/bin/mcp-server.js +39429 -0
- package/bin/mcp-server.js.map +301 -0
- package/funcs/organizationsGetFacility.js +1 -1
- package/funcs/organizationsGetFacility.js.map +1 -1
- package/funcs/organizationsListOrSearchFacilities.js +1 -1
- package/funcs/organizationsListOrSearchFacilities.js.map +1 -1
- package/funcs/userGetCurrentUser.js +1 -1
- package/funcs/userGetCurrentUser.js.map +1 -1
- package/funcs/userGetUserById.js +1 -1
- package/funcs/userGetUserById.js.map +1 -1
- package/funcs/userLogsUserIntoTheSystem.js +1 -1
- package/funcs/userLogsUserIntoTheSystem.js.map +1 -1
- package/funcs/userMagiclink.js +1 -1
- package/funcs/userMagiclink.js.map +1 -1
- package/funcs/userPassword.js +1 -1
- package/funcs/userPassword.js.map +1 -1
- package/funcs/userPasswordResetRequest.js +1 -1
- package/funcs/userPasswordResetRequest.js.map +1 -1
- package/funcs/vendorsCreateVendorRegistration.js +1 -1
- package/funcs/vendorsCreateVendorRegistration.js.map +1 -1
- package/funcs/vendorsListVendorJobTitles.js +1 -1
- package/funcs/vendorsListVendorJobTitles.js.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/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 +137 -0
- package/mcp-server/cli/start/command.js.map +1 -0
- package/mcp-server/cli/start/impl.d.ts +18 -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 +8 -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 +45 -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/organizationsGetFacility.d.ts +8 -0
- package/mcp-server/tools/organizationsGetFacility.d.ts.map +1 -0
- package/mcp-server/tools/organizationsGetFacility.js +64 -0
- package/mcp-server/tools/organizationsGetFacility.js.map +1 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts +8 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts.map +1 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.js +77 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.js.map +1 -0
- package/mcp-server/tools/userGetCurrentUser.d.ts +3 -0
- package/mcp-server/tools/userGetCurrentUser.d.ts.map +1 -0
- package/mcp-server/tools/userGetCurrentUser.js +26 -0
- package/mcp-server/tools/userGetCurrentUser.js.map +1 -0
- package/mcp-server/tools/userGetUserById.d.ts +8 -0
- package/mcp-server/tools/userGetUserById.d.ts.map +1 -0
- package/mcp-server/tools/userGetUserById.js +64 -0
- package/mcp-server/tools/userGetUserById.js.map +1 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts +8 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts.map +1 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.js +94 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.js.map +1 -0
- package/mcp-server/tools/userMagiclink.d.ts +8 -0
- package/mcp-server/tools/userMagiclink.d.ts.map +1 -0
- package/mcp-server/tools/userMagiclink.js +64 -0
- package/mcp-server/tools/userMagiclink.js.map +1 -0
- package/mcp-server/tools/userPassword.d.ts +8 -0
- package/mcp-server/tools/userPassword.d.ts.map +1 -0
- package/mcp-server/tools/userPassword.js +65 -0
- package/mcp-server/tools/userPassword.js.map +1 -0
- package/mcp-server/tools/userPasswordResetRequest.d.ts +8 -0
- package/mcp-server/tools/userPasswordResetRequest.d.ts.map +1 -0
- package/mcp-server/tools/userPasswordResetRequest.js +64 -0
- package/mcp-server/tools/userPasswordResetRequest.js.map +1 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts +8 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts.map +1 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.js +64 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.js.map +1 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.d.ts +8 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.d.ts.map +1 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.js +64 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.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/facility.d.ts +0 -4
- package/models/components/facility.d.ts.map +1 -1
- package/models/components/facility.js +0 -4
- package/models/components/facility.js.map +1 -1
- package/models/components/user.d.ts +6 -0
- package/models/components/user.d.ts.map +1 -1
- package/models/components/user.js +5 -0
- package/models/components/user.js.map +1 -1
- package/models/operations/password.d.ts +2 -2
- package/models/operations/password.d.ts.map +1 -1
- package/models/operations/password.js +2 -2
- package/models/operations/password.js.map +1 -1
- package/package.json +18 -2
- package/src/__tests__/assertions.ts +13 -0
- package/src/__tests__/files.ts +56 -0
- package/src/__tests__/organizations.test.ts +244 -0
- package/src/__tests__/testclient.ts +48 -0
- package/src/__tests__/user.test.ts +200 -0
- package/src/__tests__/vendors.test.ts +65 -0
- package/src/funcs/organizationsGetFacility.ts +1 -1
- package/src/funcs/organizationsListOrSearchFacilities.ts +1 -1
- package/src/funcs/userGetCurrentUser.ts +1 -1
- package/src/funcs/userGetUserById.ts +1 -1
- package/src/funcs/userLogsUserIntoTheSystem.ts +1 -1
- package/src/funcs/userMagiclink.ts +1 -1
- package/src/funcs/userPassword.ts +1 -1
- package/src/funcs/userPasswordResetRequest.ts +1 -1
- package/src/funcs/vendorsCreateVendorRegistration.ts +1 -1
- package/src/funcs/vendorsListVendorJobTitles.ts +1 -1
- package/src/lib/config.ts +9 -6
- package/src/lib/files.ts +1 -1
- package/src/lib/primitives.ts +14 -0
- package/src/mcp-server/cli/start/command.ts +106 -0
- package/src/mcp-server/cli/start/impl.ts +132 -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 +7 -0
- package/src/mcp-server/server.ts +54 -0
- package/src/mcp-server/shared.ts +75 -0
- package/src/mcp-server/tools/organizationsGetFacility.ts +37 -0
- package/src/mcp-server/tools/organizationsListOrSearchFacilities.ts +52 -0
- package/src/mcp-server/tools/userGetCurrentUser.ts +30 -0
- package/src/mcp-server/tools/userGetUserById.ts +37 -0
- package/src/mcp-server/tools/userLogsUserIntoTheSystem.ts +67 -0
- package/src/mcp-server/tools/userMagiclink.ts +37 -0
- package/src/mcp-server/tools/userPassword.ts +38 -0
- package/src/mcp-server/tools/userPasswordResetRequest.ts +37 -0
- package/src/mcp-server/tools/vendorsCreateVendorRegistration.ts +38 -0
- package/src/mcp-server/tools/vendorsListVendorJobTitles.ts +37 -0
- package/src/mcp-server/tools.ts +116 -0
- package/src/models/components/facility.ts +0 -8
- package/src/models/components/user.ts +15 -0
- package/src/models/operations/password.ts +4 -4
- package/src/vitest.config.js +5 -0
- package/vitest.config.d.ts +7 -0
- package/vitest.config.d.ts.map +1 -0
- package/vitest.config.js +8 -0
- package/vitest.config.js.map +1 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { expect, test } from "vitest";
|
|
6
|
+
import { GreenSecurity } from "../index.js";
|
|
7
|
+
import { createTestHTTPClient } from "./testclient.js";
|
|
8
|
+
|
|
9
|
+
test("User Get User By Id", async () => {
|
|
10
|
+
const greenSecurity = new GreenSecurity({
|
|
11
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
12
|
+
security: {
|
|
13
|
+
bearerJwt: "",
|
|
14
|
+
},
|
|
15
|
+
httpClient: createTestHTTPClient("getUserById"),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const result = await greenSecurity.user.getUserById({
|
|
19
|
+
id: 13226,
|
|
20
|
+
});
|
|
21
|
+
expect(result).toBeDefined();
|
|
22
|
+
expect(result).toEqual({
|
|
23
|
+
isGatekeeper: false,
|
|
24
|
+
success: true,
|
|
25
|
+
user: {
|
|
26
|
+
id: 13226,
|
|
27
|
+
firstName: "testFirstName",
|
|
28
|
+
lastName: "testLastName",
|
|
29
|
+
email: "testemail@test.com",
|
|
30
|
+
phone: "112233445566",
|
|
31
|
+
userType: "Vendor",
|
|
32
|
+
timezone: "Eastern Time (US & Canada)",
|
|
33
|
+
imageUrls: {
|
|
34
|
+
tiny: "",
|
|
35
|
+
thumb: "",
|
|
36
|
+
large: "",
|
|
37
|
+
original: "",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
userToken: {
|
|
41
|
+
token: "",
|
|
42
|
+
tokenType: "permanent",
|
|
43
|
+
},
|
|
44
|
+
contact: {
|
|
45
|
+
status: "Deleted",
|
|
46
|
+
department: {
|
|
47
|
+
id: 112233,
|
|
48
|
+
name: "<value>",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("User Get Current User", async () => {
|
|
55
|
+
const greenSecurity = new GreenSecurity({
|
|
56
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
57
|
+
security: {
|
|
58
|
+
bearerJwt: "",
|
|
59
|
+
},
|
|
60
|
+
httpClient: createTestHTTPClient("getCurrentUser"),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const result = await greenSecurity.user.getCurrentUser();
|
|
64
|
+
expect(result).toBeDefined();
|
|
65
|
+
expect(result).toEqual({
|
|
66
|
+
isGatekeeper: false,
|
|
67
|
+
success: true,
|
|
68
|
+
user: {
|
|
69
|
+
id: 123,
|
|
70
|
+
firstName: "John",
|
|
71
|
+
lastName: "Doe",
|
|
72
|
+
email: "john@example.com",
|
|
73
|
+
phone: "5555555555",
|
|
74
|
+
userType: "Facility User",
|
|
75
|
+
timezone: "UTC",
|
|
76
|
+
imageUrls: {
|
|
77
|
+
tiny:
|
|
78
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
79
|
+
thumb:
|
|
80
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
81
|
+
large:
|
|
82
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
83
|
+
original:
|
|
84
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
userToken: {
|
|
88
|
+
token: "WDCINRKRKYQ3TUEUEUEHEGWN6WKXP7N12345C8CSHQVJD7D6I",
|
|
89
|
+
tokenType: "permanent",
|
|
90
|
+
},
|
|
91
|
+
contact: {
|
|
92
|
+
facility: {
|
|
93
|
+
id: 233571,
|
|
94
|
+
name: "<value>",
|
|
95
|
+
},
|
|
96
|
+
system: 141123,
|
|
97
|
+
status: "Deleted",
|
|
98
|
+
department: 123,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("User Logs User Into The System", async () => {
|
|
104
|
+
const greenSecurity = new GreenSecurity({
|
|
105
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
106
|
+
security: {
|
|
107
|
+
bearerJwt: "",
|
|
108
|
+
},
|
|
109
|
+
httpClient: createTestHTTPClient("logsUserIntoTheSystem"),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const result = await greenSecurity.user.logsUserIntoTheSystem({
|
|
113
|
+
email: "user@example.com",
|
|
114
|
+
mfaCode: "123456",
|
|
115
|
+
password: "Hunter2",
|
|
116
|
+
});
|
|
117
|
+
expect(result).toBeDefined();
|
|
118
|
+
expect(result).toEqual({
|
|
119
|
+
isGatekeeper: true,
|
|
120
|
+
success: true,
|
|
121
|
+
user: {
|
|
122
|
+
id: 123,
|
|
123
|
+
firstName: "John",
|
|
124
|
+
lastName: "Doe",
|
|
125
|
+
email: "john@example.com",
|
|
126
|
+
phone: "5555555555",
|
|
127
|
+
userType: "Facility User",
|
|
128
|
+
timezone: "Pacific Time (US & Canada)",
|
|
129
|
+
imageUrls: {
|
|
130
|
+
tiny:
|
|
131
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
132
|
+
thumb:
|
|
133
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
134
|
+
large:
|
|
135
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
136
|
+
original:
|
|
137
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
userToken: {
|
|
141
|
+
token: "WDCINRKRKYQ3TUEUEUEHEGWN6WKXP7N12345C8CSHQVJD7D6I",
|
|
142
|
+
tokenType: "permanent",
|
|
143
|
+
},
|
|
144
|
+
contact: {
|
|
145
|
+
facility: {
|
|
146
|
+
id: 128492,
|
|
147
|
+
name: "<value>",
|
|
148
|
+
},
|
|
149
|
+
system: 851061,
|
|
150
|
+
status: "Inactive",
|
|
151
|
+
department: 123,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("User Magiclink", async () => {
|
|
157
|
+
const greenSecurity = new GreenSecurity({
|
|
158
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
159
|
+
security: {
|
|
160
|
+
bearerJwt: "",
|
|
161
|
+
},
|
|
162
|
+
httpClient: createTestHTTPClient("magiclink"),
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const result = await greenSecurity.user.magiclink({
|
|
166
|
+
email: "Ethel.Schroeder9@yahoo.com",
|
|
167
|
+
});
|
|
168
|
+
expect(result).toBeDefined();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("User Password Reset Request", async () => {
|
|
172
|
+
const greenSecurity = new GreenSecurity({
|
|
173
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
174
|
+
security: {
|
|
175
|
+
bearerJwt: "",
|
|
176
|
+
},
|
|
177
|
+
httpClient: createTestHTTPClient("passwordResetRequest"),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const result = await greenSecurity.user.passwordResetRequest({
|
|
181
|
+
email: "Deon76@yahoo.com",
|
|
182
|
+
});
|
|
183
|
+
expect(result).toBeDefined();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("User Password", async () => {
|
|
187
|
+
const greenSecurity = new GreenSecurity({
|
|
188
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
189
|
+
security: {
|
|
190
|
+
bearerJwt: "",
|
|
191
|
+
},
|
|
192
|
+
httpClient: createTestHTTPClient("password"),
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const result = await greenSecurity.user.password({
|
|
196
|
+
paswordResetToken: "<value>",
|
|
197
|
+
password: "BT_1LEAfXTRpaLs",
|
|
198
|
+
});
|
|
199
|
+
expect(result).toBeDefined();
|
|
200
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { expect, test } from "vitest";
|
|
6
|
+
import { GreenSecurity } from "../index.js";
|
|
7
|
+
import { createTestHTTPClient } from "./testclient.js";
|
|
8
|
+
|
|
9
|
+
test("Vendors Create Vendor Registration", async () => {
|
|
10
|
+
const greenSecurity = new GreenSecurity({
|
|
11
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
12
|
+
security: {
|
|
13
|
+
bearerJwt: "",
|
|
14
|
+
},
|
|
15
|
+
httpClient: createTestHTTPClient("createVendorRegistration"),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const result = await greenSecurity.vendors.createVendorRegistration({
|
|
19
|
+
email: "user@example.com",
|
|
20
|
+
password: "Abcdef123!",
|
|
21
|
+
timezone: "America/Chicago",
|
|
22
|
+
affiliateId: 123,
|
|
23
|
+
vendorGroupId: 123,
|
|
24
|
+
managingCompanyId: 123,
|
|
25
|
+
});
|
|
26
|
+
expect(result).toBeDefined();
|
|
27
|
+
expect(result).toEqual({
|
|
28
|
+
data: {},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("Vendors List Vendor Job Titles", async () => {
|
|
33
|
+
const greenSecurity = new GreenSecurity({
|
|
34
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
35
|
+
security: {
|
|
36
|
+
bearerJwt: "",
|
|
37
|
+
},
|
|
38
|
+
httpClient: createTestHTTPClient("listVendorJobTitles"),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const result = await greenSecurity.vendors.listVendorJobTitles({
|
|
42
|
+
sort: "job",
|
|
43
|
+
desc: true,
|
|
44
|
+
itemsPerPage: 25,
|
|
45
|
+
jobLike: "job",
|
|
46
|
+
});
|
|
47
|
+
expect(result).toBeDefined();
|
|
48
|
+
expect(result).toEqual({
|
|
49
|
+
pager: {
|
|
50
|
+
baseUrl: "api/vendors/job_titles",
|
|
51
|
+
sort: "job,title",
|
|
52
|
+
desc: 1,
|
|
53
|
+
itemCount: 228,
|
|
54
|
+
itemsPerPage: 307858,
|
|
55
|
+
page: 1,
|
|
56
|
+
useUrlParams: true,
|
|
57
|
+
},
|
|
58
|
+
items: [
|
|
59
|
+
{
|
|
60
|
+
id: 191114,
|
|
61
|
+
job: "Account Representatives/Managers|Account Executive",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -125,7 +125,7 @@ async function $do(
|
|
|
125
125
|
path: path,
|
|
126
126
|
headers: headers,
|
|
127
127
|
body: body,
|
|
128
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
128
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
129
129
|
}, options);
|
|
130
130
|
if (!requestRes.ok) {
|
|
131
131
|
return [requestRes, { status: "invalid" }];
|
|
@@ -139,7 +139,7 @@ async function $do(
|
|
|
139
139
|
headers: headers,
|
|
140
140
|
query: query,
|
|
141
141
|
body: body,
|
|
142
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
142
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
143
143
|
}, options);
|
|
144
144
|
if (!requestRes.ok) {
|
|
145
145
|
return [requestRes, { status: "invalid" }];
|
|
@@ -98,7 +98,7 @@ async function $do(
|
|
|
98
98
|
baseURL: options?.serverURL,
|
|
99
99
|
path: path,
|
|
100
100
|
headers: headers,
|
|
101
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
101
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
102
102
|
}, options);
|
|
103
103
|
if (!requestRes.ok) {
|
|
104
104
|
return [requestRes, { status: "invalid" }];
|
|
@@ -123,7 +123,7 @@ async function $do(
|
|
|
123
123
|
path: path,
|
|
124
124
|
headers: headers,
|
|
125
125
|
body: body,
|
|
126
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
126
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
127
127
|
}, options);
|
|
128
128
|
if (!requestRes.ok) {
|
|
129
129
|
return [requestRes, { status: "invalid" }];
|
|
@@ -142,7 +142,7 @@ async function $do(
|
|
|
142
142
|
path: path,
|
|
143
143
|
headers: headers,
|
|
144
144
|
body: body,
|
|
145
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
145
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
146
146
|
}, options);
|
|
147
147
|
if (!requestRes.ok) {
|
|
148
148
|
return [requestRes, { status: "invalid" }];
|
|
@@ -116,7 +116,7 @@ async function $do(
|
|
|
116
116
|
path: path,
|
|
117
117
|
headers: headers,
|
|
118
118
|
body: body,
|
|
119
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
119
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
120
120
|
}, options);
|
|
121
121
|
if (!requestRes.ok) {
|
|
122
122
|
return [requestRes, { status: "invalid" }];
|
|
@@ -117,7 +117,7 @@ async function $do(
|
|
|
117
117
|
path: path,
|
|
118
118
|
headers: headers,
|
|
119
119
|
body: body,
|
|
120
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
120
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
121
121
|
}, options);
|
|
122
122
|
if (!requestRes.ok) {
|
|
123
123
|
return [requestRes, { status: "invalid" }];
|
|
@@ -117,7 +117,7 @@ async function $do(
|
|
|
117
117
|
path: path,
|
|
118
118
|
headers: headers,
|
|
119
119
|
body: body,
|
|
120
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
120
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
121
121
|
}, options);
|
|
122
122
|
if (!requestRes.ok) {
|
|
123
123
|
return [requestRes, { status: "invalid" }];
|
|
@@ -114,7 +114,7 @@ async function $do(
|
|
|
114
114
|
path: path,
|
|
115
115
|
headers: headers,
|
|
116
116
|
body: body,
|
|
117
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
117
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
118
118
|
}, options);
|
|
119
119
|
if (!requestRes.ok) {
|
|
120
120
|
return [requestRes, { status: "invalid" }];
|
|
@@ -122,7 +122,7 @@ async function $do(
|
|
|
122
122
|
headers: headers,
|
|
123
123
|
query: query,
|
|
124
124
|
body: body,
|
|
125
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs ||
|
|
125
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000,
|
|
126
126
|
}, options);
|
|
127
127
|
if (!requestRes.ok) {
|
|
128
128
|
return [requestRes, { status: "invalid" }];
|
package/src/lib/config.ts
CHANGED
|
@@ -30,17 +30,20 @@ export type SDKOptions = {
|
|
|
30
30
|
/**
|
|
31
31
|
* The security details required to authenticate the SDK
|
|
32
32
|
*/
|
|
33
|
-
security?:
|
|
33
|
+
security?:
|
|
34
|
+
| components.Security
|
|
35
|
+
| (() => Promise<components.Security>)
|
|
36
|
+
| undefined;
|
|
34
37
|
|
|
35
38
|
httpClient?: HTTPClient;
|
|
36
39
|
/**
|
|
37
40
|
* Allows overriding the default server used by the SDK
|
|
38
41
|
*/
|
|
39
|
-
serverIdx?: number;
|
|
42
|
+
serverIdx?: number | undefined;
|
|
40
43
|
/**
|
|
41
44
|
* Allows overriding the default server URL used by the SDK
|
|
42
45
|
*/
|
|
43
|
-
serverURL?: string;
|
|
46
|
+
serverURL?: string | undefined;
|
|
44
47
|
/**
|
|
45
48
|
* Allows overriding the default retry config used by the SDK
|
|
46
49
|
*/
|
|
@@ -69,8 +72,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
69
72
|
export const SDK_METADATA = {
|
|
70
73
|
language: "typescript",
|
|
71
74
|
openapiDocVersion: "0.0.3",
|
|
72
|
-
sdkVersion: "0.
|
|
73
|
-
genVersion: "2.
|
|
75
|
+
sdkVersion: "0.12.0",
|
|
76
|
+
genVersion: "2.529.2",
|
|
74
77
|
userAgent:
|
|
75
|
-
"speakeasy-sdk/typescript 0.
|
|
78
|
+
"speakeasy-sdk/typescript 0.12.0 2.529.2 0.0.3 @greensecurity/javascript-sdk",
|
|
76
79
|
} 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
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
"api-token": {
|
|
44
|
+
kind: "parsed",
|
|
45
|
+
brief: "Sets the token auth field for the API",
|
|
46
|
+
optional: true,
|
|
47
|
+
parse: (value) => {
|
|
48
|
+
return z.string().parse(value);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
"bearer-jwt": {
|
|
52
|
+
kind: "parsed",
|
|
53
|
+
brief: "Sets the bearerJwt auth field for the API",
|
|
54
|
+
optional: true,
|
|
55
|
+
parse: (value) => {
|
|
56
|
+
return z.string().parse(value);
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
"server-url": {
|
|
60
|
+
kind: "parsed",
|
|
61
|
+
brief: "Overrides the default server URL used by the SDK",
|
|
62
|
+
optional: true,
|
|
63
|
+
parse: (value) => new URL(value).toString(),
|
|
64
|
+
},
|
|
65
|
+
"server-index": {
|
|
66
|
+
kind: "parsed",
|
|
67
|
+
brief: "Selects a predefined server used by the SDK",
|
|
68
|
+
optional: true,
|
|
69
|
+
parse: numberParser,
|
|
70
|
+
},
|
|
71
|
+
"log-level": {
|
|
72
|
+
kind: "enum",
|
|
73
|
+
brief: "The log level to use for the server",
|
|
74
|
+
default: "info",
|
|
75
|
+
values: consoleLoggerLevels,
|
|
76
|
+
},
|
|
77
|
+
env: {
|
|
78
|
+
kind: "parsed",
|
|
79
|
+
brief: "Environment variables made available to the server",
|
|
80
|
+
optional: true,
|
|
81
|
+
variadic: true,
|
|
82
|
+
parse: (val: string) => {
|
|
83
|
+
const sepIdx = val.indexOf("=");
|
|
84
|
+
if (sepIdx === -1) {
|
|
85
|
+
throw new Error("Invalid environment variable format");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const key = val.slice(0, sepIdx);
|
|
89
|
+
const value = val.slice(sepIdx + 1);
|
|
90
|
+
|
|
91
|
+
return [
|
|
92
|
+
z.string().nonempty({
|
|
93
|
+
message: "Environment variable key must be a non-empty string",
|
|
94
|
+
}).parse(key),
|
|
95
|
+
z.string().nonempty({
|
|
96
|
+
message: "Environment variable value must be a non-empty string",
|
|
97
|
+
}).parse(value),
|
|
98
|
+
] satisfies [string, string];
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
docs: {
|
|
104
|
+
brief: "Run the Model Context Protocol server",
|
|
105
|
+
},
|
|
106
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
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 "api-token"?: string | undefined;
|
|
22
|
+
readonly "bearer-jwt"?: string | undefined;
|
|
23
|
+
readonly "server-url"?: string;
|
|
24
|
+
readonly "server-index"?: SDKOptions["serverIdx"];
|
|
25
|
+
readonly "log-level": ConsoleLoggerLevel;
|
|
26
|
+
readonly env?: [string, string][];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function main(this: LocalContext, flags: StartCommandFlags) {
|
|
30
|
+
flags.env?.forEach(([key, value]) => {
|
|
31
|
+
process.env[key] = value;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
switch (flags.transport) {
|
|
35
|
+
case "stdio":
|
|
36
|
+
await startStdio(flags);
|
|
37
|
+
break;
|
|
38
|
+
case "sse":
|
|
39
|
+
await startSSE(flags);
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
throw new Error(`Invalid transport: ${flags.transport}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function startStdio(flags: StartCommandFlags) {
|
|
47
|
+
const logger = createConsoleLogger(flags["log-level"]);
|
|
48
|
+
const transport = new StdioServerTransport();
|
|
49
|
+
const server = createMCPServer({
|
|
50
|
+
logger,
|
|
51
|
+
scopes: flags.scope,
|
|
52
|
+
security: { token: flags["api-token"], bearerJwt: flags["bearer-jwt"] },
|
|
53
|
+
serverURL: flags["server-url"],
|
|
54
|
+
serverIdx: flags["server-index"],
|
|
55
|
+
});
|
|
56
|
+
await server.connect(transport);
|
|
57
|
+
|
|
58
|
+
const abort = async () => {
|
|
59
|
+
await server.close();
|
|
60
|
+
process.exit(0);
|
|
61
|
+
};
|
|
62
|
+
process.on("SIGTERM", abort);
|
|
63
|
+
process.on("SIGINT", abort);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function startSSE(flags: StartCommandFlags) {
|
|
67
|
+
const logger = createConsoleLogger(flags["log-level"]);
|
|
68
|
+
const app = express();
|
|
69
|
+
const mcpServer = createMCPServer({
|
|
70
|
+
logger,
|
|
71
|
+
scopes: flags.scope,
|
|
72
|
+
security: { token: flags["api-token"], bearerJwt: flags["bearer-jwt"] },
|
|
73
|
+
serverURL: flags["server-url"],
|
|
74
|
+
serverIdx: flags["server-index"],
|
|
75
|
+
});
|
|
76
|
+
let transport: SSEServerTransport | undefined;
|
|
77
|
+
const controller = new AbortController();
|
|
78
|
+
|
|
79
|
+
app.get("/sse", async (_req, res) => {
|
|
80
|
+
transport = new SSEServerTransport("/message", res);
|
|
81
|
+
|
|
82
|
+
await mcpServer.connect(transport);
|
|
83
|
+
|
|
84
|
+
mcpServer.server.onclose = async () => {
|
|
85
|
+
res.end();
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
app.post("/message", async (req, res) => {
|
|
90
|
+
if (!transport) {
|
|
91
|
+
throw new Error("Server transport not initialized");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
await transport.handlePostMessage(req, res);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const httpServer = app.listen(flags.port, "0.0.0.0", () => {
|
|
98
|
+
const ha = httpServer.address();
|
|
99
|
+
const host = typeof ha === "string" ? ha : `${ha?.address}:${ha?.port}`;
|
|
100
|
+
logger.info("MCP HTTP server started", { host });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
let closing = false;
|
|
104
|
+
controller.signal.addEventListener("abort", async () => {
|
|
105
|
+
if (closing) {
|
|
106
|
+
logger.info("Received second signal. Forcing shutdown.");
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
closing = true;
|
|
110
|
+
|
|
111
|
+
logger.info("Shutting down MCP server");
|
|
112
|
+
|
|
113
|
+
await mcpServer.close();
|
|
114
|
+
|
|
115
|
+
logger.info("Shutting down HTTP server");
|
|
116
|
+
|
|
117
|
+
const timer = setTimeout(() => {
|
|
118
|
+
logger.info("Forcing shutdown");
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}, 5000);
|
|
121
|
+
|
|
122
|
+
httpServer.close(() => {
|
|
123
|
+
clearTimeout(timer);
|
|
124
|
+
logger.info("Graceful shutdown complete");
|
|
125
|
+
process.exit(0);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const abort = () => controller.abort();
|
|
130
|
+
process.on("SIGTERM", abort);
|
|
131
|
+
process.on("SIGINT", abort);
|
|
132
|
+
}
|
|
@@ -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
|
+
}
|