ark-email-mcp 0.5.2

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 (94) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +101 -0
  3. package/code-tool-types.d.mts +13 -0
  4. package/code-tool-types.d.mts.map +1 -0
  5. package/code-tool-types.d.ts +13 -0
  6. package/code-tool-types.d.ts.map +1 -0
  7. package/code-tool-types.js +4 -0
  8. package/code-tool-types.js.map +1 -0
  9. package/code-tool-types.mjs +3 -0
  10. package/code-tool-types.mjs.map +1 -0
  11. package/code-tool.d.mts +12 -0
  12. package/code-tool.d.mts.map +1 -0
  13. package/code-tool.d.ts +12 -0
  14. package/code-tool.d.ts.map +1 -0
  15. package/code-tool.js +86 -0
  16. package/code-tool.js.map +1 -0
  17. package/code-tool.mjs +83 -0
  18. package/code-tool.mjs.map +1 -0
  19. package/docs-search-tool.d.mts +50 -0
  20. package/docs-search-tool.d.mts.map +1 -0
  21. package/docs-search-tool.d.ts +50 -0
  22. package/docs-search-tool.d.ts.map +1 -0
  23. package/docs-search-tool.js +51 -0
  24. package/docs-search-tool.js.map +1 -0
  25. package/docs-search-tool.mjs +47 -0
  26. package/docs-search-tool.mjs.map +1 -0
  27. package/headers.d.mts +4 -0
  28. package/headers.d.mts.map +1 -0
  29. package/headers.d.ts +4 -0
  30. package/headers.d.ts.map +1 -0
  31. package/headers.js +22 -0
  32. package/headers.js.map +1 -0
  33. package/headers.mjs +18 -0
  34. package/headers.mjs.map +1 -0
  35. package/http.d.mts +9 -0
  36. package/http.d.mts.map +1 -0
  37. package/http.d.ts +9 -0
  38. package/http.d.ts.map +1 -0
  39. package/http.js +91 -0
  40. package/http.js.map +1 -0
  41. package/http.mjs +83 -0
  42. package/http.mjs.map +1 -0
  43. package/index.d.mts +3 -0
  44. package/index.d.mts.map +1 -0
  45. package/index.d.ts +3 -0
  46. package/index.d.ts.map +1 -0
  47. package/index.js +55 -0
  48. package/index.js.map +1 -0
  49. package/index.mjs +53 -0
  50. package/index.mjs.map +1 -0
  51. package/options.d.mts +11 -0
  52. package/options.d.mts.map +1 -0
  53. package/options.d.ts +11 -0
  54. package/options.d.ts.map +1 -0
  55. package/options.js +72 -0
  56. package/options.js.map +1 -0
  57. package/options.mjs +65 -0
  58. package/options.mjs.map +1 -0
  59. package/package.json +161 -0
  60. package/server.d.mts +30 -0
  61. package/server.d.mts.map +1 -0
  62. package/server.d.ts +30 -0
  63. package/server.d.ts.map +1 -0
  64. package/server.js +121 -0
  65. package/server.js.map +1 -0
  66. package/server.mjs +109 -0
  67. package/server.mjs.map +1 -0
  68. package/src/code-tool-types.ts +15 -0
  69. package/src/code-tool.ts +97 -0
  70. package/src/docs-search-tool.ts +59 -0
  71. package/src/headers.ts +25 -0
  72. package/src/http.ts +109 -0
  73. package/src/index.ts +61 -0
  74. package/src/options.ts +92 -0
  75. package/src/server.ts +147 -0
  76. package/src/stdio.ts +12 -0
  77. package/src/tsconfig.json +11 -0
  78. package/src/types.ts +115 -0
  79. package/stdio.d.mts +2 -0
  80. package/stdio.d.mts.map +1 -0
  81. package/stdio.d.ts +2 -0
  82. package/stdio.d.ts.map +1 -0
  83. package/stdio.js +14 -0
  84. package/stdio.js.map +1 -0
  85. package/stdio.mjs +10 -0
  86. package/stdio.mjs.map +1 -0
  87. package/types.d.mts +52 -0
  88. package/types.d.mts.map +1 -0
  89. package/types.d.ts +52 -0
  90. package/types.d.ts.map +1 -0
  91. package/types.js +58 -0
  92. package/types.js.map +1 -0
  93. package/types.mjs +53 -0
  94. package/types.mjs.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Ark
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # Ark TypeScript MCP Server
2
+
3
+ It is generated with [Stainless](https://www.stainless.com/).
4
+
5
+ ## Installation
6
+
7
+ ### Direct invocation
8
+
9
+ You can run the MCP Server directly via `npx`:
10
+
11
+ ```sh
12
+ export ARK_API_KEY="My API Key"
13
+ npx -y ark-email-mcp@latest
14
+ ```
15
+
16
+ ### Via MCP Client
17
+
18
+ There is a partial list of existing clients at [modelcontextprotocol.io](https://modelcontextprotocol.io/clients). If you already
19
+ have a client, consult their documentation to install the MCP server.
20
+
21
+ For clients with a configuration JSON, it might look something like this:
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "ark_email_api": {
27
+ "command": "npx",
28
+ "args": ["-y", "ark-email-mcp"],
29
+ "env": {
30
+ "ARK_API_KEY": "My API Key"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ ### Cursor
38
+
39
+ If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
40
+ in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
41
+
42
+ [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=ark-email-mcp&config=eyJuYW1lIjoiYXJrLWVtYWlsLW1jcCIsInRyYW5zcG9ydCI6InNzZSIsInVybCI6Imh0dHBzOi8vYXJrLW1jcC5zdGxtY3AuY29tL3NzZSIsImVudiI6eyJBUktfQVBJX0tFWSI6IlNldCB5b3VyIEFSS19BUElfS0VZIGhlcmUuIn19)
43
+
44
+ ### VS Code
45
+
46
+ If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
47
+ in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
48
+
49
+ [Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22ark-email-mcp%22%2C%22type%22%3A%22sse%22%2C%22url%22%3A%22https%3A%2F%2Fark-mcp.stlmcp.com%2Fsse%22%2C%22env%22%3A%7B%22ARK_API_KEY%22%3A%22Set%20your%20ARK_API_KEY%20here.%22%7D%7D)
50
+
51
+ ### Claude Code
52
+
53
+ If you use Claude Code, you can install the MCP server by running the command below in your terminal. You will need to set your
54
+ environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
55
+
56
+ ```
57
+ claude mcp add ark_email_mcp_api --env ARK_API_KEY="Your ARK_API_KEY here." --transport sse https://ark-mcp.stlmcp.com/sse
58
+ ```
59
+
60
+ ## Code Mode
61
+
62
+ This MCP server is built on the "Code Mode" tool scheme. In this MCP Server,
63
+ your agent will write code against the TypeScript SDK, which will then be executed in an
64
+ isolated sandbox. To accomplish this, the server will expose two tools to your agent:
65
+
66
+ - The first tool is a docs search tool, which can be used to generically query for
67
+ documentation about your API/SDK.
68
+
69
+ - The second tool is a code tool, where the agent can write code against the TypeScript SDK.
70
+ The code will be executed in a sandbox environment without web or filesystem access. Then,
71
+ anything the code returns or prints will be returned to the agent as the result of the
72
+ tool call.
73
+
74
+ Using this scheme, agents are capable of performing very complex tasks deterministically
75
+ and repeatably.
76
+
77
+ ## Running remotely
78
+
79
+ Launching the client with `--transport=http` launches the server as a remote server using Streamable HTTP transport. The `--port` setting can choose the port it will run on, and the `--socket` setting allows it to run on a Unix socket.
80
+
81
+ Authorization can be provided via the `Authorization` header using the Bearer scheme.
82
+
83
+ Additionally, authorization can be provided via the following headers:
84
+ | Header | Equivalent client option | Security scheme |
85
+ | --------------- | ------------------------ | --------------- |
86
+ | `x-ark-api-key` | `apiKey` | apiKey |
87
+
88
+ A configuration JSON for this server might look like this, assuming the server is hosted at `http://localhost:3000`:
89
+
90
+ ```json
91
+ {
92
+ "mcpServers": {
93
+ "ark_email_api": {
94
+ "url": "http://localhost:3000",
95
+ "headers": {
96
+ "Authorization": "Bearer <auth value>"
97
+ }
98
+ }
99
+ }
100
+ }
101
+ ```
@@ -0,0 +1,13 @@
1
+ import { ClientOptions } from 'ark-email';
2
+ export type WorkerInput = {
3
+ project_name: string;
4
+ code: string;
5
+ client_opts: ClientOptions;
6
+ };
7
+ export type WorkerOutput = {
8
+ is_error: boolean;
9
+ result: unknown | null;
10
+ log_lines: string[];
11
+ err_lines: string[];
12
+ };
13
+ //# sourceMappingURL=code-tool-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,WAAW;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { ClientOptions } from 'ark-email';
2
+ export type WorkerInput = {
3
+ project_name: string;
4
+ code: string;
5
+ client_opts: ClientOptions;
6
+ };
7
+ export type WorkerOutput = {
8
+ is_error: boolean;
9
+ result: unknown | null;
10
+ log_lines: string[];
11
+ err_lines: string[];
12
+ };
13
+ //# sourceMappingURL=code-tool-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,WAAW;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=code-tool-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.js","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":";AAAA,sFAAsF"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export {};
3
+ //# sourceMappingURL=code-tool-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.mjs","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
@@ -0,0 +1,12 @@
1
+ import { McpTool } from "./types.mjs";
2
+ /**
3
+ * A tool that runs code against a copy of the SDK.
4
+ *
5
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
6
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
+ *
9
+ * @param endpoints - The endpoints to include in the list.
10
+ */
11
+ export declare function codeTool(): McpTool;
12
+ //# sourceMappingURL=code-tool.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AA8BhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAuDlC"}
package/code-tool.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { McpTool } from "./types.js";
2
+ /**
3
+ * A tool that runs code against a copy of the SDK.
4
+ *
5
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
6
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
+ *
9
+ * @param endpoints - The endpoints to include in the list.
10
+ */
11
+ export declare function codeTool(): McpTool;
12
+ //# sourceMappingURL=code-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AA8BhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAuDlC"}
package/code-tool.js ADDED
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.codeTool = codeTool;
5
+ const types_1 = require("./types.js");
6
+ const server_1 = require("./server.js");
7
+ const prompt = `Runs JavaScript code to interact with the Ark API.
8
+
9
+ You are a skilled programmer writing code to interface with the service.
10
+ Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
11
+ For example:
12
+
13
+ \`\`\`
14
+ async function run(client) {
15
+ const response = await client.emails.send({
16
+ from: 'hello@yourdomain.com',
17
+ subject: 'Hello World',
18
+ to: ['user@example.com'],
19
+ html: '<h1>Welcome!</h1>',
20
+ });
21
+
22
+ console.log(response.data);
23
+ }
24
+ \`\`\`
25
+
26
+ You will be returned anything that your function returns, plus the results of any console.log statements.
27
+ Do not add try-catch blocks for single API calls. The tool will handle errors for you.
28
+ Do not add comments unless necessary for generating better code.
29
+ Code will run in a container, and cannot interact with the network outside of the given SDK client.
30
+ Variables will not persist between calls, so make sure to return or log any data you might need later.`;
31
+ /**
32
+ * A tool that runs code against a copy of the SDK.
33
+ *
34
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
35
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
36
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
37
+ *
38
+ * @param endpoints - The endpoints to include in the list.
39
+ */
40
+ function codeTool() {
41
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
42
+ const tool = {
43
+ name: 'execute',
44
+ description: prompt,
45
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
46
+ };
47
+ const handler = async (_, args) => {
48
+ const code = args.code;
49
+ // this is not required, but passing a Stainless API key for the matching project_name
50
+ // will allow you to run code-mode queries against non-published versions of your SDK.
51
+ const stainlessAPIKey = (0, server_1.readEnv)('STAINLESS_API_KEY');
52
+ const codeModeEndpoint = (0, server_1.readEnv)('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
53
+ const res = await fetch(codeModeEndpoint, {
54
+ method: 'POST',
55
+ headers: {
56
+ ...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
57
+ 'Content-Type': 'application/json',
58
+ client_envs: JSON.stringify({
59
+ ARK_API_KEY: (0, server_1.readEnvOrError)('ARK_API_KEY'),
60
+ ARK_BASE_URL: (0, server_1.readEnv)('ARK_BASE_URL'),
61
+ }),
62
+ },
63
+ body: JSON.stringify({
64
+ project_name: 'ark',
65
+ code,
66
+ client_opts: {},
67
+ }),
68
+ });
69
+ if (!res.ok) {
70
+ throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
71
+ }
72
+ const { is_error, result, log_lines, err_lines } = (await res.json());
73
+ const hasLogs = log_lines.length > 0 || err_lines.length > 0;
74
+ const output = {
75
+ result,
76
+ ...(log_lines.length > 0 && { log_lines }),
77
+ ...(err_lines.length > 0 && { err_lines }),
78
+ };
79
+ if (is_error) {
80
+ return (0, types_1.asErrorResult)(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
81
+ }
82
+ return (0, types_1.asTextContentResult)(output);
83
+ };
84
+ return { metadata, tool, handler };
85
+ }
86
+ //# sourceMappingURL=code-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AAyCtF,4BAuDC;AA9FD,sCAAgG;AAEhG,wCAAmD;AAGnD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;uGAuBwF,CAAC;AAExG;;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,KACX,GAAG,CAAC,UACN,4DAA4D,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAC/E,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAiB,CAAC;QACtF,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG;YACb,MAAM;YACN,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;SAC3C,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAA,qBAAa,EAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,IAAA,2BAAmB,EAAC,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
package/code-tool.mjs ADDED
@@ -0,0 +1,83 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { asErrorResult, asTextContentResult } from "./types.mjs";
3
+ import { readEnv, readEnvOrError } from "./server.mjs";
4
+ const prompt = `Runs JavaScript code to interact with the Ark API.
5
+
6
+ You are a skilled programmer writing code to interface with the service.
7
+ Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
8
+ For example:
9
+
10
+ \`\`\`
11
+ async function run(client) {
12
+ const response = await client.emails.send({
13
+ from: 'hello@yourdomain.com',
14
+ subject: 'Hello World',
15
+ to: ['user@example.com'],
16
+ html: '<h1>Welcome!</h1>',
17
+ });
18
+
19
+ console.log(response.data);
20
+ }
21
+ \`\`\`
22
+
23
+ You will be returned anything that your function returns, plus the results of any console.log statements.
24
+ Do not add try-catch blocks for single API calls. The tool will handle errors for you.
25
+ Do not add comments unless necessary for generating better code.
26
+ Code will run in a container, and cannot interact with the network outside of the given SDK client.
27
+ Variables will not persist between calls, so make sure to return or log any data you might need later.`;
28
+ /**
29
+ * A tool that runs code against a copy of the SDK.
30
+ *
31
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
32
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
33
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
34
+ *
35
+ * @param endpoints - The endpoints to include in the list.
36
+ */
37
+ export function codeTool() {
38
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
39
+ const tool = {
40
+ name: 'execute',
41
+ description: prompt,
42
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
43
+ };
44
+ const handler = async (_, args) => {
45
+ const code = args.code;
46
+ // this is not required, but passing a Stainless API key for the matching project_name
47
+ // will allow you to run code-mode queries against non-published versions of your SDK.
48
+ const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
49
+ const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
50
+ const res = await fetch(codeModeEndpoint, {
51
+ method: 'POST',
52
+ headers: {
53
+ ...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
54
+ 'Content-Type': 'application/json',
55
+ client_envs: JSON.stringify({
56
+ ARK_API_KEY: readEnvOrError('ARK_API_KEY'),
57
+ ARK_BASE_URL: readEnv('ARK_BASE_URL'),
58
+ }),
59
+ },
60
+ body: JSON.stringify({
61
+ project_name: 'ark',
62
+ code,
63
+ client_opts: {},
64
+ }),
65
+ });
66
+ if (!res.ok) {
67
+ throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
68
+ }
69
+ const { is_error, result, log_lines, err_lines } = (await res.json());
70
+ const hasLogs = log_lines.length > 0 || err_lines.length > 0;
71
+ const output = {
72
+ result,
73
+ ...(log_lines.length > 0 && { log_lines }),
74
+ ...(err_lines.length > 0 && { err_lines }),
75
+ };
76
+ if (is_error) {
77
+ return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
78
+ }
79
+ return asTextContentResult(output);
80
+ };
81
+ return { metadata, tool, handler };
82
+ }
83
+ //# sourceMappingURL=code-tool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAqC,aAAa,EAAE,mBAAmB,EAAE;OAEzE,EAAE,OAAO,EAAE,cAAc,EAAE;AAGlC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;uGAuBwF,CAAC;AAExG;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,EAAE,CAAU,EAAE,IAAS,EAA2B,EAAE;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAc,CAAC;QAEjC,sFAAsF;QACtF,sFAAsF;QACtF,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACrD,MAAM,gBAAgB,G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AC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { Metadata } from "./types.mjs";
2
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
3
+ export declare const metadata: Metadata;
4
+ export declare const tool: Tool;
5
+ export declare const handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
6
+ declare const _default: {
7
+ metadata: Metadata;
8
+ tool: {
9
+ inputSchema: {
10
+ [x: string]: unknown;
11
+ type: "object";
12
+ properties?: {
13
+ [x: string]: object;
14
+ } | undefined;
15
+ required?: string[] | undefined;
16
+ };
17
+ name: string;
18
+ description?: string | undefined;
19
+ outputSchema?: {
20
+ [x: string]: unknown;
21
+ type: "object";
22
+ properties?: {
23
+ [x: string]: object;
24
+ } | undefined;
25
+ required?: string[] | undefined;
26
+ } | undefined;
27
+ annotations?: {
28
+ title?: string | undefined;
29
+ readOnlyHint?: boolean | undefined;
30
+ destructiveHint?: boolean | undefined;
31
+ idempotentHint?: boolean | undefined;
32
+ openWorldHint?: boolean | undefined;
33
+ } | undefined;
34
+ execution?: {
35
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
36
+ } | undefined;
37
+ _meta?: {
38
+ [x: string]: unknown;
39
+ } | undefined;
40
+ icons?: {
41
+ src: string;
42
+ mimeType?: string | undefined;
43
+ sizes?: string[] | undefined;
44
+ }[] | undefined;
45
+ title?: string | undefined;
46
+ };
47
+ handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
48
+ };
49
+ export default _default;
50
+ //# sourceMappingURL=docs-search-tool.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.d.mts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,8CAYlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAZ+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAcnF,wBAA2C"}