@greensecurity/javascript-sdk 0.9.1 → 0.11.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.
Files changed (223) hide show
  1. package/README.md +81 -16
  2. package/bin/mcp-server.js +39384 -0
  3. package/bin/mcp-server.js.map +301 -0
  4. package/funcs/organizationsGetFacility.d.ts +2 -1
  5. package/funcs/organizationsGetFacility.d.ts.map +1 -1
  6. package/funcs/organizationsGetFacility.js +11 -7
  7. package/funcs/organizationsGetFacility.js.map +1 -1
  8. package/funcs/organizationsListOrSearchFacilities.d.ts +2 -1
  9. package/funcs/organizationsListOrSearchFacilities.d.ts.map +1 -1
  10. package/funcs/organizationsListOrSearchFacilities.js +11 -7
  11. package/funcs/organizationsListOrSearchFacilities.js.map +1 -1
  12. package/funcs/userGetCurrentUser.d.ts +2 -1
  13. package/funcs/userGetCurrentUser.d.ts.map +1 -1
  14. package/funcs/userGetCurrentUser.js +10 -6
  15. package/funcs/userGetCurrentUser.js.map +1 -1
  16. package/funcs/userGetUserById.d.ts +2 -1
  17. package/funcs/userGetUserById.d.ts.map +1 -1
  18. package/funcs/userGetUserById.js +11 -7
  19. package/funcs/userGetUserById.js.map +1 -1
  20. package/funcs/userLogsUserIntoTheSystem.d.ts +2 -1
  21. package/funcs/userLogsUserIntoTheSystem.d.ts.map +1 -1
  22. package/funcs/userLogsUserIntoTheSystem.js +11 -7
  23. package/funcs/userLogsUserIntoTheSystem.js.map +1 -1
  24. package/funcs/userMagiclink.d.ts +17 -0
  25. package/funcs/userMagiclink.d.ts.map +1 -0
  26. package/funcs/userMagiclink.js +115 -0
  27. package/funcs/userMagiclink.js.map +1 -0
  28. package/funcs/userPassword.d.ts +18 -0
  29. package/funcs/userPassword.d.ts.map +1 -0
  30. package/funcs/userPassword.js +116 -0
  31. package/funcs/userPassword.js.map +1 -0
  32. package/funcs/userPasswordResetRequest.d.ts +17 -0
  33. package/funcs/userPasswordResetRequest.d.ts.map +1 -0
  34. package/funcs/userPasswordResetRequest.js +115 -0
  35. package/funcs/userPasswordResetRequest.js.map +1 -0
  36. package/funcs/vendorsCreateVendorRegistration.d.ts +2 -1
  37. package/funcs/vendorsCreateVendorRegistration.d.ts.map +1 -1
  38. package/funcs/vendorsCreateVendorRegistration.js +11 -7
  39. package/funcs/vendorsCreateVendorRegistration.js.map +1 -1
  40. package/funcs/vendorsListVendorJobTitles.d.ts +2 -1
  41. package/funcs/vendorsListVendorJobTitles.d.ts.map +1 -1
  42. package/funcs/vendorsListVendorJobTitles.js +11 -7
  43. package/funcs/vendorsListVendorJobTitles.js.map +1 -1
  44. package/jsr.json +1 -1
  45. package/lib/config.d.ts +5 -5
  46. package/lib/config.d.ts.map +1 -1
  47. package/lib/config.js +3 -3
  48. package/lib/config.js.map +1 -1
  49. package/lib/files.js.map +1 -1
  50. package/lib/sdks.d.ts +1 -1
  51. package/lib/sdks.d.ts.map +1 -1
  52. package/mcp-server/build.d.mts.map +1 -0
  53. package/mcp-server/build.mjs +14 -0
  54. package/mcp-server/build.mjs.map +1 -0
  55. package/mcp-server/cli/start/command.d.ts +2 -0
  56. package/mcp-server/cli/start/command.d.ts.map +1 -0
  57. package/mcp-server/cli/start/command.js +99 -0
  58. package/mcp-server/cli/start/command.js.map +1 -0
  59. package/mcp-server/cli/start/impl.d.ts +15 -0
  60. package/mcp-server/cli/start/impl.d.ts.map +1 -0
  61. package/mcp-server/cli/start/impl.js +97 -0
  62. package/mcp-server/cli/start/impl.js.map +1 -0
  63. package/mcp-server/cli.d.ts +6 -0
  64. package/mcp-server/cli.d.ts.map +1 -0
  65. package/mcp-server/cli.js +10 -0
  66. package/mcp-server/cli.js.map +1 -0
  67. package/mcp-server/console-logger.d.ts +7 -0
  68. package/mcp-server/console-logger.d.ts.map +1 -0
  69. package/mcp-server/console-logger.js +59 -0
  70. package/mcp-server/console-logger.js.map +1 -0
  71. package/mcp-server/mcp-server.d.ts +2 -0
  72. package/mcp-server/mcp-server.d.ts.map +1 -0
  73. package/mcp-server/mcp-server.js +29 -0
  74. package/mcp-server/mcp-server.js.map +1 -0
  75. package/mcp-server/resources.d.ts +27 -0
  76. package/mcp-server/resources.d.ts.map +1 -0
  77. package/mcp-server/resources.js +51 -0
  78. package/mcp-server/resources.js.map +1 -0
  79. package/mcp-server/scopes.d.ts +3 -0
  80. package/mcp-server/scopes.d.ts.map +1 -0
  81. package/mcp-server/scopes.js +8 -0
  82. package/mcp-server/scopes.js.map +1 -0
  83. package/mcp-server/server.d.ts +11 -0
  84. package/mcp-server/server.d.ts.map +1 -0
  85. package/mcp-server/server.js +44 -0
  86. package/mcp-server/server.js.map +1 -0
  87. package/mcp-server/shared.d.ts +7 -0
  88. package/mcp-server/shared.d.ts.map +1 -0
  89. package/mcp-server/shared.js +98 -0
  90. package/mcp-server/shared.js.map +1 -0
  91. package/mcp-server/tools/organizationsGetFacility.d.ts +8 -0
  92. package/mcp-server/tools/organizationsGetFacility.d.ts.map +1 -0
  93. package/mcp-server/tools/organizationsGetFacility.js +64 -0
  94. package/mcp-server/tools/organizationsGetFacility.js.map +1 -0
  95. package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts +8 -0
  96. package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts.map +1 -0
  97. package/mcp-server/tools/organizationsListOrSearchFacilities.js +77 -0
  98. package/mcp-server/tools/organizationsListOrSearchFacilities.js.map +1 -0
  99. package/mcp-server/tools/userGetCurrentUser.d.ts +3 -0
  100. package/mcp-server/tools/userGetCurrentUser.d.ts.map +1 -0
  101. package/mcp-server/tools/userGetCurrentUser.js +26 -0
  102. package/mcp-server/tools/userGetCurrentUser.js.map +1 -0
  103. package/mcp-server/tools/userGetUserById.d.ts +8 -0
  104. package/mcp-server/tools/userGetUserById.d.ts.map +1 -0
  105. package/mcp-server/tools/userGetUserById.js +64 -0
  106. package/mcp-server/tools/userGetUserById.js.map +1 -0
  107. package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts +8 -0
  108. package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts.map +1 -0
  109. package/mcp-server/tools/userLogsUserIntoTheSystem.js +94 -0
  110. package/mcp-server/tools/userLogsUserIntoTheSystem.js.map +1 -0
  111. package/mcp-server/tools/userMagiclink.d.ts +8 -0
  112. package/mcp-server/tools/userMagiclink.d.ts.map +1 -0
  113. package/mcp-server/tools/userMagiclink.js +64 -0
  114. package/mcp-server/tools/userMagiclink.js.map +1 -0
  115. package/mcp-server/tools/userPassword.d.ts +8 -0
  116. package/mcp-server/tools/userPassword.d.ts.map +1 -0
  117. package/mcp-server/tools/userPassword.js +65 -0
  118. package/mcp-server/tools/userPassword.js.map +1 -0
  119. package/mcp-server/tools/userPasswordResetRequest.d.ts +8 -0
  120. package/mcp-server/tools/userPasswordResetRequest.d.ts.map +1 -0
  121. package/mcp-server/tools/userPasswordResetRequest.js +64 -0
  122. package/mcp-server/tools/userPasswordResetRequest.js.map +1 -0
  123. package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts +8 -0
  124. package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts.map +1 -0
  125. package/mcp-server/tools/vendorsCreateVendorRegistration.js +64 -0
  126. package/mcp-server/tools/vendorsCreateVendorRegistration.js.map +1 -0
  127. package/mcp-server/tools/vendorsListVendorJobTitles.d.ts +8 -0
  128. package/mcp-server/tools/vendorsListVendorJobTitles.d.ts.map +1 -0
  129. package/mcp-server/tools/vendorsListVendorJobTitles.js +64 -0
  130. package/mcp-server/tools/vendorsListVendorJobTitles.js.map +1 -0
  131. package/mcp-server/tools.d.ts +25 -0
  132. package/mcp-server/tools.d.ts.map +1 -0
  133. package/mcp-server/tools.js +74 -0
  134. package/mcp-server/tools.js.map +1 -0
  135. package/models/operations/index.d.ts +3 -0
  136. package/models/operations/index.d.ts.map +1 -1
  137. package/models/operations/index.js +3 -0
  138. package/models/operations/index.js.map +1 -1
  139. package/models/operations/magiclink.d.ts +57 -0
  140. package/models/operations/magiclink.d.ts.map +1 -0
  141. package/models/operations/magiclink.js +96 -0
  142. package/models/operations/magiclink.js.map +1 -0
  143. package/models/operations/password.d.ts +59 -0
  144. package/models/operations/password.d.ts.map +1 -0
  145. package/models/operations/password.js +107 -0
  146. package/models/operations/password.js.map +1 -0
  147. package/models/operations/passwordresetrequest.d.ts +57 -0
  148. package/models/operations/passwordresetrequest.d.ts.map +1 -0
  149. package/models/operations/passwordresetrequest.js +96 -0
  150. package/models/operations/passwordresetrequest.js.map +1 -0
  151. package/package.json +14 -2
  152. package/react-query/index.d.ts +3 -0
  153. package/react-query/index.d.ts.map +1 -1
  154. package/react-query/index.js +3 -0
  155. package/react-query/index.js.map +1 -1
  156. package/react-query/userMagiclink.d.ts +23 -0
  157. package/react-query/userMagiclink.d.ts.map +1 -0
  158. package/react-query/userMagiclink.js +47 -0
  159. package/react-query/userMagiclink.js.map +1 -0
  160. package/react-query/userPassword.d.ts +24 -0
  161. package/react-query/userPassword.d.ts.map +1 -0
  162. package/react-query/userPassword.js +48 -0
  163. package/react-query/userPassword.js.map +1 -0
  164. package/react-query/userPasswordResetRequest.d.ts +23 -0
  165. package/react-query/userPasswordResetRequest.d.ts.map +1 -0
  166. package/react-query/userPasswordResetRequest.js +47 -0
  167. package/react-query/userPasswordResetRequest.js.map +1 -0
  168. package/sdk/user.d.ts +22 -0
  169. package/sdk/user.d.ts.map +1 -1
  170. package/sdk/user.js +31 -0
  171. package/sdk/user.js.map +1 -1
  172. package/src/funcs/organizationsGetFacility.ts +37 -8
  173. package/src/funcs/organizationsListOrSearchFacilities.ts +35 -8
  174. package/src/funcs/userGetCurrentUser.ts +33 -7
  175. package/src/funcs/userGetUserById.ts +36 -8
  176. package/src/funcs/userLogsUserIntoTheSystem.ts +36 -8
  177. package/src/funcs/userMagiclink.ts +162 -0
  178. package/src/funcs/userPassword.ts +163 -0
  179. package/src/funcs/userPasswordResetRequest.ts +163 -0
  180. package/src/funcs/vendorsCreateVendorRegistration.ts +36 -8
  181. package/src/funcs/vendorsListVendorJobTitles.ts +37 -8
  182. package/src/lib/config.ts +5 -5
  183. package/src/lib/files.ts +1 -1
  184. package/src/lib/sdks.ts +1 -1
  185. package/src/mcp-server/cli/start/command.ts +67 -0
  186. package/src/mcp-server/cli/start/impl.ts +123 -0
  187. package/src/mcp-server/cli.ts +13 -0
  188. package/src/mcp-server/console-logger.ts +71 -0
  189. package/src/mcp-server/mcp-server.ts +26 -0
  190. package/src/mcp-server/resources.ts +96 -0
  191. package/src/mcp-server/scopes.ts +7 -0
  192. package/src/mcp-server/server.ts +52 -0
  193. package/src/mcp-server/shared.ts +75 -0
  194. package/src/mcp-server/tools/organizationsGetFacility.ts +37 -0
  195. package/src/mcp-server/tools/organizationsListOrSearchFacilities.ts +52 -0
  196. package/src/mcp-server/tools/userGetCurrentUser.ts +30 -0
  197. package/src/mcp-server/tools/userGetUserById.ts +37 -0
  198. package/src/mcp-server/tools/userLogsUserIntoTheSystem.ts +67 -0
  199. package/src/mcp-server/tools/userMagiclink.ts +37 -0
  200. package/src/mcp-server/tools/userPassword.ts +38 -0
  201. package/src/mcp-server/tools/userPasswordResetRequest.ts +37 -0
  202. package/src/mcp-server/tools/vendorsCreateVendorRegistration.ts +38 -0
  203. package/src/mcp-server/tools/vendorsListVendorJobTitles.ts +37 -0
  204. package/src/mcp-server/tools.ts +116 -0
  205. package/src/models/operations/index.ts +3 -0
  206. package/src/models/operations/magiclink.ts +127 -0
  207. package/src/models/operations/password.ts +140 -0
  208. package/src/models/operations/passwordresetrequest.ts +131 -0
  209. package/src/react-query/index.ts +3 -0
  210. package/src/react-query/userMagiclink.ts +88 -0
  211. package/src/react-query/userPassword.ts +89 -0
  212. package/src/react-query/userPasswordResetRequest.ts +89 -0
  213. package/src/sdk/user.ts +55 -0
  214. package/src/types/async.ts +68 -0
  215. package/types/async.d.ts +23 -0
  216. package/types/async.d.ts.map +1 -0
  217. package/types/async.js +44 -0
  218. package/types/async.js.map +1 -0
  219. package/.devcontainer/README.md +0 -35
  220. package/docs/sdks/greensecurity/README.md +0 -14
  221. package/docs/sdks/organizations/README.md +0 -252
  222. package/docs/sdks/user/README.md +0 -348
  223. package/docs/sdks/vendors/README.md +0 -219
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { organizationsGetFacility } from "../../funcs/organizationsGetFacility.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.GetFacilityRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$organizationsGetFacility: ToolDefinition<typeof args> = {
14
+ name: "organizations_get-facility",
15
+ description: `Get facility
16
+
17
+ Retrieve an individual facility.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await organizationsGetFacility(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { organizationsListOrSearchFacilities } from "../../funcs/organizationsListOrSearchFacilities.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.ListOrSearchFacilitiesRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$organizationsListOrSearchFacilities: ToolDefinition<
14
+ typeof args
15
+ > = {
16
+ name: "organizations_list-or-search-facilities",
17
+ description: `List or search facilities
18
+
19
+ List or search facilities.
20
+
21
+ Available \`expand\` scopes are:
22
+
23
+ - facility.appointment_policy
24
+ - facility.contacts
25
+ - facility.vendor_counts
26
+ - facility.flu_credential
27
+ - facility.scrubs_policy
28
+ - facility.system
29
+ - facility.vendor_guest_policy
30
+ - facility.vendor_policy
31
+ - facility.visitor_policy
32
+ - facility.workflow`,
33
+ args,
34
+ tool: async (client, args, ctx) => {
35
+ const [result, apiCall] = await organizationsListOrSearchFacilities(
36
+ client,
37
+ args.request,
38
+ { fetchOptions: { signal: ctx.signal } },
39
+ ).$inspect();
40
+
41
+ if (!result.ok) {
42
+ return {
43
+ content: [{ type: "text", text: result.error.message }],
44
+ isError: true,
45
+ };
46
+ }
47
+
48
+ const value = result.value;
49
+
50
+ return formatResult(value, apiCall);
51
+ },
52
+ };
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userGetCurrentUser } from "../../funcs/userGetCurrentUser.js";
6
+ import { formatResult, ToolDefinition } from "../tools.js";
7
+
8
+ export const tool$userGetCurrentUser: ToolDefinition = {
9
+ name: "user_get-current-user",
10
+ description: `Get current user
11
+
12
+ Returns a user object for the user represented by the authorization token`,
13
+ tool: async (client, ctx) => {
14
+ const [result, apiCall] = await userGetCurrentUser(
15
+ client,
16
+ { fetchOptions: { signal: ctx.signal } },
17
+ ).$inspect();
18
+
19
+ if (!result.ok) {
20
+ return {
21
+ content: [{ type: "text", text: result.error.message }],
22
+ isError: true,
23
+ };
24
+ }
25
+
26
+ const value = result.value;
27
+
28
+ return formatResult(value, apiCall);
29
+ },
30
+ };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userGetUserById } from "../../funcs/userGetUserById.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.GetUserByIdRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$userGetUserById: ToolDefinition<typeof args> = {
14
+ name: "user_get-user-by-id",
15
+ description: `Get user by id
16
+
17
+ Returns a user object for the user represented by the identifier in the path.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await userGetUserById(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userLogsUserIntoTheSystem } from "../../funcs/userLogsUserIntoTheSystem.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.LogsUserIntoTheSystemRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userLogsUserIntoTheSystem: ToolDefinition<typeof args> = {
14
+ name: "user_logs-user-into-the-system",
15
+ description: `Logs user into the system
16
+
17
+ This endpoint allows a user to authenticate themselves and retrieve a permanent token for access.
18
+
19
+ Permanent tokens should only ever be stored in an encrypted storage because they represent a fully logged in user.
20
+
21
+ Users may log in with \`email/password\`, \`SAML\`, \`magic link\` or \`mfa\`. The application should handle all of the above as equally valid login methods.
22
+
23
+ The most common way to authenticate a user is to log in with an email and password. If the user provides valid credentials, the server will either respond with a full user object including the token.
24
+
25
+ When the user's account is protected via MFA, the server will send a 6 digit code to the user via their default MFA provider. You should collect that code and resend the email, password and mfa_code together to get a successful authentication.
26
+
27
+ The ideal flow for a login sequence is the following:
28
+
29
+ 1. Present an email address field only and allow the user to submit
30
+ 2. Send \`email\` and \`return_url\` payload to this endpoint
31
+ 3. Follow the flow based on the response \`requires\` field
32
+
33
+ Requires: \`password\`
34
+
35
+ 1. Show a password field for the user to fill out
36
+ 2. Submit the \`email\` and \`password\` to this endpoint
37
+ 3. If the response is \`200\`, the login is done. If the response is \`201\`, then check if \`requires: mfa_code\` is returned and show MFA flow
38
+ 4. Submit \`email\`, \`password\`, \`mfa_code\` to this endpoint
39
+ 5. If the response is \`200\`, the login is done. Otherwise, show the appropriate error to the user and go back to step 1 or 3 depending on the error.
40
+
41
+ Requires: \`saml_login\`
42
+
43
+ 1. [Open a browser](https://docs.expo.dev/versions/latest/sdk/webbrowser/#webbrowseropenauthsessionasyncurl-redirecturl-options) to the url returned in \`sso_url\`
44
+ 2. User completes sign-in using their configured SAML IdP
45
+ 3. Site redirects to your selected \`return_url\`
46
+ 4. The \`user_token\` will be appended as a query string parameter to your \`return_url\` - you must parse this token and store it
47
+ 5. Fetch the user object from \`/users/me\` using the token`,
48
+ args,
49
+ tool: async (client, args, ctx) => {
50
+ const [result, apiCall] = await userLogsUserIntoTheSystem(
51
+ client,
52
+ args.request,
53
+ { fetchOptions: { signal: ctx.signal } },
54
+ ).$inspect();
55
+
56
+ if (!result.ok) {
57
+ return {
58
+ content: [{ type: "text", text: result.error.message }],
59
+ isError: true,
60
+ };
61
+ }
62
+
63
+ const value = result.value;
64
+
65
+ return formatResult(value, apiCall);
66
+ },
67
+ };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userMagiclink } from "../../funcs/userMagiclink.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.MagiclinkRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userMagiclink: ToolDefinition<typeof args> = {
14
+ name: "user_magiclink",
15
+ description: `Magic link
16
+
17
+ It sends an email with a magic link to allow the user to log in.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await userMagiclink(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userPassword } from "../../funcs/userPassword.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.PasswordRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userPassword: ToolDefinition<typeof args> = {
14
+ name: "user_password",
15
+ description: `Password reset
16
+
17
+ Resets the a user's password using a password_reset_id that was sent to them via email.
18
+ See /users/passwordresetrequest to initiate a password reset flow.`,
19
+ args,
20
+ tool: async (client, args, ctx) => {
21
+ const [result, apiCall] = await userPassword(
22
+ client,
23
+ args.request,
24
+ { fetchOptions: { signal: ctx.signal } },
25
+ ).$inspect();
26
+
27
+ if (!result.ok) {
28
+ return {
29
+ content: [{ type: "text", text: result.error.message }],
30
+ isError: true,
31
+ };
32
+ }
33
+
34
+ const value = result.value;
35
+
36
+ return formatResult(value, apiCall);
37
+ },
38
+ };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userPasswordResetRequest } from "../../funcs/userPasswordResetRequest.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.PasswordResetRequestRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userPasswordResetRequest: ToolDefinition<typeof args> = {
14
+ name: "user_password-reset-request",
15
+ description: `Password reset request
16
+
17
+ It sends an email with a link for resetting a user's password.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await userPasswordResetRequest(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { vendorsCreateVendorRegistration } from "../../funcs/vendorsCreateVendorRegistration.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.CreateVendorRegistrationRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$vendorsCreateVendorRegistration: ToolDefinition<typeof args> =
14
+ {
15
+ name: "vendors_create-vendor-registration",
16
+ description: `Create vendor registration
17
+
18
+ Create an initial vendor registration. Once successful, the vendor will be able to continue to filling out the rest of their onboarding profile.`,
19
+ args,
20
+ tool: async (client, args, ctx) => {
21
+ const [result, apiCall] = await vendorsCreateVendorRegistration(
22
+ client,
23
+ args.request,
24
+ { fetchOptions: { signal: ctx.signal } },
25
+ ).$inspect();
26
+
27
+ if (!result.ok) {
28
+ return {
29
+ content: [{ type: "text", text: result.error.message }],
30
+ isError: true,
31
+ };
32
+ }
33
+
34
+ const value = result.value;
35
+
36
+ return formatResult(value, apiCall);
37
+ },
38
+ };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { vendorsListVendorJobTitles } from "../../funcs/vendorsListVendorJobTitles.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.ListVendorJobTitlesRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$vendorsListVendorJobTitles: ToolDefinition<typeof args> = {
14
+ name: "vendors_list-vendor-job-titles",
15
+ description: `List vendor job titles
16
+
17
+ List valid job titles for Vendors. This can be used during sign up or in a filter.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await vendorsListVendorJobTitles(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
7
+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
8
+ import { objectOutputType, ZodRawShape, ZodTypeAny } from "zod";
9
+ import { GreenSecurityCore } from "../core.js";
10
+ import { ConsoleLogger } from "./console-logger.js";
11
+ import { MCPScope } from "./scopes.js";
12
+ import { isAsyncIterable, isBinaryData, valueToBase64 } from "./shared.js";
13
+
14
+ export type ToolDefinition<Args extends undefined | ZodRawShape = undefined> =
15
+ Args extends ZodRawShape ? {
16
+ name: string;
17
+ description: string;
18
+ scopes?: MCPScope[];
19
+ args: Args;
20
+ tool: (
21
+ client: GreenSecurityCore,
22
+ args: objectOutputType<Args, ZodTypeAny>,
23
+ extra: RequestHandlerExtra,
24
+ ) => CallToolResult | Promise<CallToolResult>;
25
+ }
26
+ : {
27
+ name: string;
28
+ description: string;
29
+ scopes?: MCPScope[];
30
+ args?: undefined;
31
+ tool: (
32
+ client: GreenSecurityCore,
33
+ extra: RequestHandlerExtra,
34
+ ) => CallToolResult | Promise<CallToolResult>;
35
+ };
36
+
37
+ export async function formatResult(
38
+ value: unknown,
39
+ init: { response?: Response | undefined },
40
+ ): Promise<CallToolResult> {
41
+ if (typeof value === "undefined") {
42
+ return { content: [] };
43
+ }
44
+
45
+ const { response } = init;
46
+ const contentType = response?.headers.get("content-type") ?? "";
47
+ let content: CallToolResult["content"] = [];
48
+
49
+ if (contentType.search(/\bjson\b/g)) {
50
+ content = [{ type: "text", text: JSON.stringify(value) }];
51
+ } else if (
52
+ contentType.startsWith("text/event-stream")
53
+ && isAsyncIterable(value)
54
+ ) {
55
+ content = await consumeSSE(value);
56
+ } else if (contentType.startsWith("text/") && typeof value === "string") {
57
+ content = [{ type: "text", text: value }];
58
+ } else if (isBinaryData(value) && contentType.startsWith("image/")) {
59
+ const data = await valueToBase64(value);
60
+ content = data == null
61
+ ? []
62
+ : [{ type: "image", data, mimeType: contentType }];
63
+ } else {
64
+ return {
65
+ content: [{
66
+ type: "text",
67
+ text: `Unsupported content type: "${contentType}"`,
68
+ }],
69
+ isError: true,
70
+ };
71
+ }
72
+
73
+ return { content };
74
+ }
75
+
76
+ async function consumeSSE(
77
+ value: AsyncIterable<unknown>,
78
+ ): Promise<CallToolResult["content"]> {
79
+ const content: CallToolResult["content"] = [];
80
+
81
+ for await (const chunk of value) {
82
+ if (typeof chunk === "string") {
83
+ content.push({ type: "text", text: chunk });
84
+ } else {
85
+ content.push({ type: "text", text: JSON.stringify(chunk) });
86
+ }
87
+ }
88
+
89
+ return content;
90
+ }
91
+
92
+ export function createRegisterTool(
93
+ logger: ConsoleLogger,
94
+ server: McpServer,
95
+ sdk: GreenSecurityCore,
96
+ allowedScopes: Set<MCPScope>,
97
+ ): <A extends ZodRawShape | undefined>(tool: ToolDefinition<A>) => void {
98
+ return <A extends ZodRawShape | undefined>(tool: ToolDefinition<A>): void => {
99
+ const toolScopes = tool.scopes ?? [];
100
+ if (!toolScopes.every((s) => allowedScopes.has(s))) {
101
+ return;
102
+ }
103
+
104
+ if (tool.args) {
105
+ server.tool(tool.name, tool.description, tool.args, async (args, ctx) => {
106
+ return tool.tool(sdk, args, ctx);
107
+ });
108
+ } else {
109
+ server.tool(tool.name, tool.description, async (ctx) => {
110
+ return tool.tool(sdk, ctx);
111
+ });
112
+ }
113
+
114
+ logger.debug("Registered tool", { name: tool.name });
115
+ };
116
+ }
@@ -8,3 +8,6 @@ export * from "./getuserbyid.js";
8
8
  export * from "./listorsearchfacilities.js";
9
9
  export * from "./listvendorjobtitles.js";
10
10
  export * from "./logsuserintothesystem.js";
11
+ export * from "./magiclink.js";
12
+ export * from "./password.js";
13
+ export * from "./passwordresetrequest.js";
@@ -0,0 +1,127 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../../types/fp.js";
8
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+
10
+ export type MagiclinkRequestBody = {
11
+ email: string;
12
+ };
13
+
14
+ /**
15
+ * The request was successful, and the server has returned the requested resource in the response body.
16
+ */
17
+ export type MagiclinkResponseBody = {
18
+ success: boolean;
19
+ };
20
+
21
+ /** @internal */
22
+ export const MagiclinkRequestBody$inboundSchema: z.ZodType<
23
+ MagiclinkRequestBody,
24
+ z.ZodTypeDef,
25
+ unknown
26
+ > = z.object({
27
+ email: z.string(),
28
+ });
29
+
30
+ /** @internal */
31
+ export type MagiclinkRequestBody$Outbound = {
32
+ email: string;
33
+ };
34
+
35
+ /** @internal */
36
+ export const MagiclinkRequestBody$outboundSchema: z.ZodType<
37
+ MagiclinkRequestBody$Outbound,
38
+ z.ZodTypeDef,
39
+ MagiclinkRequestBody
40
+ > = z.object({
41
+ email: z.string(),
42
+ });
43
+
44
+ /**
45
+ * @internal
46
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
47
+ */
48
+ export namespace MagiclinkRequestBody$ {
49
+ /** @deprecated use `MagiclinkRequestBody$inboundSchema` instead. */
50
+ export const inboundSchema = MagiclinkRequestBody$inboundSchema;
51
+ /** @deprecated use `MagiclinkRequestBody$outboundSchema` instead. */
52
+ export const outboundSchema = MagiclinkRequestBody$outboundSchema;
53
+ /** @deprecated use `MagiclinkRequestBody$Outbound` instead. */
54
+ export type Outbound = MagiclinkRequestBody$Outbound;
55
+ }
56
+
57
+ export function magiclinkRequestBodyToJSON(
58
+ magiclinkRequestBody: MagiclinkRequestBody,
59
+ ): string {
60
+ return JSON.stringify(
61
+ MagiclinkRequestBody$outboundSchema.parse(magiclinkRequestBody),
62
+ );
63
+ }
64
+
65
+ export function magiclinkRequestBodyFromJSON(
66
+ jsonString: string,
67
+ ): SafeParseResult<MagiclinkRequestBody, SDKValidationError> {
68
+ return safeParse(
69
+ jsonString,
70
+ (x) => MagiclinkRequestBody$inboundSchema.parse(JSON.parse(x)),
71
+ `Failed to parse 'MagiclinkRequestBody' from JSON`,
72
+ );
73
+ }
74
+
75
+ /** @internal */
76
+ export const MagiclinkResponseBody$inboundSchema: z.ZodType<
77
+ MagiclinkResponseBody,
78
+ z.ZodTypeDef,
79
+ unknown
80
+ > = z.object({
81
+ success: z.boolean(),
82
+ });
83
+
84
+ /** @internal */
85
+ export type MagiclinkResponseBody$Outbound = {
86
+ success: boolean;
87
+ };
88
+
89
+ /** @internal */
90
+ export const MagiclinkResponseBody$outboundSchema: z.ZodType<
91
+ MagiclinkResponseBody$Outbound,
92
+ z.ZodTypeDef,
93
+ MagiclinkResponseBody
94
+ > = z.object({
95
+ success: z.boolean(),
96
+ });
97
+
98
+ /**
99
+ * @internal
100
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
101
+ */
102
+ export namespace MagiclinkResponseBody$ {
103
+ /** @deprecated use `MagiclinkResponseBody$inboundSchema` instead. */
104
+ export const inboundSchema = MagiclinkResponseBody$inboundSchema;
105
+ /** @deprecated use `MagiclinkResponseBody$outboundSchema` instead. */
106
+ export const outboundSchema = MagiclinkResponseBody$outboundSchema;
107
+ /** @deprecated use `MagiclinkResponseBody$Outbound` instead. */
108
+ export type Outbound = MagiclinkResponseBody$Outbound;
109
+ }
110
+
111
+ export function magiclinkResponseBodyToJSON(
112
+ magiclinkResponseBody: MagiclinkResponseBody,
113
+ ): string {
114
+ return JSON.stringify(
115
+ MagiclinkResponseBody$outboundSchema.parse(magiclinkResponseBody),
116
+ );
117
+ }
118
+
119
+ export function magiclinkResponseBodyFromJSON(
120
+ jsonString: string,
121
+ ): SafeParseResult<MagiclinkResponseBody, SDKValidationError> {
122
+ return safeParse(
123
+ jsonString,
124
+ (x) => MagiclinkResponseBody$inboundSchema.parse(JSON.parse(x)),
125
+ `Failed to parse 'MagiclinkResponseBody' from JSON`,
126
+ );
127
+ }