anyformat-mcp 0.1.3

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 (153) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +101 -0
  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 +37 -0
  8. package/auth.js.map +1 -0
  9. package/auth.mjs +32 -0
  10. package/auth.mjs.map +1 -0
  11. package/code-tool-paths.cjs +8 -0
  12. package/code-tool-paths.cjs.map +1 -0
  13. package/code-tool-paths.d.cts +2 -0
  14. package/code-tool-paths.d.cts.map +1 -0
  15. package/code-tool-types.d.mts +14 -0
  16. package/code-tool-types.d.mts.map +1 -0
  17. package/code-tool-types.d.ts +14 -0
  18. package/code-tool-types.d.ts.map +1 -0
  19. package/code-tool-types.js +4 -0
  20. package/code-tool-types.js.map +1 -0
  21. package/code-tool-types.mjs +3 -0
  22. package/code-tool-types.mjs.map +1 -0
  23. package/code-tool-worker.d.mts +5 -0
  24. package/code-tool-worker.d.mts.map +1 -0
  25. package/code-tool-worker.d.ts +5 -0
  26. package/code-tool-worker.d.ts.map +1 -0
  27. package/code-tool-worker.js +282 -0
  28. package/code-tool-worker.js.map +1 -0
  29. package/code-tool-worker.mjs +244 -0
  30. package/code-tool-worker.mjs.map +1 -0
  31. package/code-tool.d.mts +21 -0
  32. package/code-tool.d.mts.map +1 -0
  33. package/code-tool.d.ts +21 -0
  34. package/code-tool.d.ts.map +1 -0
  35. package/code-tool.js +335 -0
  36. package/code-tool.js.map +1 -0
  37. package/code-tool.mjs +299 -0
  38. package/code-tool.mjs.map +1 -0
  39. package/docs-search-tool.d.mts +59 -0
  40. package/docs-search-tool.d.mts.map +1 -0
  41. package/docs-search-tool.d.ts +59 -0
  42. package/docs-search-tool.d.ts.map +1 -0
  43. package/docs-search-tool.js +104 -0
  44. package/docs-search-tool.js.map +1 -0
  45. package/docs-search-tool.mjs +99 -0
  46. package/docs-search-tool.mjs.map +1 -0
  47. package/http.d.mts +12 -0
  48. package/http.d.mts.map +1 -0
  49. package/http.d.ts +12 -0
  50. package/http.d.ts.map +1 -0
  51. package/http.js +190 -0
  52. package/http.js.map +1 -0
  53. package/http.mjs +182 -0
  54. package/http.mjs.map +1 -0
  55. package/index.d.mts +3 -0
  56. package/index.d.mts.map +1 -0
  57. package/index.d.ts +3 -0
  58. package/index.d.ts.map +1 -0
  59. package/index.js +60 -0
  60. package/index.js.map +1 -0
  61. package/index.mjs +58 -0
  62. package/index.mjs.map +1 -0
  63. package/instructions.d.mts +5 -0
  64. package/instructions.d.mts.map +1 -0
  65. package/instructions.d.ts +5 -0
  66. package/instructions.d.ts.map +1 -0
  67. package/instructions.js +61 -0
  68. package/instructions.js.map +1 -0
  69. package/instructions.mjs +55 -0
  70. package/instructions.mjs.map +1 -0
  71. package/local-docs-search.d.mts +28 -0
  72. package/local-docs-search.d.mts.map +1 -0
  73. package/local-docs-search.d.ts +28 -0
  74. package/local-docs-search.d.ts.map +1 -0
  75. package/local-docs-search.js +731 -0
  76. package/local-docs-search.js.map +1 -0
  77. package/local-docs-search.mjs +691 -0
  78. package/local-docs-search.mjs.map +1 -0
  79. package/logger.d.mts +7 -0
  80. package/logger.d.mts.map +1 -0
  81. package/logger.d.ts +7 -0
  82. package/logger.d.ts.map +1 -0
  83. package/logger.js +29 -0
  84. package/logger.js.map +1 -0
  85. package/logger.mjs +22 -0
  86. package/logger.mjs.map +1 -0
  87. package/methods.d.mts +10 -0
  88. package/methods.d.mts.map +1 -0
  89. package/methods.d.ts +10 -0
  90. package/methods.d.ts.map +1 -0
  91. package/methods.js +161 -0
  92. package/methods.js.map +1 -0
  93. package/methods.mjs +157 -0
  94. package/methods.mjs.map +1 -0
  95. package/options.d.mts +23 -0
  96. package/options.d.mts.map +1 -0
  97. package/options.d.ts +23 -0
  98. package/options.d.ts.map +1 -0
  99. package/options.js +141 -0
  100. package/options.js.map +1 -0
  101. package/options.mjs +134 -0
  102. package/options.mjs.map +1 -0
  103. package/package.json +235 -0
  104. package/server.d.mts +38 -0
  105. package/server.d.mts.map +1 -0
  106. package/server.d.ts +38 -0
  107. package/server.d.ts.map +1 -0
  108. package/server.js +168 -0
  109. package/server.js.map +1 -0
  110. package/server.mjs +158 -0
  111. package/server.mjs.map +1 -0
  112. package/src/auth.ts +42 -0
  113. package/src/code-tool-paths.cts +5 -0
  114. package/src/code-tool-types.ts +17 -0
  115. package/src/code-tool-worker.ts +295 -0
  116. package/src/code-tool.ts +389 -0
  117. package/src/docs-search-tool.ts +138 -0
  118. package/src/http.ts +227 -0
  119. package/src/index.ts +67 -0
  120. package/src/instructions.ts +83 -0
  121. package/src/local-docs-search.ts +831 -0
  122. package/src/logger.ts +28 -0
  123. package/src/methods.ts +182 -0
  124. package/src/options.ts +185 -0
  125. package/src/server.ts +208 -0
  126. package/src/stdio.ts +17 -0
  127. package/src/tsconfig.json +11 -0
  128. package/src/types.ts +126 -0
  129. package/src/util.ts +25 -0
  130. package/stdio.d.mts +3 -0
  131. package/stdio.d.mts.map +1 -0
  132. package/stdio.d.ts +3 -0
  133. package/stdio.d.ts.map +1 -0
  134. package/stdio.js +18 -0
  135. package/stdio.js.map +1 -0
  136. package/stdio.mjs +14 -0
  137. package/stdio.mjs.map +1 -0
  138. package/types.d.mts +65 -0
  139. package/types.d.mts.map +1 -0
  140. package/types.d.ts +65 -0
  141. package/types.d.ts.map +1 -0
  142. package/types.js +58 -0
  143. package/types.js.map +1 -0
  144. package/types.mjs +53 -0
  145. package/types.mjs.map +1 -0
  146. package/util.d.mts +4 -0
  147. package/util.d.mts.map +1 -0
  148. package/util.d.ts +4 -0
  149. package/util.d.ts.map +1 -0
  150. package/util.js +30 -0
  151. package/util.js.map +1 -0
  152. package/util.mjs +24 -0
  153. package/util.mjs.map +1 -0
