profound-mcp 0.14.0 → 0.17.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 (272) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +14 -184
  3. package/code-tool-types.d.mts +6 -9
  4. package/code-tool-types.d.mts.map +1 -1
  5. package/code-tool-types.d.ts +6 -9
  6. package/code-tool-types.d.ts.map +1 -1
  7. package/code-tool.d.mts +2 -2
  8. package/code-tool.d.mts.map +1 -1
  9. package/code-tool.d.ts +2 -2
  10. package/code-tool.d.ts.map +1 -1
  11. package/code-tool.js +53 -145
  12. package/code-tool.js.map +1 -1
  13. package/code-tool.mjs +53 -112
  14. package/code-tool.mjs.map +1 -1
  15. package/docs-search-tool.d.mts +15 -9
  16. package/docs-search-tool.d.mts.map +1 -1
  17. package/docs-search-tool.d.ts +15 -9
  18. package/docs-search-tool.d.ts.map +1 -1
  19. package/docs-search-tool.js +4 -1
  20. package/docs-search-tool.js.map +1 -1
  21. package/docs-search-tool.mjs +4 -1
  22. package/docs-search-tool.mjs.map +1 -1
  23. package/http.d.mts.map +1 -1
  24. package/http.d.ts.map +1 -1
  25. package/http.js +1 -18
  26. package/http.js.map +1 -1
  27. package/http.mjs +1 -18
  28. package/http.mjs.map +1 -1
  29. package/index.js +4 -40
  30. package/index.js.map +1 -1
  31. package/index.mjs +4 -40
  32. package/index.mjs.map +1 -1
  33. package/options.d.mts +0 -9
  34. package/options.d.mts.map +1 -1
  35. package/options.d.ts +0 -9
  36. package/options.d.ts.map +1 -1
  37. package/options.js +6 -361
  38. package/options.js.map +1 -1
  39. package/options.mjs +6 -361
  40. package/options.mjs.map +1 -1
  41. package/package.json +10 -66
  42. package/server.d.mts +3 -8
  43. package/server.d.mts.map +1 -1
  44. package/server.d.ts +3 -8
  45. package/server.d.ts.map +1 -1
  46. package/server.js +12 -65
  47. package/server.js.map +1 -1
  48. package/server.mjs +11 -62
  49. package/server.mjs.map +1 -1
  50. package/src/code-tool-types.ts +6 -9
  51. package/src/code-tool.ts +60 -138
  52. package/src/docs-search-tool.ts +8 -1
  53. package/src/http.ts +1 -19
  54. package/src/index.ts +5 -52
  55. package/src/options.ts +7 -388
  56. package/src/server.ts +12 -72
  57. package/src/stdio.ts +2 -3
  58. package/src/{tools/types.ts → types.ts} +1 -1
  59. package/stdio.d.mts +1 -2
  60. package/stdio.d.mts.map +1 -1
  61. package/stdio.d.ts +1 -2
  62. package/stdio.d.ts.map +1 -1
  63. package/stdio.js +2 -2
  64. package/stdio.js.map +1 -1
  65. package/stdio.mjs +2 -2
  66. package/stdio.mjs.map +1 -1
  67. package/{tools/types.d.mts → types.d.mts} +1 -1
  68. package/types.d.mts.map +1 -0
  69. package/{tools/types.d.ts → types.d.ts} +1 -1
  70. package/types.d.ts.map +1 -0
  71. package/types.js.map +1 -0
  72. package/types.mjs.map +1 -0
  73. package/code-tool-paths.cjs +0 -6
  74. package/code-tool-paths.cjs.map +0 -1
  75. package/code-tool-paths.d.cts +0 -2
  76. package/code-tool-paths.d.cts.map +0 -1
  77. package/code-tool-worker.d.mts +0 -5
  78. package/code-tool-worker.d.mts.map +0 -1
  79. package/code-tool-worker.d.ts +0 -5
  80. package/code-tool-worker.d.ts.map +0 -1
  81. package/code-tool-worker.js +0 -169
  82. package/code-tool-worker.js.map +0 -1
  83. package/code-tool-worker.mjs +0 -164
  84. package/code-tool-worker.mjs.map +0 -1
  85. package/compat.d.mts +0 -58
  86. package/compat.d.mts.map +0 -1
  87. package/compat.d.ts +0 -58
  88. package/compat.d.ts.map +0 -1
  89. package/compat.js +0 -387
  90. package/compat.js.map +0 -1
  91. package/compat.mjs +0 -378
  92. package/compat.mjs.map +0 -1
  93. package/dynamic-tools.d.mts +0 -12
  94. package/dynamic-tools.d.mts.map +0 -1
  95. package/dynamic-tools.d.ts +0 -12
  96. package/dynamic-tools.d.ts.map +0 -1
  97. package/dynamic-tools.js +0 -135
  98. package/dynamic-tools.js.map +0 -1
  99. package/dynamic-tools.mjs +0 -132
  100. package/dynamic-tools.mjs.map +0 -1
  101. package/filtering.d.mts +0 -3
  102. package/filtering.d.mts.map +0 -1
  103. package/filtering.d.ts +0 -3
  104. package/filtering.d.ts.map +0 -1
  105. package/filtering.js +0 -24
  106. package/filtering.js.map +0 -1
  107. package/filtering.mjs +0 -16
  108. package/filtering.mjs.map +0 -1
  109. package/src/code-tool-paths.cts +0 -3
  110. package/src/code-tool-worker.ts +0 -215
  111. package/src/compat.ts +0 -483
  112. package/src/dynamic-tools.ts +0 -153
  113. package/src/filtering.ts +0 -18
  114. package/src/tools/index.ts +0 -99
  115. package/src/tools/logs/raw/bots-logs-raw.ts +0 -544
  116. package/src/tools/logs/raw/logs-logs-raw.ts +0 -565
  117. package/src/tools/organizations/categories/assets-organizations-categories.ts +0 -57
  118. package/src/tools/organizations/categories/list-organizations-categories.ts +0 -51
  119. package/src/tools/organizations/categories/prompts-organizations-categories.ts +0 -57
  120. package/src/tools/organizations/categories/tags-organizations-categories.ts +0 -57
  121. package/src/tools/organizations/categories/topics-organizations-categories.ts +0 -57
  122. package/src/tools/organizations/domains-organizations.ts +0 -51
  123. package/src/tools/organizations/list-assets-organizations.ts +0 -51
  124. package/src/tools/organizations/models-organizations.ts +0 -51
  125. package/src/tools/organizations/regions-organizations.ts +0 -51
  126. package/src/tools/prompts/answers-prompts.ts +0 -370
  127. package/src/tools/reports/citations-reports.ts +0 -504
  128. package/src/tools/reports/sentiment-reports.ts +0 -418
  129. package/src/tools/reports/visibility-reports.ts +0 -364
  130. package/src/tools.ts +0 -1
  131. package/tools/index.d.mts +0 -10
  132. package/tools/index.d.mts.map +0 -1
  133. package/tools/index.d.ts +0 -10
  134. package/tools/index.d.ts.map +0 -1
  135. package/tools/index.js +0 -83
  136. package/tools/index.js.map +0 -1
  137. package/tools/index.mjs +0 -76
  138. package/tools/index.mjs.map +0 -1
  139. package/tools/logs/raw/bots-logs-raw.d.mts +0 -45
  140. package/tools/logs/raw/bots-logs-raw.d.mts.map +0 -1
  141. package/tools/logs/raw/bots-logs-raw.d.ts +0 -45
  142. package/tools/logs/raw/bots-logs-raw.d.ts.map +0 -1
  143. package/tools/logs/raw/bots-logs-raw.js +0 -544
  144. package/tools/logs/raw/bots-logs-raw.js.map +0 -1
  145. package/tools/logs/raw/bots-logs-raw.mjs +0 -537
  146. package/tools/logs/raw/bots-logs-raw.mjs.map +0 -1
  147. package/tools/logs/raw/logs-logs-raw.d.mts +0 -45
  148. package/tools/logs/raw/logs-logs-raw.d.mts.map +0 -1
  149. package/tools/logs/raw/logs-logs-raw.d.ts +0 -45
  150. package/tools/logs/raw/logs-logs-raw.d.ts.map +0 -1
  151. package/tools/logs/raw/logs-logs-raw.js +0 -565
  152. package/tools/logs/raw/logs-logs-raw.js.map +0 -1
  153. package/tools/logs/raw/logs-logs-raw.mjs +0 -558
  154. package/tools/logs/raw/logs-logs-raw.mjs.map +0 -1
  155. package/tools/organizations/categories/assets-organizations-categories.d.mts +0 -45
  156. package/tools/organizations/categories/assets-organizations-categories.d.mts.map +0 -1
  157. package/tools/organizations/categories/assets-organizations-categories.d.ts +0 -45
  158. package/tools/organizations/categories/assets-organizations-categories.d.ts.map +0 -1
  159. package/tools/organizations/categories/assets-organizations-categories.js +0 -55
  160. package/tools/organizations/categories/assets-organizations-categories.js.map +0 -1
  161. package/tools/organizations/categories/assets-organizations-categories.mjs +0 -48
  162. package/tools/organizations/categories/assets-organizations-categories.mjs.map +0 -1
  163. package/tools/organizations/categories/list-organizations-categories.d.mts +0 -45
  164. package/tools/organizations/categories/list-organizations-categories.d.mts.map +0 -1
  165. package/tools/organizations/categories/list-organizations-categories.d.ts +0 -45
  166. package/tools/organizations/categories/list-organizations-categories.d.ts.map +0 -1
  167. package/tools/organizations/categories/list-organizations-categories.js +0 -51
  168. package/tools/organizations/categories/list-organizations-categories.js.map +0 -1
  169. package/tools/organizations/categories/list-organizations-categories.mjs +0 -44
  170. package/tools/organizations/categories/list-organizations-categories.mjs.map +0 -1
  171. package/tools/organizations/categories/prompts-organizations-categories.d.mts +0 -45
  172. package/tools/organizations/categories/prompts-organizations-categories.d.mts.map +0 -1
  173. package/tools/organizations/categories/prompts-organizations-categories.d.ts +0 -45
  174. package/tools/organizations/categories/prompts-organizations-categories.d.ts.map +0 -1
  175. package/tools/organizations/categories/prompts-organizations-categories.js +0 -55
  176. package/tools/organizations/categories/prompts-organizations-categories.js.map +0 -1
  177. package/tools/organizations/categories/prompts-organizations-categories.mjs +0 -48
  178. package/tools/organizations/categories/prompts-organizations-categories.mjs.map +0 -1
  179. package/tools/organizations/categories/tags-organizations-categories.d.mts +0 -45
  180. package/tools/organizations/categories/tags-organizations-categories.d.mts.map +0 -1
  181. package/tools/organizations/categories/tags-organizations-categories.d.ts +0 -45
  182. package/tools/organizations/categories/tags-organizations-categories.d.ts.map +0 -1
  183. package/tools/organizations/categories/tags-organizations-categories.js +0 -55
  184. package/tools/organizations/categories/tags-organizations-categories.js.map +0 -1
  185. package/tools/organizations/categories/tags-organizations-categories.mjs +0 -48
  186. package/tools/organizations/categories/tags-organizations-categories.mjs.map +0 -1
  187. package/tools/organizations/categories/topics-organizations-categories.d.mts +0 -45
  188. package/tools/organizations/categories/topics-organizations-categories.d.mts.map +0 -1
  189. package/tools/organizations/categories/topics-organizations-categories.d.ts +0 -45
  190. package/tools/organizations/categories/topics-organizations-categories.d.ts.map +0 -1
  191. package/tools/organizations/categories/topics-organizations-categories.js +0 -55
  192. package/tools/organizations/categories/topics-organizations-categories.js.map +0 -1
  193. package/tools/organizations/categories/topics-organizations-categories.mjs +0 -48
  194. package/tools/organizations/categories/topics-organizations-categories.mjs.map +0 -1
  195. package/tools/organizations/domains-organizations.d.mts +0 -45
  196. package/tools/organizations/domains-organizations.d.mts.map +0 -1
  197. package/tools/organizations/domains-organizations.d.ts +0 -45
  198. package/tools/organizations/domains-organizations.d.ts.map +0 -1
  199. package/tools/organizations/domains-organizations.js +0 -51
  200. package/tools/organizations/domains-organizations.js.map +0 -1
  201. package/tools/organizations/domains-organizations.mjs +0 -44
  202. package/tools/organizations/domains-organizations.mjs.map +0 -1
  203. package/tools/organizations/list-assets-organizations.d.mts +0 -45
  204. package/tools/organizations/list-assets-organizations.d.mts.map +0 -1
  205. package/tools/organizations/list-assets-organizations.d.ts +0 -45
  206. package/tools/organizations/list-assets-organizations.d.ts.map +0 -1
  207. package/tools/organizations/list-assets-organizations.js +0 -51
  208. package/tools/organizations/list-assets-organizations.js.map +0 -1
  209. package/tools/organizations/list-assets-organizations.mjs +0 -44
  210. package/tools/organizations/list-assets-organizations.mjs.map +0 -1
  211. package/tools/organizations/models-organizations.d.mts +0 -45
  212. package/tools/organizations/models-organizations.d.mts.map +0 -1
  213. package/tools/organizations/models-organizations.d.ts +0 -45
  214. package/tools/organizations/models-organizations.d.ts.map +0 -1
  215. package/tools/organizations/models-organizations.js +0 -51
  216. package/tools/organizations/models-organizations.js.map +0 -1
  217. package/tools/organizations/models-organizations.mjs +0 -44
  218. package/tools/organizations/models-organizations.mjs.map +0 -1
  219. package/tools/organizations/regions-organizations.d.mts +0 -45
  220. package/tools/organizations/regions-organizations.d.mts.map +0 -1
  221. package/tools/organizations/regions-organizations.d.ts +0 -45
  222. package/tools/organizations/regions-organizations.d.ts.map +0 -1
  223. package/tools/organizations/regions-organizations.js +0 -51
  224. package/tools/organizations/regions-organizations.js.map +0 -1
  225. package/tools/organizations/regions-organizations.mjs +0 -44
  226. package/tools/organizations/regions-organizations.mjs.map +0 -1
  227. package/tools/prompts/answers-prompts.d.mts +0 -45
  228. package/tools/prompts/answers-prompts.d.mts.map +0 -1
  229. package/tools/prompts/answers-prompts.d.ts +0 -45
  230. package/tools/prompts/answers-prompts.d.ts.map +0 -1
  231. package/tools/prompts/answers-prompts.js +0 -372
  232. package/tools/prompts/answers-prompts.js.map +0 -1
  233. package/tools/prompts/answers-prompts.mjs +0 -365
  234. package/tools/prompts/answers-prompts.mjs.map +0 -1
  235. package/tools/reports/citations-reports.d.mts +0 -45
  236. package/tools/reports/citations-reports.d.mts.map +0 -1
  237. package/tools/reports/citations-reports.d.ts +0 -45
  238. package/tools/reports/citations-reports.d.ts.map +0 -1
  239. package/tools/reports/citations-reports.js +0 -503
  240. package/tools/reports/citations-reports.js.map +0 -1
  241. package/tools/reports/citations-reports.mjs +0 -496
  242. package/tools/reports/citations-reports.mjs.map +0 -1
  243. package/tools/reports/sentiment-reports.d.mts +0 -45
  244. package/tools/reports/sentiment-reports.d.mts.map +0 -1
  245. package/tools/reports/sentiment-reports.d.ts +0 -45
  246. package/tools/reports/sentiment-reports.d.ts.map +0 -1
  247. package/tools/reports/sentiment-reports.js +0 -417
  248. package/tools/reports/sentiment-reports.js.map +0 -1
  249. package/tools/reports/sentiment-reports.mjs +0 -410
  250. package/tools/reports/sentiment-reports.mjs.map +0 -1
  251. package/tools/reports/visibility-reports.d.mts +0 -45
  252. package/tools/reports/visibility-reports.d.mts.map +0 -1
  253. package/tools/reports/visibility-reports.d.ts +0 -45
  254. package/tools/reports/visibility-reports.d.ts.map +0 -1
  255. package/tools/reports/visibility-reports.js +0 -363
  256. package/tools/reports/visibility-reports.js.map +0 -1
  257. package/tools/reports/visibility-reports.mjs +0 -356
  258. package/tools/reports/visibility-reports.mjs.map +0 -1
  259. package/tools/types.d.mts.map +0 -1
  260. package/tools/types.d.ts.map +0 -1
  261. package/tools/types.js.map +0 -1
  262. package/tools/types.mjs.map +0 -1
  263. package/tools.d.mts +0 -2
  264. package/tools.d.mts.map +0 -1
  265. package/tools.d.ts +0 -2
  266. package/tools.d.ts.map +0 -1
  267. package/tools.js +0 -18
  268. package/tools.js.map +0 -1
  269. package/tools.mjs +0 -2
  270. package/tools.mjs.map +0 -1
  271. /package/{tools/types.js → types.js} +0 -0
  272. /package/{tools/types.mjs → types.mjs} +0 -0
