cas-parser-node-mcp 1.4.1 → 1.7.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 (227) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +29 -147
  3. package/auth.d.mts +6 -0
  4. package/auth.d.mts.map +1 -0
  5. package/auth.d.ts +6 -0
  6. package/auth.d.ts.map +1 -0
  7. package/auth.js +22 -0
  8. package/auth.js.map +1 -0
  9. package/auth.mjs +17 -0
  10. package/auth.mjs.map +1 -0
  11. package/code-tool-types.d.mts +7 -7
  12. package/code-tool-types.d.mts.map +1 -1
  13. package/code-tool-types.d.ts +7 -7
  14. package/code-tool-types.d.ts.map +1 -1
  15. package/code-tool.d.mts +6 -3
  16. package/code-tool.d.mts.map +1 -1
  17. package/code-tool.d.ts +6 -3
  18. package/code-tool.d.ts.map +1 -1
  19. package/code-tool.js +86 -133
  20. package/code-tool.js.map +1 -1
  21. package/code-tool.mjs +86 -100
  22. package/code-tool.mjs.map +1 -1
  23. package/{tools/cas-generator/generate-cas-cas-generator.d.ts → docs-search-tool.d.mts} +23 -11
  24. package/docs-search-tool.d.mts.map +1 -0
  25. package/{tools/cas-generator/generate-cas-cas-generator.d.mts → docs-search-tool.d.ts} +23 -11
  26. package/docs-search-tool.d.ts.map +1 -0
  27. package/docs-search-tool.js +55 -0
  28. package/docs-search-tool.js.map +1 -0
  29. package/docs-search-tool.mjs +51 -0
  30. package/docs-search-tool.mjs.map +1 -0
  31. package/http.d.mts +9 -4
  32. package/http.d.mts.map +1 -1
  33. package/http.d.ts +9 -4
  34. package/http.d.ts.map +1 -1
  35. package/http.js +35 -48
  36. package/http.js.map +1 -1
  37. package/http.mjs +35 -48
  38. package/http.mjs.map +1 -1
  39. package/index.js +8 -40
  40. package/index.js.map +1 -1
  41. package/index.mjs +8 -40
  42. package/index.mjs.map +1 -1
  43. package/instructions.d.mts +2 -0
  44. package/instructions.d.mts.map +1 -0
  45. package/instructions.d.ts +2 -0
  46. package/instructions.d.ts.map +1 -0
  47. package/instructions.js +55 -0
  48. package/instructions.js.map +1 -0
  49. package/instructions.mjs +52 -0
  50. package/instructions.mjs.map +1 -0
  51. package/methods.d.mts +10 -0
  52. package/methods.d.mts.map +1 -0
  53. package/methods.d.ts +10 -0
  54. package/methods.d.ts.map +1 -0
  55. package/methods.js +167 -0
  56. package/methods.js.map +1 -0
  57. package/methods.mjs +163 -0
  58. package/methods.mjs.map +1 -0
  59. package/options.d.mts +6 -9
  60. package/options.d.mts.map +1 -1
  61. package/options.d.ts +6 -9
  62. package/options.d.ts.map +1 -1
  63. package/options.js +42 -360
  64. package/options.js.map +1 -1
  65. package/options.mjs +42 -360
  66. package/options.mjs.map +1 -1
  67. package/package.json +67 -79
  68. package/server.d.mts +10 -16
  69. package/server.d.mts.map +1 -1
  70. package/server.d.ts +10 -16
  71. package/server.d.ts.map +1 -1
  72. package/server.js +89 -101
  73. package/server.js.map +1 -1
  74. package/server.mjs +88 -96
  75. package/server.mjs.map +1 -1
  76. package/src/auth.ts +25 -0
  77. package/src/code-tool-types.ts +7 -5
  78. package/src/code-tool.ts +113 -117
  79. package/src/docs-search-tool.ts +68 -0
  80. package/src/http.ts +52 -52
  81. package/src/index.ts +9 -52
  82. package/src/instructions.ts +74 -0
  83. package/src/methods.ts +188 -0
  84. package/src/options.ts +55 -382
  85. package/src/server.ts +98 -117
  86. package/src/stdio.ts +4 -4
  87. package/src/{tools/types.ts → types.ts} +25 -5
  88. package/src/util.ts +25 -0
  89. package/stdio.d.mts +1 -1
  90. package/stdio.d.mts.map +1 -1
  91. package/stdio.d.ts +1 -1
  92. package/stdio.d.ts.map +1 -1
  93. package/stdio.js +3 -3
  94. package/stdio.js.map +1 -1
  95. package/stdio.mjs +3 -3
  96. package/stdio.mjs.map +1 -1
  97. package/{tools/types.d.mts → types.d.mts} +10 -2
  98. package/types.d.mts.map +1 -0
  99. package/{tools/types.d.ts → types.d.ts} +10 -2
  100. package/types.d.ts.map +1 -0
  101. package/{tools/types.js → types.js} +12 -0
  102. package/types.js.map +1 -0
  103. package/{tools/types.mjs → types.mjs} +11 -0
  104. package/types.mjs.map +1 -0
  105. package/util.d.mts +4 -0
  106. package/util.d.mts.map +1 -0
  107. package/util.d.ts +4 -0
  108. package/util.d.ts.map +1 -0
  109. package/util.js +30 -0
  110. package/util.js.map +1 -0
  111. package/util.mjs +24 -0
  112. package/util.mjs.map +1 -0
  113. package/code-tool-paths.cjs +0 -6
  114. package/code-tool-paths.cjs.map +0 -1
  115. package/code-tool-paths.d.cts +0 -2
  116. package/code-tool-paths.d.cts.map +0 -1
  117. package/code-tool-worker.d.mts +0 -5
  118. package/code-tool-worker.d.mts.map +0 -1
  119. package/code-tool-worker.d.ts +0 -5
  120. package/code-tool-worker.d.ts.map +0 -1
  121. package/code-tool-worker.js +0 -45
  122. package/code-tool-worker.js.map +0 -1
  123. package/code-tool-worker.mjs +0 -40
  124. package/code-tool-worker.mjs.map +0 -1
  125. package/compat.d.mts +0 -58
  126. package/compat.d.mts.map +0 -1
  127. package/compat.d.ts +0 -58
  128. package/compat.d.ts.map +0 -1
  129. package/compat.js +0 -387
  130. package/compat.js.map +0 -1
  131. package/compat.mjs +0 -378
  132. package/compat.mjs.map +0 -1
  133. package/dynamic-tools.d.mts +0 -12
  134. package/dynamic-tools.d.mts.map +0 -1
  135. package/dynamic-tools.d.ts +0 -12
  136. package/dynamic-tools.d.ts.map +0 -1
  137. package/dynamic-tools.js +0 -135
  138. package/dynamic-tools.js.map +0 -1
  139. package/dynamic-tools.mjs +0 -132
  140. package/dynamic-tools.mjs.map +0 -1
  141. package/filtering.d.mts +0 -2
  142. package/filtering.d.mts.map +0 -1
  143. package/filtering.d.ts +0 -2
  144. package/filtering.d.ts.map +0 -1
  145. package/filtering.js +0 -20
  146. package/filtering.js.map +0 -1
  147. package/filtering.mjs +0 -13
  148. package/filtering.mjs.map +0 -1
  149. package/headers.d.mts +0 -4
  150. package/headers.d.mts.map +0 -1
  151. package/headers.d.ts +0 -4
  152. package/headers.d.ts.map +0 -1
  153. package/headers.js +0 -10
  154. package/headers.js.map +0 -1
  155. package/headers.mjs +0 -6
  156. package/headers.mjs.map +0 -1
  157. package/src/code-tool-paths.cts +0 -3
  158. package/src/code-tool-worker.ts +0 -46
  159. package/src/compat.ts +0 -483
  160. package/src/dynamic-tools.ts +0 -159
  161. package/src/filtering.ts +0 -14
  162. package/src/headers.ts +0 -10
  163. package/src/tools/cas-generator/generate-cas-cas-generator.ts +0 -67
  164. package/src/tools/cas-parser/cams-kfintech-cas-parser.ts +0 -47
  165. package/src/tools/cas-parser/cdsl-cas-parser.ts +0 -47
  166. package/src/tools/cas-parser/nsdl-cas-parser.ts +0 -47
  167. package/src/tools/cas-parser/smart-parse-cas-parser.ts +0 -47
  168. package/src/tools/index.ts +0 -79
  169. package/src/tools.ts +0 -1
  170. package/tools/cas-generator/generate-cas-cas-generator.d.mts.map +0 -1
  171. package/tools/cas-generator/generate-cas-cas-generator.d.ts.map +0 -1
  172. package/tools/cas-generator/generate-cas-cas-generator.js +0 -62
  173. package/tools/cas-generator/generate-cas-cas-generator.js.map +0 -1
  174. package/tools/cas-generator/generate-cas-cas-generator.mjs +0 -58
  175. package/tools/cas-generator/generate-cas-cas-generator.mjs.map +0 -1
  176. package/tools/cas-parser/cams-kfintech-cas-parser.d.mts +0 -45
  177. package/tools/cas-parser/cams-kfintech-cas-parser.d.mts.map +0 -1
  178. package/tools/cas-parser/cams-kfintech-cas-parser.d.ts +0 -45
  179. package/tools/cas-parser/cams-kfintech-cas-parser.d.ts.map +0 -1
  180. package/tools/cas-parser/cams-kfintech-cas-parser.js +0 -43
  181. package/tools/cas-parser/cams-kfintech-cas-parser.js.map +0 -1
  182. package/tools/cas-parser/cams-kfintech-cas-parser.mjs +0 -39
  183. package/tools/cas-parser/cams-kfintech-cas-parser.mjs.map +0 -1
  184. package/tools/cas-parser/cdsl-cas-parser.d.mts +0 -45
  185. package/tools/cas-parser/cdsl-cas-parser.d.mts.map +0 -1
  186. package/tools/cas-parser/cdsl-cas-parser.d.ts +0 -45
  187. package/tools/cas-parser/cdsl-cas-parser.d.ts.map +0 -1
  188. package/tools/cas-parser/cdsl-cas-parser.js +0 -43
  189. package/tools/cas-parser/cdsl-cas-parser.js.map +0 -1
  190. package/tools/cas-parser/cdsl-cas-parser.mjs +0 -39
  191. package/tools/cas-parser/cdsl-cas-parser.mjs.map +0 -1
  192. package/tools/cas-parser/nsdl-cas-parser.d.mts +0 -45
  193. package/tools/cas-parser/nsdl-cas-parser.d.mts.map +0 -1
  194. package/tools/cas-parser/nsdl-cas-parser.d.ts +0 -45
  195. package/tools/cas-parser/nsdl-cas-parser.d.ts.map +0 -1
  196. package/tools/cas-parser/nsdl-cas-parser.js +0 -43
  197. package/tools/cas-parser/nsdl-cas-parser.js.map +0 -1
  198. package/tools/cas-parser/nsdl-cas-parser.mjs +0 -39
  199. package/tools/cas-parser/nsdl-cas-parser.mjs.map +0 -1
  200. package/tools/cas-parser/smart-parse-cas-parser.d.mts +0 -45
  201. package/tools/cas-parser/smart-parse-cas-parser.d.mts.map +0 -1
  202. package/tools/cas-parser/smart-parse-cas-parser.d.ts +0 -45
  203. package/tools/cas-parser/smart-parse-cas-parser.d.ts.map +0 -1
  204. package/tools/cas-parser/smart-parse-cas-parser.js +0 -43
  205. package/tools/cas-parser/smart-parse-cas-parser.js.map +0 -1
  206. package/tools/cas-parser/smart-parse-cas-parser.mjs +0 -39
  207. package/tools/cas-parser/smart-parse-cas-parser.mjs.map +0 -1
  208. package/tools/index.d.mts +0 -10
  209. package/tools/index.d.mts.map +0 -1
  210. package/tools/index.d.ts +0 -10
  211. package/tools/index.d.ts.map +0 -1
  212. package/tools/index.js +0 -63
  213. package/tools/index.js.map +0 -1
  214. package/tools/index.mjs +0 -56
  215. package/tools/index.mjs.map +0 -1
  216. package/tools/types.d.mts.map +0 -1
  217. package/tools/types.d.ts.map +0 -1
  218. package/tools/types.js.map +0 -1
  219. package/tools/types.mjs.map +0 -1
  220. package/tools.d.mts +0 -2
  221. package/tools.d.mts.map +0 -1
  222. package/tools.d.ts +0 -2
  223. package/tools.d.ts.map +0 -1
  224. package/tools.js +0 -18
  225. package/tools.js.map +0 -1
  226. package/tools.mjs +0 -2
  227. package/tools.mjs.map +0 -1