package/options.js ADDED
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.parseCLIOptions = parseCLIOptions;
8
+ exports.parseQueryOptions = parseQueryOptions;
9
+ const qs_1 = __importDefault(require("qs"));
10
+ const yargs_1 = __importDefault(require("yargs"));
11
+ const helpers_1 = require("yargs/helpers");
12
+ const zod_1 = __importDefault(require("zod"));
13
+ const util_1 = require("./util.js");
14
+ function parseCLIOptions() {
15
+ const opts = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
16
+ .option('code-allow-http-gets', {
17
+ type: 'boolean',
18
+ description: 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.',
19
+ })
20
+ .option('code-allowed-methods', {
21
+ type: 'string',
22
+ array: true,
23
+ description: '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.',
24
+ })
25
+ .option('code-blocked-methods', {
26
+ type: 'string',
27
+ array: true,
28
+ description: '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.',
29
+ })
30
+ .option('code-execution-mode', {
31
+ type: 'string',
32
+ choices: ['stainless-sandbox', 'local'],
33
+ default: 'stainless-sandbox',
34
+ description: "Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.",
35
+ })
36
+ .option('custom-instructions-path', {
37
+ type: 'string',
38
+ description: 'Path to custom instructions for the MCP server',
39
+ })
40
+ .option('debug', { type: 'boolean', description: 'Enable debug logging' })
41
+ .option('docs-dir', {
42
+ type: 'string',
43
+ description: 'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.',
44
+ })
45
+ .option('docs-search-mode', {
46
+ type: 'string',
47
+ choices: ['stainless-api', 'local'],
48
+ default: 'stainless-api',
49
+ description: "Where to search documentation; 'stainless-api' uses the Stainless-hosted search API whereas 'local' uses an in-memory search index built from embedded SDK method data and optional local docs files.",
50
+ })
51
+ .option('log-format', {
52
+ type: 'string',
53
+ choices: ['json', 'pretty'],
54
+ description: 'Format for log output; defaults to json unless tty is detected',
55
+ })
56
+ .option('no-tools', {
57
+ type: 'string',
58
+ array: true,
59
+ choices: ['code', 'docs'],
60
+ description: 'Tools to explicitly disable',
61
+ })
62
+ .option('port', {
63
+ type: 'number',
64
+ default: 3000,
65
+ description: 'Port to serve on if using http transport',
66
+ })
67
+ .option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
68
+ .option('stainless-api-key', {
69
+ type: 'string',
70
+ default: (0, util_1.readEnv)('STAINLESS_API_KEY'),
71
+ description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
72
+ })
73
+ .option('tools', {
74
+ type: 'string',
75
+ array: true,
76
+ choices: ['code', 'docs'],
77
+ description: 'Tools to explicitly enable',
78
+ })
79
+ .option('transport', {
80
+ type: 'string',
81
+ choices: ['stdio', 'http'],
82
+ default: 'stdio',
83
+ description: 'What transport to use; stdio for local servers or http for remote servers',
84
+ })
85
+ .env('MCP_SERVER')
86
+ .version(true)
87
+ .help();
88
+ const argv = opts.parseSync();
89
+ const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
90
+ : argv.tools?.includes(toolType) ? true
91
+ : undefined;
92
+ const includeCodeTool = shouldIncludeToolType('code');
93
+ const includeDocsTools = shouldIncludeToolType('docs');
94
+ const transport = argv.transport;
95
+ const logFormat = argv.logFormat ? argv.logFormat
96
+ : process.stderr.isTTY ? 'pretty'
97
+ : 'json';
98
+ return {
99
+ ...(includeCodeTool !== undefined && { includeCodeTool }),
100
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
101
+ debug: !!argv.debug,
102
+ stainlessApiKey: argv.stainlessApiKey,
103
+ docsSearchMode: argv.docsSearchMode,
104
+ docsDir: argv.docsDir,
105
+ codeAllowHttpGets: argv.codeAllowHttpGets,
106
+ codeAllowedMethods: argv.codeAllowedMethods,
107
+ codeBlockedMethods: argv.codeBlockedMethods,
108
+ codeExecutionMode: argv.codeExecutionMode,
109
+ customInstructionsPath: argv.customInstructionsPath,
110
+ transport,
111
+ logFormat,
112
+ port: argv.port,
113
+ socket: argv.socket,
114
+ };
115
+ }
116
+ const coerceArray = (zodType) => zod_1.default.preprocess((val) => Array.isArray(val) ? val
117
+ : val ? [val]
118
+ : val, zod_1.default.array(zodType).optional());
119
+ const QueryOptions = zod_1.default.object({
120
+ tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
121
+ no_tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
122
+ tool: coerceArray(zod_1.default.string()).describe('Include tools matching the specified names'),
123
+ });
124
+ function parseQueryOptions(defaultOptions, query) {
125
+ const queryObject = typeof query === 'string' ? qs_1.default.parse(query) : query;
126
+ const queryOptions = QueryOptions.parse(queryObject);
127
+ let codeTool = queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
128
+ : queryOptions.tools?.includes('code') ? true
129
+ : defaultOptions.includeCodeTool;
130
+ let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
131
+ : queryOptions.tools?.includes('docs') ? true
132
+ : defaultOptions.includeDocsTools;
133
+ return {
134
+ ...(codeTool !== undefined && { includeCodeTool: codeTool }),
135
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
136
+ codeExecutionMode: defaultOptions.codeExecutionMode,
137
+ docsSearchMode: defaultOptions.docsSearchMode,
138
+ docsDir: defaultOptions.docsDir,
139
+ };
140
+ }
141
+ //# sourceMappingURL=options.js.map
package/options.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;AA+BtF,0CAmHC;AAiBD,8CAqBC;AAtLD,4CAAoB;AACpB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C,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;QAC5D,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;QAC/D,iBAAiB,EAAE,cAAc,CAAC,iBAAiB;QACnD,cAAc,EAAE,cAAc,CAAC,cAAc;QAC7C,OAAO,EAAE,cAAc,CAAC,OAAO;KAChC,CAAC;AACJ,CAAC"}
package/options.mjs ADDED
@@ -0,0 +1,134 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import qs from 'qs';
3
+ import yargs from 'yargs';
4
+ import { hideBin } from 'yargs/helpers';
5
+ import z from 'zod';
6
+ import { readEnv } from "./util.mjs";
7
+ export function parseCLIOptions() {
8
+ const opts = yargs(hideBin(process.argv))
9
+ .option('code-allow-http-gets', {
10
+ type: 'boolean',
11
+ description: 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.',
12
+ })
13
+ .option('code-allowed-methods', {
14
+ type: 'string',
15
+ array: true,
16
+ description: '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.',
17
+ })
18
+ .option('code-blocked-methods', {
19
+ type: 'string',
20
+ array: true,
21
+ description: '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.',
22
+ })
23
+ .option('code-execution-mode', {
24
+ type: 'string',
25
+ choices: ['stainless-sandbox', 'local'],
26
+ default: 'stainless-sandbox',
27
+ description: "Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.",
28
+ })
29
+ .option('custom-instructions-path', {
30
+ type: 'string',
31
+ description: 'Path to custom instructions for the MCP server',
32
+ })
33
+ .option('debug', { type: 'boolean', description: 'Enable debug logging' })
34
+ .option('docs-dir', {
35
+ type: 'string',
36
+ description: 'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.',
37
+ })
38
+ .option('docs-search-mode', {
39
+ type: 'string',
40
+ choices: ['stainless-api', 'local'],
41
+ default: 'stainless-api',
42
+ description: "Where to search documentation; 'stainless-api' uses the Stainless-hosted search API whereas 'local' uses an in-memory search index built from embedded SDK method data and optional local docs files.",
43
+ })
44
+ .option('log-format', {
45
+ type: 'string',
46
+ choices: ['json', 'pretty'],
47
+ description: 'Format for log output; defaults to json unless tty is detected',
48
+ })
49
+ .option('no-tools', {
50
+ type: 'string',
51
+ array: true,
52
+ choices: ['code', 'docs'],
53
+ description: 'Tools to explicitly disable',
54
+ })
55
+ .option('port', {
56
+ type: 'number',
57
+ default: 3000,
58
+ description: 'Port to serve on if using http transport',
59
+ })
60
+ .option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
61
+ .option('stainless-api-key', {
62
+ type: 'string',
63
+ default: readEnv('STAINLESS_API_KEY'),
64
+ description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
65
+ })
66
+ .option('tools', {
67
+ type: 'string',
68
+ array: true,
69
+ choices: ['code', 'docs'],
70
+ description: 'Tools to explicitly enable',
71
+ })
72
+ .option('transport', {
73
+ type: 'string',
74
+ choices: ['stdio', 'http'],
75
+ default: 'stdio',
76
+ description: 'What transport to use; stdio for local servers or http for remote servers',
77
+ })
78
+ .env('MCP_SERVER')
79
+ .version(true)
80
+ .help();
81
+ const argv = opts.parseSync();
82
+ const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
83
+ : argv.tools?.includes(toolType) ? true
84
+ : undefined;
85
+ const includeCodeTool = shouldIncludeToolType('code');
86
+ const includeDocsTools = shouldIncludeToolType('docs');
87
+ const transport = argv.transport;
88
+ const logFormat = argv.logFormat ? argv.logFormat
89
+ : process.stderr.isTTY ? 'pretty'
90
+ : 'json';
91
+ return {
92
+ ...(includeCodeTool !== undefined && { includeCodeTool }),
93
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
94
+ debug: !!argv.debug,
95
+ stainlessApiKey: argv.stainlessApiKey,
96
+ docsSearchMode: argv.docsSearchMode,
97
+ docsDir: argv.docsDir,
98
+ codeAllowHttpGets: argv.codeAllowHttpGets,
99
+ codeAllowedMethods: argv.codeAllowedMethods,
100
+ codeBlockedMethods: argv.codeBlockedMethods,
101
+ codeExecutionMode: argv.codeExecutionMode,
102
+ customInstructionsPath: argv.customInstructionsPath,
103
+ transport,
104
+ logFormat,
105
+ port: argv.port,
106
+ socket: argv.socket,
107
+ };
108
+ }
109
+ const coerceArray = (zodType) => z.preprocess((val) => Array.isArray(val) ? val
110
+ : val ? [val]
111
+ : val, z.array(zodType).optional());
112
+ const QueryOptions = z.object({
113
+ tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
114
+ no_tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
115
+ tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
116
+ });
117
+ export function parseQueryOptions(defaultOptions, query) {
118
+ const queryObject = typeof query === 'string' ? qs.parse(query) : query;
119
+ const queryOptions = QueryOptions.parse(queryObject);
120
+ let codeTool = queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false
121
+ : queryOptions.tools?.includes('code') ? true
122
+ : defaultOptions.includeCodeTool;
123
+ let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
124
+ : queryOptions.tools?.includes('docs') ? true
125
+ : defaultOptions.includeDocsTools;
126
+ return {
127
+ ...(codeTool !== undefined && { includeCodeTool: codeTool }),
128
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
129
+ codeExecutionMode: defaultOptions.codeExecutionMode,
130
+ docsSearchMode: defaultOptions.docsSearchMode,
131
+ docsDir: defaultOptions.docsDir,
132
+ };
133
+ }
134
+ //# sourceMappingURL=options.mjs.map
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AAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;QAC5D,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;QAC/D,iBAAiB,EAAE,cAAc,CAAC,iBAAiB;QACnD,cAAc,EAAE,cAAc,CAAC,cAAc;QAC7C,OAAO,EAAE,cAAc,CAAC,OAAO;KAChC,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,235 @@
1
+ {
2
+ "name": "anyformat-mcp",
3
+ "version": "0.1.3",
4
+ "description": "The official MCP Server for the Anyformat API",
5
+ "author": "Anyformat <>",
6
+ "types": "./index.d.ts",
7
+ "main": "./index.js",
8
+ "type": "commonjs",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/anyformat-ai/anyformat-node.git",
12
+ "directory": "packages/mcp-server"
13
+ },
14
+ "homepage": "https://github.com/anyformat-ai/anyformat-node/tree/main/packages/mcp-server#readme",
15
+ "license": "Apache-2.0",
16
+ "private": false,
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "dependencies": {
21
+ "anyformat-ai": "^0.1.3",
22
+ "ajv": "^8.18.0",
23
+ "@cloudflare/cabidela": "^0.2.4",
24
+ "@hono/node-server": "^1.19.10",
25
+ "@modelcontextprotocol/sdk": "^1.27.1",
26
+ "hono": "^4.12.4",
27
+ "@valtown/deno-http-worker": "^0.0.21",
28
+ "cookie-parser": "^1.4.6",
29
+ "cors": "^2.8.5",
30
+ "express": "^5.1.0",
31
+ "fuse.js": "^7.1.0",
32
+ "minisearch": "^7.2.0",
33
+ "jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.8/jq-web.tar.gz",
34
+ "pino": "^10.3.1",
35
+ "pino-http": "^11.0.0",
36
+ "pino-pretty": "^13.1.3",
37
+ "qs": "^6.14.1",
38
+ "typescript": "5.8.3",
39
+ "yargs": "^17.7.2",
40
+ "zod": "^3.25.20",
41
+ "zod-to-json-schema": "^3.24.5",
42
+ "zod-validation-error": "^4.0.1"
43
+ },
44
+ "bin": {
45
+ "mcp-server": "./index.js"
46
+ },
47
+ "imports": {
48
+ "anyformat-mcp": ".",
49
+ "anyformat-mcp/*": "./src/*"
50
+ },
51
+ "exports": {
52
+ ".": {
53
+ "require": {
54
+ "types": "./index.d.ts",
55
+ "default": "./index.js"
56
+ },
57
+ "types": "./index.d.mts",
58
+ "default": "./index.mjs"
59
+ },
60
+ "./auth": {
61
+ "import": "./auth.mjs",
62
+ "require": "./auth.js"
63
+ },
64
+ "./auth.js": {
65
+ "default": "./auth.js"
66
+ },
67
+ "./auth.mjs": {
68
+ "default": "./auth.mjs"
69
+ },
70
+ "./code-tool-paths": {
71
+ "require": "./code-tool-paths.cjs"
72
+ },
73
+ "./code-tool-paths.cjs": {
74
+ "default": "./code-tool-paths.cjs"
75
+ },
76
+ "./code-tool-types": {
77
+ "import": "./code-tool-types.mjs",
78
+ "require": "./code-tool-types.js"
79
+ },
80
+ "./code-tool-types.js": {
81
+ "default": "./code-tool-types.js"
82
+ },
83
+ "./code-tool-types.mjs": {
84
+ "default": "./code-tool-types.mjs"
85
+ },
86
+ "./code-tool-worker": {
87
+ "import": "./code-tool-worker.mjs",
88
+ "require": "./code-tool-worker.js"
89
+ },
90
+ "./code-tool-worker.js": {
91
+ "default": "./code-tool-worker.js"
92
+ },
93
+ "./code-tool-worker.mjs": {
94
+ "default": "./code-tool-worker.mjs"
95
+ },
96
+ "./code-tool": {
97
+ "import": "./code-tool.mjs",
98
+ "require": "./code-tool.js"
99
+ },
100
+ "./code-tool.js": {
101
+ "default": "./code-tool.js"
102
+ },
103
+ "./code-tool.mjs": {
104
+ "default": "./code-tool.mjs"
105
+ },
106
+ "./docs-search-tool": {
107
+ "import": "./docs-search-tool.mjs",
108
+ "require": "./docs-search-tool.js"
109
+ },
110
+ "./docs-search-tool.js": {
111
+ "default": "./docs-search-tool.js"
112
+ },
113
+ "./docs-search-tool.mjs": {
114
+ "default": "./docs-search-tool.mjs"
115
+ },
116
+ "./http": {
117
+ "import": "./http.mjs",
118
+ "require": "./http.js"
119
+ },
120
+ "./http.js": {
121
+ "default": "./http.js"
122
+ },
123
+ "./http.mjs": {
124
+ "default": "./http.mjs"
125
+ },
126
+ "./index": {
127
+ "import": "./index.mjs",
128
+ "require": "./index.js"
129
+ },
130
+ "./index.js": {
131
+ "default": "./index.js"
132
+ },
133
+ "./index.mjs": {
134
+ "default": "./index.mjs"
135
+ },
136
+ "./instructions": {
137
+ "import": "./instructions.mjs",
138
+ "require": "./instructions.js"
139
+ },
140
+ "./instructions.js": {
141
+ "default": "./instructions.js"
142
+ },
143
+ "./instructions.mjs": {
144
+ "default": "./instructions.mjs"
145
+ },
146
+ "./local-docs-search": {
147
+ "import": "./local-docs-search.mjs",
148
+ "require": "./local-docs-search.js"
149
+ },
150
+ "./local-docs-search.js": {
151
+ "default": "./local-docs-search.js"
152
+ },
153
+ "./local-docs-search.mjs": {
154
+ "default": "./local-docs-search.mjs"
155
+ },
156
+ "./logger": {
157
+ "import": "./logger.mjs",
158
+ "require": "./logger.js"
159
+ },
160
+ "./logger.js": {
161
+ "default": "./logger.js"
162
+ },
163
+ "./logger.mjs": {
164
+ "default": "./logger.mjs"
165
+ },
166
+ "./methods": {
167
+ "import": "./methods.mjs",
168
+ "require": "./methods.js"
169
+ },
170
+ "./methods.js": {
171
+ "default": "./methods.js"
172
+ },
173
+ "./methods.mjs": {
174
+ "default": "./methods.mjs"
175
+ },
176
+ "./options": {
177
+ "import": "./options.mjs",
178
+ "require": "./options.js"
179
+ },
180
+ "./options.js": {
181
+ "default": "./options.js"
182
+ },
183
+ "./options.mjs": {
184
+ "default": "./options.mjs"
185
+ },
186
+ "./server": {
187
+ "import": "./server.mjs",
188
+ "require": "./server.js"
189
+ },
190
+ "./server.js": {
191
+ "default": "./server.js"
192
+ },
193
+ "./server.mjs": {
194
+ "default": "./server.mjs"
195
+ },
196
+ "./stdio": {
197
+ "import": "./stdio.mjs",
198
+ "require": "./stdio.js"
199
+ },
200
+ "./stdio.js": {
201
+ "default": "./stdio.js"
202
+ },
203
+ "./stdio.mjs": {
204
+ "default": "./stdio.mjs"
205
+ },
206
+ "./types": {
207
+ "import": "./types.mjs",
208
+ "require": "./types.js"
209
+ },
210
+ "./types.js": {
211
+ "default": "./types.js"
212
+ },
213
+ "./types.mjs": {
214
+ "default": "./types.mjs"
215
+ },
216
+ "./util": {
217
+ "import": "./util.mjs",
218
+ "require": "./util.js"
219
+ },
220
+ "./util.js": {
221
+ "default": "./util.js"
222
+ },
223
+ "./util.mjs": {
224
+ "default": "./util.mjs"
225
+ }
226
+ },
227
+ "scripts": {
228
+ "test": "jest",
229
+ "build": "bash ./build",
230
+ "format": "prettier --write --cache --cache-strategy metadata . !dist",
231
+ "tsn": "ts-node -r tsconfig-paths/register",
232
+ "lint": "eslint .",
233
+ "fix": "eslint --fix ."
234
+ }
235
+ }
package/server.d.mts ADDED
@@ -0,0 +1,38 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { ClientOptions } from 'anyformat-ai';
4
+ import { McpOptions } from "./options.mjs";
5
+ import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.mjs";
6
+ export declare const newMcpServer: ({ stainlessApiKey, customInstructionsPath, }: {
7
+ stainlessApiKey?: string | undefined;
8
+ customInstructionsPath?: string | undefined;
9
+ }) => Promise<McpServer>;
10
+ /**
11
+ * Initializes the provided MCP Server with the given tools and handlers.
12
+ * If not provided, the default client, tools and handlers will be used.
13
+ */
14
+ export declare function initMcpServer(params: {
15
+ server: Server | McpServer;
16
+ clientOptions?: ClientOptions;
17
+ mcpOptions?: McpOptions;
18
+ stainlessApiKey?: string | undefined;
19
+ upstreamClientEnvs?: Record<string, string> | undefined;
20
+ mcpSessionId?: string | undefined;
21
+ mcpClientInfo?: {
22
+ name: string;
23
+ version: string;
24
+ } | undefined;
25
+ }): Promise<void>;
26
+ /**
27
+ * Selects the tools to include in the MCP Server based on the provided options.
28
+ */
29
+ export declare function selectTools(options?: McpOptions): McpTool[];
30
+ /**
31
+ * Runs the provided handler with the given client and arguments.
32
+ */
33
+ export declare function executeHandler({ handler, reqContext, args, }: {
34
+ handler: HandlerFunction;
35
+ reqContext: McpRequestContext;
36
+ args: Record<string, unknown> | undefined;
37
+ }): Promise<ToolCallResult>;
38
+ //# sourceMappingURL=server.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;OAOrC,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE;AAEtE,eAAO,MAAM,YAAY,GAAU,8CAGhC;IACD,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C,uBAUE,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACxD,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CAC/D,iBA0HA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAe3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GACL,EAAE;IACD,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,GAAG,OAAO,CAAC,cAAc,CAAC,CAE1B"}
package/server.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { ClientOptions } from 'anyformat-ai';
4
+ import { McpOptions } from "./options.js";
5
+ import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.js";
6
+ export declare const newMcpServer: ({ stainlessApiKey, customInstructionsPath, }: {
7
+ stainlessApiKey?: string | undefined;
8
+ customInstructionsPath?: string | undefined;
9
+ }) => Promise<McpServer>;
10
+ /**
11
+ * Initializes the provided MCP Server with the given tools and handlers.
12
+ * If not provided, the default client, tools and handlers will be used.
13
+ */
14
+ export declare function initMcpServer(params: {
15
+ server: Server | McpServer;
16
+ clientOptions?: ClientOptions;
17
+ mcpOptions?: McpOptions;
18
+ stainlessApiKey?: string | undefined;
19
+ upstreamClientEnvs?: Record<string, string> | undefined;
20
+ mcpSessionId?: string | undefined;
21
+ mcpClientInfo?: {
22
+ name: string;
23
+ version: string;
24
+ } | undefined;
25
+ }): Promise<void>;
26
+ /**
27
+ * Selects the tools to include in the MCP Server based on the provided options.
28
+ */
29
+ export declare function selectTools(options?: McpOptions): McpTool[];
30
+ /**
31
+ * Runs the provided handler with the given client and arguments.
32
+ */
33
+ export declare function executeHandler({ handler, reqContext, args, }: {
34
+ handler: HandlerFunction;
35
+ reqContext: McpRequestContext;
36
+ args: Record<string, unknown> | undefined;
37
+ }): Promise<ToolCallResult>;
38
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,cAAc;OAOrC,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE;AAEtE,eAAO,MAAM,YAAY,GAAU,8CAGhC;IACD,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C,uBAUE,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACxD,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CAC/D,iBA0HA;AAED;;GAEG;AAC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