package/src/index.ts CHANGED
@@ -1,20 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { selectTools } from './server';
4
- import { Endpoint, endpoints } from './tools';
5
4
  import { McpOptions, parseCLIOptions } from './options';
6
5
  import { launchStdioServer } from './stdio';
7
6
  import { launchStreamableHTTPServer } from './http';
7
+ import type { McpTool } from './types';
8
8
 
9
9
  async function main() {
10
10
  const options = parseOptionsOrError();
11
11
 
12
- if (options.list) {
13
- listAllTools();
14
- return;
15
- }
16
-
17
- const selectedTools = await selectToolsOrError(endpoints, options);
12
+ const selectedTools = await selectToolsOrError(options);
18
13
 
19
14
  console.error(
20
15
  `MCP Server starting with ${selectedTools.length} tools:`,
@@ -23,7 +18,7 @@ async function main() {
23
18
 
24
19
  switch (options.transport) {
25
20
  case 'stdio':
26
- await launchStdioServer(options);
21
+ await launchStdioServer();
27
22
  break;
28
23
  case 'http':
29
24
  await launchStreamableHTTPServer(options, options.port ?? options.socket);
@@ -47,9 +42,9 @@ function parseOptionsOrError() {
47
42
  }
48
43
  }
49
44
 
50
- async function selectToolsOrError(endpoints: Endpoint[], options: McpOptions): Promise<Endpoint[]> {
45
+ async function selectToolsOrError(options: McpOptions): Promise<McpTool[]> {
51
46
  try {
52
- const includedTools = await selectTools(endpoints, options);
47
+ const includedTools = selectTools(options);
53
48
  if (includedTools.length === 0) {
54
49
  console.error('No tools match the provided filters.');
55
50
  process.exit(1);
@@ -64,45 +59,3 @@ async function selectToolsOrError(endpoints: Endpoint[], options: McpOptions): P
64
59
  process.exit(1);
65
60
  }
66
61
  }
67
-
68
- function listAllTools() {
69
- if (endpoints.length === 0) {
70
- console.log('No tools available.');
71
- return;
72
- }
73
- console.log('Available tools:\n');
74
-
75
- // Group endpoints by resource
76
- const resourceGroups = new Map<string, typeof endpoints>();
77
-
78
- for (const endpoint of endpoints) {
79
- const resource = endpoint.metadata.resource;
80
- if (!resourceGroups.has(resource)) {
81
- resourceGroups.set(resource, []);
82
- }
83
- resourceGroups.get(resource)!.push(endpoint);
84
- }
85
-
86
- // Sort resources alphabetically
87
- const sortedResources = Array.from(resourceGroups.keys()).sort();
88
-
89
- // Display hierarchically by resource
90
- for (const resource of sortedResources) {
91
- console.log(`Resource: ${resource}`);
92
-
93
- const resourceEndpoints = resourceGroups.get(resource)!;
94
- // Sort endpoints by tool name
95
- resourceEndpoints.sort((a, b) => a.tool.name.localeCompare(b.tool.name));
96
-
97
- for (const endpoint of resourceEndpoints) {
98
- const {
99
- tool,
100
- metadata: { operation, tags },
101
- } = endpoint;
102
-
103
- console.log(` - ${tool.name} (${operation}) ${tags.length > 0 ? `tags: ${tags.join(', ')}` : ''}`);
104
- console.log(` Description: ${tool.description}`);
105
- }
106
- console.log('');
107
- }
108
- }
package/src/options.ts CHANGED
@@ -2,140 +2,31 @@ import qs from 'qs';
2
2
  import yargs from 'yargs';
3
3
  import { hideBin } from 'yargs/helpers';
4
4
  import z from 'zod';
5
- import { endpoints, Filter } from './tools';
6
- import { ClientCapabilities, knownClients, ClientType } from './compat';
7
5
 
8
6
  export type CLIOptions = McpOptions & {
9
- list: boolean;
10
7
  transport: 'stdio' | 'http';
11
8
  port: number | undefined;
12
9
  socket: string | undefined;
13
10
  };
14
11
 
15
12
  export type McpOptions = {
16
- client?: ClientType | undefined;
17
- includeDynamicTools?: boolean | undefined;
18
- includeAllTools?: boolean | undefined;
19
- includeCodeTools?: boolean | undefined;
20
13
  includeDocsTools?: boolean | undefined;
21
- filters?: Filter[] | undefined;
22
- capabilities?: Partial<ClientCapabilities> | undefined;
23
14
  };
24
15
 
25
- const CAPABILITY_CHOICES = [
26
- 'top-level-unions',
27
- 'valid-json',
28
- 'refs',
29
- 'unions',
30
- 'formats',
31
- 'tool-name-length',
32
- ] as const;
33
-
34
- type Capability = (typeof CAPABILITY_CHOICES)[number];
35
-
36
- function parseCapabilityValue(cap: string): { name: Capability; value?: number } {
37
- if (cap.startsWith('tool-name-length=')) {
38
- const parts = cap.split('=');
39
- if (parts.length === 2) {
40
- const length = parseInt(parts[1]!, 10);
41
- if (!isNaN(length)) {
42
- return { name: 'tool-name-length', value: length };
43
- }
44
- throw new Error(`Invalid tool-name-length value: ${parts[1]}. Expected a number.`);
45
- }
46
- throw new Error(`Invalid format for tool-name-length. Expected tool-name-length=N.`);
47
- }
48
- if (!CAPABILITY_CHOICES.includes(cap as Capability)) {
49
- throw new Error(`Unknown capability: ${cap}. Valid capabilities are: ${CAPABILITY_CHOICES.join(', ')}`);
50
- }
51
- return { name: cap as Capability };
52
- }
53
-
54
16
  export function parseCLIOptions(): CLIOptions {
55
17
  const opts = yargs(hideBin(process.argv))
56
18
  .option('tools', {
57
19
  type: 'string',
58
20
  array: true,
59
- choices: ['dynamic', 'all', 'code', 'docs'],
21
+ choices: ['code', 'docs'],
60
22
  description: 'Use dynamic tools or all tools',
61
23
  })
62
24
  .option('no-tools', {
63
25
  type: 'string',
64
26
  array: true,
65
- choices: ['dynamic', 'all', 'code', 'docs'],
27
+ choices: ['code', 'docs'],
66
28
  description: 'Do not use any dynamic or all tools',
67
29
  })
68
- .option('tool', {
69
- type: 'string',
70
- array: true,
71
- description: 'Include tools matching the specified names',
72
- })
73
- .option('resource', {
74
- type: 'string',
75
- array: true,
76
- description: 'Include tools matching the specified resources',
77
- })
78
- .option('operation', {
79
- type: 'string',
80
- array: true,
81
- choices: ['read', 'write'],
82
- description: 'Include tools matching the specified operations',
83
- })
84
- .option('tag', {
85
- type: 'string',
86
- array: true,
87
- description: 'Include tools with the specified tags',
88
- })
89
- .option('no-tool', {
90
- type: 'string',
91
- array: true,
92
- description: 'Exclude tools matching the specified names',
93
- })
94
- .option('no-resource', {
95
- type: 'string',
96
- array: true,
97
- description: 'Exclude tools matching the specified resources',
98
- })
99
- .option('no-operation', {
100
- type: 'string',
101
- array: true,
102
- description: 'Exclude tools matching the specified operations',
103
- })
104
- .option('no-tag', {
105
- type: 'string',
106
- array: true,
107
- description: 'Exclude tools with the specified tags',
108
- })
109
- .option('list', {
110
- type: 'boolean',
111
- description: 'List all tools and exit',
112
- })
113
- .option('client', {
114
- type: 'string',
115
- choices: Object.keys(knownClients),
116
- description: 'Specify the MCP client being used',
117
- })
118
- .option('capability', {
119
- type: 'string',
120
- array: true,
121
- description: 'Specify client capabilities',
122
- coerce: (values: string[]) => {
123
- return values.flatMap((v) => v.split(','));
124
- },
125
- })
126
- .option('no-capability', {
127
- type: 'string',
128
- array: true,
129
- description: 'Unset client capabilities',
130
- choices: CAPABILITY_CHOICES,
131
- coerce: (values: string[]) => {
132
- return values.flatMap((v) => v.split(','));
133
- },
134
- })
135
- .option('describe-capabilities', {
136
- type: 'boolean',
137
- description: 'Print detailed explanation of client capabilities and exit',
138
- })
139
30
  .option('transport', {
140
31
  type: 'string',
141
32
  choices: ['stdio', 'http'],
@@ -152,122 +43,19 @@ export function parseCLIOptions(): CLIOptions {
152
43
  })
153
44
  .help();
154
45
 
155
- for (const [command, desc] of examples()) {
156
- opts.example(command, desc);
157
- }
158
-
159
46
  const argv = opts.parseSync();
160
47
 
161
- // Handle describe-capabilities flag
162
- if (argv.describeCapabilities) {
163
- console.log(getCapabilitiesExplanation());
164
- process.exit(0);
165
- }
166
-
167
- const filters: Filter[] = [];
168
-
169
- // Helper function to support comma-separated values
170
- const splitValues = (values: string[] | undefined): string[] => {
171
- if (!values) return [];
172
- return values.flatMap((v) => v.split(','));
173
- };
174
-
175
- for (const tag of splitValues(argv.tag)) {
176
- filters.push({ type: 'tag', op: 'include', value: tag });
177
- }
178
-
179
- for (const tag of splitValues(argv.noTag)) {
180
- filters.push({ type: 'tag', op: 'exclude', value: tag });
181
- }
182
-
183
- for (const resource of splitValues(argv.resource)) {
184
- filters.push({ type: 'resource', op: 'include', value: resource });
185
- }
186
-
187
- for (const resource of splitValues(argv.noResource)) {
188
- filters.push({ type: 'resource', op: 'exclude', value: resource });
189
- }
190
-
191
- for (const tool of splitValues(argv.tool)) {
192
- filters.push({ type: 'tool', op: 'include', value: tool });
193
- }
194
-
195
- for (const tool of splitValues(argv.noTool)) {
196
- filters.push({ type: 'tool', op: 'exclude', value: tool });
197
- }
198
-
199
- for (const operation of splitValues(argv.operation)) {
200
- filters.push({ type: 'operation', op: 'include', value: operation });
201
- }
202
-
203
- for (const operation of splitValues(argv.noOperation)) {
204
- filters.push({ type: 'operation', op: 'exclude', value: operation });
205
- }
206
-
207
- // Parse client capabilities
208
- const clientCapabilities: Partial<ClientCapabilities> = {};
209
-
210
- // Apply individual capability overrides
211
- if (Array.isArray(argv.capability)) {
212
- for (const cap of argv.capability) {
213
- const parsedCap = parseCapabilityValue(cap);
214
- if (parsedCap.name === 'top-level-unions') {
215
- clientCapabilities.topLevelUnions = true;
216
- } else if (parsedCap.name === 'valid-json') {
217
- clientCapabilities.validJson = true;
218
- } else if (parsedCap.name === 'refs') {
219
- clientCapabilities.refs = true;
220
- } else if (parsedCap.name === 'unions') {
221
- clientCapabilities.unions = true;
222
- } else if (parsedCap.name === 'formats') {
223
- clientCapabilities.formats = true;
224
- } else if (parsedCap.name === 'tool-name-length') {
225
- clientCapabilities.toolNameLength = parsedCap.value;
226
- }
227
- }
228
- }
229
-
230
- // Handle no-capability options to unset capabilities
231
- if (Array.isArray(argv.noCapability)) {
232
- for (const cap of argv.noCapability) {
233
- if (cap === 'top-level-unions') {
234
- clientCapabilities.topLevelUnions = false;
235
- } else if (cap === 'valid-json') {
236
- clientCapabilities.validJson = false;
237
- } else if (cap === 'refs') {
238
- clientCapabilities.refs = false;
239
- } else if (cap === 'unions') {
240
- clientCapabilities.unions = false;
241
- } else if (cap === 'formats') {
242
- clientCapabilities.formats = false;
243
- } else if (cap === 'tool-name-length') {
244
- clientCapabilities.toolNameLength = undefined;
245
- }
246
- }
247
- }
248
-
249
- const shouldIncludeToolType = (toolType: 'dynamic' | 'all' | 'code' | 'docs') =>
48
+ const shouldIncludeToolType = (toolType: 'code' | 'docs') =>
250
49
  argv.noTools?.includes(toolType) ? false
251
50
  : argv.tools?.includes(toolType) ? true
252
51
  : undefined;
253
52
 
254
- const includeDynamicTools = shouldIncludeToolType('dynamic');
255
- const includeAllTools = shouldIncludeToolType('all');
256
- const includeCodeTools = shouldIncludeToolType('code');
257
53
  const includeDocsTools = shouldIncludeToolType('docs');
258
54
 
259
55
  const transport = argv.transport as 'stdio' | 'http';
260
56
 
261
- const client = argv.client as ClientType;
262
57
  return {
263
- client: client && client !== 'infer' && knownClients[client] ? client : undefined,
264
- includeDynamicTools,
265
- includeAllTools,
266
- includeCodeTools,
267
- includeDocsTools,
268
- filters,
269
- capabilities: clientCapabilities,
270
- list: argv.list || false,
58
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
271
59
  transport,
272
60
  port: argv.port,
273
61
  socket: argv.socket,
@@ -284,190 +72,21 @@ const coerceArray = <T extends z.ZodTypeAny>(zodType: T) =>
284
72
  );
285
73
 
286
74
  const QueryOptions = z.object({
287
- tools: coerceArray(z.enum(['dynamic', 'all', 'code', 'docs'])).describe('Specify which MCP tools to use'),
288
- no_tools: coerceArray(z.enum(['dynamic', 'all', 'code', 'docs'])).describe(
289
- 'Specify which MCP tools to not use.',
290
- ),
75
+ tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
76
+ no_tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
291
77
  tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
292
- resource: coerceArray(z.string()).describe('Include tools matching the specified resources'),
293
- operation: coerceArray(z.enum(['read', 'write'])).describe(
294
- 'Include tools matching the specified operations',
295
- ),
296
- tag: coerceArray(z.string()).describe('Include tools with the specified tags'),
297
- no_tool: coerceArray(z.string()).describe('Exclude tools matching the specified names'),
298
- no_resource: coerceArray(z.string()).describe('Exclude tools matching the specified resources'),
299
- no_operation: coerceArray(z.enum(['read', 'write'])).describe(
300
- 'Exclude tools matching the specified operations',
301
- ),
302
- no_tag: coerceArray(z.string()).describe('Exclude tools with the specified tags'),
303
- client: ClientType.optional().describe('Specify the MCP client being used'),
304
- capability: coerceArray(z.string()).describe('Specify client capabilities'),
305
- no_capability: coerceArray(z.enum(CAPABILITY_CHOICES)).describe('Unset client capabilities'),
306
78
  });
307
79
 
308
80
  export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions {
309
81
  const queryObject = typeof query === 'string' ? qs.parse(query) : query;
310
82
  const queryOptions = QueryOptions.parse(queryObject);
311
83
 
312
- const filters: Filter[] = [...(defaultOptions.filters ?? [])];
313
-
314
- for (const resource of queryOptions.resource || []) {
315
- filters.push({ type: 'resource', op: 'include', value: resource });
316
- }
317
- for (const operation of queryOptions.operation || []) {
318
- filters.push({ type: 'operation', op: 'include', value: operation });
319
- }
320
- for (const tag of queryOptions.tag || []) {
321
- filters.push({ type: 'tag', op: 'include', value: tag });
322
- }
323
- for (const tool of queryOptions.tool || []) {
324
- filters.push({ type: 'tool', op: 'include', value: tool });
325
- }
326
- for (const resource of queryOptions.no_resource || []) {
327
- filters.push({ type: 'resource', op: 'exclude', value: resource });
328
- }
329
- for (const operation of queryOptions.no_operation || []) {
330
- filters.push({ type: 'operation', op: 'exclude', value: operation });
331
- }
332
- for (const tag of queryOptions.no_tag || []) {
333
- filters.push({ type: 'tag', op: 'exclude', value: tag });
334
- }
335
- for (const tool of queryOptions.no_tool || []) {
336
- filters.push({ type: 'tool', op: 'exclude', value: tool });
337
- }
338
-
339
- // Parse client capabilities
340
- const clientCapabilities: Partial<ClientCapabilities> = { ...defaultOptions.capabilities };
341
-
342
- for (const cap of queryOptions.capability || []) {
343
- const parsed = parseCapabilityValue(cap);
344
- if (parsed.name === 'top-level-unions') {
345
- clientCapabilities.topLevelUnions = true;
346
- } else if (parsed.name === 'valid-json') {
347
- clientCapabilities.validJson = true;
348
- } else if (parsed.name === 'refs') {
349
- clientCapabilities.refs = true;
350
- } else if (parsed.name === 'unions') {
351
- clientCapabilities.unions = true;
352
- } else if (parsed.name === 'formats') {
353
- clientCapabilities.formats = true;
354
- } else if (parsed.name === 'tool-name-length') {
355
- clientCapabilities.toolNameLength = parsed.value;
356
- }
357
- }
358
-
359
- for (const cap of queryOptions.no_capability || []) {
360
- if (cap === 'top-level-unions') {
361
- clientCapabilities.topLevelUnions = false;
362
- } else if (cap === 'valid-json') {
363
- clientCapabilities.validJson = false;
364
- } else if (cap === 'refs') {
365
- clientCapabilities.refs = false;
366
- } else if (cap === 'unions') {
367
- clientCapabilities.unions = false;
368
- } else if (cap === 'formats') {
369
- clientCapabilities.formats = false;
370
- } else if (cap === 'tool-name-length') {
371
- clientCapabilities.toolNameLength = undefined;
372
- }
373
- }
374
-
375
- let dynamicTools: boolean | undefined =
376
- queryOptions.no_tools && queryOptions.no_tools?.includes('dynamic') ? false
377
- : queryOptions.tools?.includes('dynamic') ? true
378
- : defaultOptions.includeDynamicTools;
379
-
380
- let allTools: boolean | undefined =
381
- queryOptions.no_tools && queryOptions.no_tools?.includes('all') ? false
382
- : queryOptions.tools?.includes('all') ? true
383
- : defaultOptions.includeAllTools;
384
-
385
84
  let docsTools: boolean | undefined =
386
85
  queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
387
86
  : queryOptions.tools?.includes('docs') ? true
388
87
  : defaultOptions.includeDocsTools;
389
88
 
390
- let codeTools: boolean | undefined =
391
- queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
392
- : queryOptions.tools?.includes('code') && defaultOptions.includeCodeTools ? true
393
- : defaultOptions.includeCodeTools;
394
-
395
89
  return {
396
- client: queryOptions.client ?? defaultOptions.client,
397
- includeDynamicTools: dynamicTools,
398
- includeAllTools: allTools,
399
- includeCodeTools: codeTools,
400
- includeDocsTools: docsTools,
401
- filters,
402
- capabilities: clientCapabilities,
90
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
403
91
  };
404
92
  }
405
-
406
- function getCapabilitiesExplanation(): string {
407
- return `
408
- Client Capabilities Explanation:
409
-
410
- 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.
411
-
412
- 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.
413
-
414
- Available Capabilities:
415
-
416
- # top-level-unions
417
- 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.
418
-
419
- # refs
420
- 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.
421
-
422
- # valid-json
423
- 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.
424
-
425
- # unions
426
- 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.
427
-
428
- # formats
429
- 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.
430
-
431
- # tool-name-length=N
432
- 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.
433
-
434
- Client Presets (--client):
435
- Presets like '--client=openai-agents' or '--client=cursor' automatically configure these capabilities based on current known limitations of those clients, simplifying setup.
436
-
437
- Current presets:
438
- ${JSON.stringify(knownClients, null, 2)}
439
- `;
440
- }
441
-
442
- function examples(): [string, string][] {
443
- const firstEndpoint = endpoints[0]!;
444
- const secondEndpoint =
445
- endpoints.find((e) => e.metadata.resource !== firstEndpoint.metadata.resource) || endpoints[1];
446
- const tag = endpoints.find((e) => e.metadata.tags.length > 0)?.metadata.tags[0];
447
- const otherEndpoint = secondEndpoint || firstEndpoint;
448
-
449
- return [
450
- [
451
- `--tool="${firstEndpoint.tool.name}" ${secondEndpoint ? `--tool="${secondEndpoint.tool.name}"` : ''}`,
452
- 'Include tools by name',
453
- ],
454
- [
455
- `--resource="${firstEndpoint.metadata.resource}" --operation="read"`,
456
- 'Filter by resource and operation',
457
- ],
458
- [
459
- `--resource="${otherEndpoint.metadata.resource}*" --no-tool="${otherEndpoint.tool.name}"`,
460
- 'Use resource wildcards and exclusions',
461
- ],
462
- [`--client="cursor"`, 'Adjust schemas to be more compatible with Cursor'],
463
- [
464
- `--capability="top-level-unions" --capability="tool-name-length=40"`,
465
- 'Specify individual client capabilities',
466
- ],
467
- [
468
- `--client="cursor" --no-capability="tool-name-length"`,
469
- 'Use cursor client preset but remove tool name length limit',
470
- ],
471
- ...(tag ? [[`--tag="${tag}"`, 'Filter based on tags'] as [string, string]] : []),
472
- ];
473
- }