package/src/options.ts CHANGED
@@ -1,139 +1,69 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
1
3
  import qs from 'qs';
2
4
  import yargs from 'yargs';
3
5
  import { hideBin } from 'yargs/helpers';
4
6
  import z from 'zod';
5
- import { endpoints, Filter } from './tools';
6
- import { ClientCapabilities, knownClients, ClientType } from './compat';
7
+ import { readEnv } from './util';
7
8
 
8
9
  export type CLIOptions = McpOptions & {
9
- list: boolean;
10
+ debug: boolean;
10
11
  transport: 'stdio' | 'http';
11
12
  port: number | undefined;
12
13
  socket: string | undefined;
13
14
  };
14
15
 
15
16
  export type McpOptions = {
16
- client?: ClientType | undefined;
17
- includeDynamicTools?: boolean | undefined;
18
- includeAllTools?: boolean | undefined;
19
- includeCodeTools?: boolean | undefined;
20
- filters?: Filter[] | undefined;
21
- capabilities?: Partial<ClientCapabilities> | undefined;
17
+ includeDocsTools?: boolean | undefined;
18
+ stainlessApiKey?: string | undefined;
19
+ codeAllowHttpGets?: boolean | undefined;
20
+ codeAllowedMethods?: string[] | undefined;
21
+ codeBlockedMethods?: string[] | undefined;
22
22
  };
23
23
 
24
- const CAPABILITY_CHOICES = [
25
- 'top-level-unions',
26
- 'valid-json',
27
- 'refs',
28
- 'unions',
29
- 'formats',
30
- 'tool-name-length',
31
- ] as const;
32
-
33
- type Capability = (typeof CAPABILITY_CHOICES)[number];
34
-
35
- function parseCapabilityValue(cap: string): { name: Capability; value?: number } {
36
- if (cap.startsWith('tool-name-length=')) {
37
- const parts = cap.split('=');
38
- if (parts.length === 2) {
39
- const length = parseInt(parts[1]!, 10);
40
- if (!isNaN(length)) {
41
- return { name: 'tool-name-length', value: length };
42
- }
43
- throw new Error(`Invalid tool-name-length value: ${parts[1]}. Expected a number.`);
44
- }
45
- throw new Error(`Invalid format for tool-name-length. Expected tool-name-length=N.`);
46
- }
47
- if (!CAPABILITY_CHOICES.includes(cap as Capability)) {
48
- throw new Error(`Unknown capability: ${cap}. Valid capabilities are: ${CAPABILITY_CHOICES.join(', ')}`);
49
- }
50
- return { name: cap as Capability };
51
- }
52
-
53
24
  export function parseCLIOptions(): CLIOptions {
54
25
  const opts = yargs(hideBin(process.argv))
55
- .option('tools', {
56
- type: 'string',
57
- array: true,
58
- choices: ['dynamic', 'all', 'code'],
59
- description: 'Use dynamic tools or all tools',
60
- })
61
- .option('no-tools', {
62
- type: 'string',
63
- array: true,
64
- choices: ['dynamic', 'all', 'code'],
65
- description: 'Do not use any dynamic or all tools',
66
- })
67
- .option('tool', {
68
- type: 'string',
69
- array: true,
70
- description: 'Include tools matching the specified names',
71
- })
72
- .option('resource', {
73
- type: 'string',
74
- array: true,
75
- description: 'Include tools matching the specified resources',
76
- })
77
- .option('operation', {
78
- type: 'string',
79
- array: true,
80
- choices: ['read', 'write'],
81
- description: 'Include tools matching the specified operations',
82
- })
83
- .option('tag', {
84
- type: 'string',
85
- array: true,
86
- description: 'Include tools with the specified tags',
87
- })
88
- .option('no-tool', {
89
- type: 'string',
90
- array: true,
91
- description: 'Exclude tools matching the specified names',
26
+ .option('code-allow-http-gets', {
27
+ type: 'boolean',
28
+ description:
29
+ 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.',
92
30
  })
93
- .option('no-resource', {
31
+ .option('code-allowed-methods', {
94
32
  type: 'string',
95
33
  array: true,
96
- description: 'Exclude tools matching the specified resources',
34
+ description:
35
+ 'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
97
36
  })
98
- .option('no-operation', {
37
+ .option('code-blocked-methods', {
99
38
  type: 'string',
100
39
  array: true,
101
- description: 'Exclude tools matching the specified operations',
40
+ description:
41
+ 'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.',
102
42
  })
103
- .option('no-tag', {
43
+ .option('debug', { type: 'boolean', description: 'Enable debug logging' })
44
+ .option('no-tools', {
104
45
  type: 'string',
105
46
  array: true,
106
- description: 'Exclude tools with the specified tags',
47
+ choices: ['code', 'docs'],
48
+ description: 'Tools to explicitly disable',
107
49
  })
108
- .option('list', {
109
- type: 'boolean',
110
- description: 'List all tools and exit',
111
- })
112
- .option('client', {
113
- type: 'string',
114
- choices: Object.keys(knownClients),
115
- description: 'Specify the MCP client being used',
50
+ .option('port', {
51
+ type: 'number',
52
+ default: 3000,
53
+ description: 'Port to serve on if using http transport',
116
54
  })
117
- .option('capability', {
55
+ .option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
56
+ .option('stainless-api-key', {
118
57
  type: 'string',
119
- array: true,
120
- description: 'Specify client capabilities',
121
- coerce: (values: string[]) => {
122
- return values.flatMap((v) => v.split(','));
123
- },
58
+ default: readEnv('STAINLESS_API_KEY'),
59
+ description:
60
+ 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
124
61
  })
125
- .option('no-capability', {
62
+ .option('tools', {
126
63
  type: 'string',
127
64
  array: true,
128
- description: 'Unset client capabilities',
129
- choices: CAPABILITY_CHOICES,
130
- coerce: (values: string[]) => {
131
- return values.flatMap((v) => v.split(','));
132
- },
133
- })
134
- .option('describe-capabilities', {
135
- type: 'boolean',
136
- description: 'Print detailed explanation of client capabilities and exit',
65
+ choices: ['code', 'docs'],
66
+ description: 'Tools to explicitly enable',
137
67
  })
138
68
  .option('transport', {
139
69
  type: 'string',
@@ -141,129 +71,28 @@ export function parseCLIOptions(): CLIOptions {
141
71
  default: 'stdio',
142
72
  description: 'What transport to use; stdio for local servers or http for remote servers',
143
73
  })
144
- .option('port', {
145
- type: 'number',
146
- description: 'Port to serve on if using http transport',
147
- })
148
- .option('socket', {
149
- type: 'string',
150
- description: 'Unix socket to serve on if using http transport',
151
- })
74
+ .env('MCP_SERVER')
75
+ .version(true)
152
76
  .help();
153
77
 
154
- for (const [command, desc] of examples()) {
155
- opts.example(command, desc);
156
- }
157
-
158
78
  const argv = opts.parseSync();
159
79
 
160
- // Handle describe-capabilities flag
161
- if (argv.describeCapabilities) {
162
- console.log(getCapabilitiesExplanation());
163
- process.exit(0);
164
- }
165
-
166
- const filters: Filter[] = [];
167
-
168
- // Helper function to support comma-separated values
169
- const splitValues = (values: string[] | undefined): string[] => {
170
- if (!values) return [];
171
- return values.flatMap((v) => v.split(','));
172
- };
173
-
174
- for (const tag of splitValues(argv.tag)) {
175
- filters.push({ type: 'tag', op: 'include', value: tag });
176
- }
177
-
178
- for (const tag of splitValues(argv.noTag)) {
179
- filters.push({ type: 'tag', op: 'exclude', value: tag });
180
- }
181
-
182
- for (const resource of splitValues(argv.resource)) {
183
- filters.push({ type: 'resource', op: 'include', value: resource });
184
- }
185
-
186
- for (const resource of splitValues(argv.noResource)) {
187
- filters.push({ type: 'resource', op: 'exclude', value: resource });
188
- }
80
+ const shouldIncludeToolType = (toolType: 'code' | 'docs') =>
81
+ argv.noTools?.includes(toolType) ? false
82
+ : argv.tools?.includes(toolType) ? true
83
+ : undefined;
189
84
 
190
- for (const tool of splitValues(argv.tool)) {
191
- filters.push({ type: 'tool', op: 'include', value: tool });
192
- }
193
-
194
- for (const tool of splitValues(argv.noTool)) {
195
- filters.push({ type: 'tool', op: 'exclude', value: tool });
196
- }
197
-
198
- for (const operation of splitValues(argv.operation)) {
199
- filters.push({ type: 'operation', op: 'include', value: operation });
200
- }
201
-
202
- for (const operation of splitValues(argv.noOperation)) {
203
- filters.push({ type: 'operation', op: 'exclude', value: operation });
204
- }
205
-
206
- // Parse client capabilities
207
- const clientCapabilities: Partial<ClientCapabilities> = {};
208
-
209
- // Apply individual capability overrides
210
- if (Array.isArray(argv.capability)) {
211
- for (const cap of argv.capability) {
212
- const parsedCap = parseCapabilityValue(cap);
213
- if (parsedCap.name === 'top-level-unions') {
214
- clientCapabilities.topLevelUnions = true;
215
- } else if (parsedCap.name === 'valid-json') {
216
- clientCapabilities.validJson = true;
217
- } else if (parsedCap.name === 'refs') {
218
- clientCapabilities.refs = true;
219
- } else if (parsedCap.name === 'unions') {
220
- clientCapabilities.unions = true;
221
- } else if (parsedCap.name === 'formats') {
222
- clientCapabilities.formats = true;
223
- } else if (parsedCap.name === 'tool-name-length') {
224
- clientCapabilities.toolNameLength = parsedCap.value;
225
- }
226
- }
227
- }
228
-
229
- // Handle no-capability options to unset capabilities
230
- if (Array.isArray(argv.noCapability)) {
231
- for (const cap of argv.noCapability) {
232
- if (cap === 'top-level-unions') {
233
- clientCapabilities.topLevelUnions = false;
234
- } else if (cap === 'valid-json') {
235
- clientCapabilities.validJson = false;
236
- } else if (cap === 'refs') {
237
- clientCapabilities.refs = false;
238
- } else if (cap === 'unions') {
239
- clientCapabilities.unions = false;
240
- } else if (cap === 'formats') {
241
- clientCapabilities.formats = false;
242
- } else if (cap === 'tool-name-length') {
243
- clientCapabilities.toolNameLength = undefined;
244
- }
245
- }
246
- }
247
-
248
- const shouldIncludeToolType = (toolType: 'dynamic' | 'all' | 'code') =>
249
- explicitTools ? argv.tools?.includes(toolType) && !argv.noTools?.includes(toolType) : undefined;
250
-
251
- const explicitTools = Boolean(argv.tools || argv.noTools);
252
- const includeDynamicTools = shouldIncludeToolType('dynamic');
253
- const includeAllTools = shouldIncludeToolType('all');
254
- const includeCodeTools = shouldIncludeToolType('code');
85
+ const includeDocsTools = shouldIncludeToolType('docs');
255
86
 
256
87
  const transport = argv.transport as 'stdio' | 'http';
257
88
 
258
- const client = argv.client as ClientType;
259
89
  return {
260
- client: client && client !== 'infer' && knownClients[client] ? client : undefined,
261
- includeDynamicTools,
262
- includeAllTools,
263
- includeCodeTools,
264
- filters,
265
- capabilities: clientCapabilities,
266
- list: argv.list || false,
90
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
91
+ debug: !!argv.debug,
92
+ stainlessApiKey: argv.stainlessApiKey,
93
+ codeAllowHttpGets: argv.codeAllowHttpGets,
94
+ codeAllowedMethods: argv.codeAllowedMethods,
95
+ codeBlockedMethods: argv.codeBlockedMethods,
267
96
  transport,
268
97
  port: argv.port,
269
98
  socket: argv.socket,
@@ -280,177 +109,21 @@ const coerceArray = <T extends z.ZodTypeAny>(zodType: T) =>
280
109
  );
281
110
 
282
111
  const QueryOptions = z.object({
283
- tools: coerceArray(z.enum(['dynamic', 'all'])).describe('Use dynamic tools or all tools'),
284
- no_tools: coerceArray(z.enum(['dynamic', 'all'])).describe('Do not use dynamic tools or all tools'),
112
+ tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
113
+ no_tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
285
114
  tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
286
- resource: coerceArray(z.string()).describe('Include tools matching the specified resources'),
287
- operation: coerceArray(z.enum(['read', 'write'])).describe(
288
- 'Include tools matching the specified operations',
289
- ),
290
- tag: coerceArray(z.string()).describe('Include tools with the specified tags'),
291
- no_tool: coerceArray(z.string()).describe('Exclude tools matching the specified names'),
292
- no_resource: coerceArray(z.string()).describe('Exclude tools matching the specified resources'),
293
- no_operation: coerceArray(z.enum(['read', 'write'])).describe(
294
- 'Exclude tools matching the specified operations',
295
- ),
296
- no_tag: coerceArray(z.string()).describe('Exclude tools with the specified tags'),
297
- client: ClientType.optional().describe('Specify the MCP client being used'),
298
- capability: coerceArray(z.string()).describe('Specify client capabilities'),
299
- no_capability: coerceArray(z.enum(CAPABILITY_CHOICES)).describe('Unset client capabilities'),
300
115
  });
301
116
 
302
117
  export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions {
303
118
  const queryObject = typeof query === 'string' ? qs.parse(query) : query;
304
119
  const queryOptions = QueryOptions.parse(queryObject);
305
120
 
306
- const filters: Filter[] = [...(defaultOptions.filters ?? [])];
307
-
308
- for (const resource of queryOptions.resource || []) {
309
- filters.push({ type: 'resource', op: 'include', value: resource });
310
- }
311
- for (const operation of queryOptions.operation || []) {
312
- filters.push({ type: 'operation', op: 'include', value: operation });
313
- }
314
- for (const tag of queryOptions.tag || []) {
315
- filters.push({ type: 'tag', op: 'include', value: tag });
316
- }
317
- for (const tool of queryOptions.tool || []) {
318
- filters.push({ type: 'tool', op: 'include', value: tool });
319
- }
320
- for (const resource of queryOptions.no_resource || []) {
321
- filters.push({ type: 'resource', op: 'exclude', value: resource });
322
- }
323
- for (const operation of queryOptions.no_operation || []) {
324
- filters.push({ type: 'operation', op: 'exclude', value: operation });
325
- }
326
- for (const tag of queryOptions.no_tag || []) {
327
- filters.push({ type: 'tag', op: 'exclude', value: tag });
328
- }
329
- for (const tool of queryOptions.no_tool || []) {
330
- filters.push({ type: 'tool', op: 'exclude', value: tool });
331
- }
332
-
333
- // Parse client capabilities
334
- const clientCapabilities: Partial<ClientCapabilities> = { ...defaultOptions.capabilities };
335
-
336
- for (const cap of queryOptions.capability || []) {
337
- const parsed = parseCapabilityValue(cap);
338
- if (parsed.name === 'top-level-unions') {
339
- clientCapabilities.topLevelUnions = true;
340
- } else if (parsed.name === 'valid-json') {
341
- clientCapabilities.validJson = true;
342
- } else if (parsed.name === 'refs') {
343
- clientCapabilities.refs = true;
344
- } else if (parsed.name === 'unions') {
345
- clientCapabilities.unions = true;
346
- } else if (parsed.name === 'formats') {
347
- clientCapabilities.formats = true;
348
- } else if (parsed.name === 'tool-name-length') {
349
- clientCapabilities.toolNameLength = parsed.value;
350
- }
351
- }
352
-
353
- for (const cap of queryOptions.no_capability || []) {
354
- if (cap === 'top-level-unions') {
355
- clientCapabilities.topLevelUnions = false;
356
- } else if (cap === 'valid-json') {
357
- clientCapabilities.validJson = false;
358
- } else if (cap === 'refs') {
359
- clientCapabilities.refs = false;
360
- } else if (cap === 'unions') {
361
- clientCapabilities.unions = false;
362
- } else if (cap === 'formats') {
363
- clientCapabilities.formats = false;
364
- } else if (cap === 'tool-name-length') {
365
- clientCapabilities.toolNameLength = undefined;
366
- }
367
- }
368
-
369
- let dynamicTools: boolean | undefined =
370
- queryOptions.no_tools && queryOptions.no_tools?.includes('dynamic') ? false
371
- : queryOptions.tools?.includes('dynamic') ? true
372
- : defaultOptions.includeDynamicTools;
373
-
374
- let allTools: boolean | undefined =
375
- queryOptions.no_tools && queryOptions.no_tools?.includes('all') ? false
376
- : queryOptions.tools?.includes('all') ? true
377
- : defaultOptions.includeAllTools;
121
+ let docsTools: boolean | undefined =
122
+ queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
123
+ : queryOptions.tools?.includes('docs') ? true
124
+ : defaultOptions.includeDocsTools;
378
125
 
379
126
  return {
380
- client: queryOptions.client ?? defaultOptions.client,
381
- includeDynamicTools: dynamicTools,
382
- includeAllTools: allTools,
383
- includeCodeTools: undefined,
384
- filters,
385
- capabilities: clientCapabilities,
127
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
386
128
  };
387
129
  }
388
-
389
- function getCapabilitiesExplanation(): string {
390
- return `
391
- Client Capabilities Explanation:
392
-
393
- Different Language Models (LLMs) and the MCP clients that use them have varying limitations in how they handle tool schemas. Capability flags allow you to inform the MCP server about these limitations.
394
-
395
- When a capability flag is set to false, the MCP server will automatically adjust the tool schemas to work around that limitation, ensuring broader compatibility.
396
-
397
- Available Capabilities:
398
-
399
- # top-level-unions
400
- Some clients/LLMs do not support JSON schemas with a union type (anyOf) at the root level. If a client lacks this capability, the MCP server splits tools with top-level unions into multiple separate tools, one for each variant in the union.
401
-
402
- # refs
403
- Some clients/LLMs do not support $ref pointers for schema reuse. If a client lacks this capability, the MCP server automatically inlines all references ($defs) directly into the schema. Properties that would cause circular references are removed during this process.
404
-
405
- # valid-json
406
- Some clients/LLMs may incorrectly send arguments as a JSON-encoded string instead of a proper JSON object. If a client *has* this capability, the MCP server will attempt to parse string values as JSON if the initial validation against the schema fails.
407
-
408
- # unions
409
- Some clients/LLMs do not support union types (anyOf) in JSON schemas. If a client lacks this capability, the MCP server removes all anyOf fields and uses only the first variant as the schema.
410
-
411
- # formats
412
- Some clients/LLMs do not support the 'format' keyword in JSON Schema specifications. If a client lacks this capability, the MCP server removes all format fields and appends the format information to the field's description in parentheses.
413
-
414
- # tool-name-length=N
415
- Some clients/LLMs impose a maximum length on tool names. If this capability is set, the MCP server will automatically truncate tool names exceeding the specified length (N), ensuring uniqueness by appending numbers if necessary.
416
-
417
- Client Presets (--client):
418
- Presets like '--client=openai-agents' or '--client=cursor' automatically configure these capabilities based on current known limitations of those clients, simplifying setup.
419
-
420
- Current presets:
421
- ${JSON.stringify(knownClients, null, 2)}
422
- `;
423
- }
424
-
425
- function examples(): [string, string][] {
426
- const firstEndpoint = endpoints[0]!;
427
- const secondEndpoint =
428
- endpoints.find((e) => e.metadata.resource !== firstEndpoint.metadata.resource) || endpoints[1];
429
- const tag = endpoints.find((e) => e.metadata.tags.length > 0)?.metadata.tags[0];
430
- const otherEndpoint = secondEndpoint || firstEndpoint;
431
-
432
- return [
433
- [
434
- `--tool="${firstEndpoint.tool.name}" ${secondEndpoint ? `--tool="${secondEndpoint.tool.name}"` : ''}`,
435
- 'Include tools by name',
436
- ],
437
- [
438
- `--resource="${firstEndpoint.metadata.resource}" --operation="read"`,
439
- 'Filter by resource and operation',
440
- ],
441
- [
442
- `--resource="${otherEndpoint.metadata.resource}*" --no-tool="${otherEndpoint.tool.name}"`,
443
- 'Use resource wildcards and exclusions',
444
- ],
445
- [`--client="cursor"`, 'Adjust schemas to be more compatible with Cursor'],
446
- [
447
- `--capability="top-level-unions" --capability="tool-name-length=40"`,
448
- 'Specify individual client capabilities',
449
- ],
450
- [
451
- `--client="cursor" --no-capability="tool-name-length"`,
452
- 'Use cursor client preset but remove tool name length limit',
453
- ],
454
- ...(tag ? [[`--tag="${tag}"`, 'Filter based on tags'] as [string, string]] : []),
455
- ];
456
- }