@revoxai/sdk-mcp 0.1.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 (144) 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 +6 -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 +237 -0
  28. package/code-tool-worker.js.map +1 -0
  29. package/code-tool-worker.mjs +232 -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 +331 -0
  36. package/code-tool.js.map +1 -0
  37. package/code-tool.mjs +292 -0
  38. package/code-tool.mjs.map +1 -0
  39. package/docs-search-tool.d.mts +57 -0
  40. package/docs-search-tool.d.mts.map +1 -0
  41. package/docs-search-tool.d.ts +57 -0
  42. package/docs-search-tool.d.ts.map +1 -0
  43. package/docs-search-tool.js +74 -0
  44. package/docs-search-tool.js.map +1 -0
  45. package/docs-search-tool.mjs +70 -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 +128 -0
  52. package/http.js.map +1 -0
  53. package/http.mjs +120 -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 +2 -0
  64. package/instructions.d.mts.map +1 -0
  65. package/instructions.d.ts +2 -0
  66. package/instructions.d.ts.map +1 -0
  67. package/instructions.js +46 -0
  68. package/instructions.js.map +1 -0
  69. package/instructions.mjs +43 -0
  70. package/instructions.mjs.map +1 -0
  71. package/logger.d.mts +7 -0
  72. package/logger.d.mts.map +1 -0
  73. package/logger.d.ts +7 -0
  74. package/logger.d.ts.map +1 -0
  75. package/logger.js +29 -0
  76. package/logger.js.map +1 -0
  77. package/logger.mjs +22 -0
  78. package/logger.mjs.map +1 -0
  79. package/methods.d.mts +10 -0
  80. package/methods.d.mts.map +1 -0
  81. package/methods.d.ts +10 -0
  82. package/methods.d.ts.map +1 -0
  83. package/methods.js +143 -0
  84. package/methods.js.map +1 -0
  85. package/methods.mjs +139 -0
  86. package/methods.mjs.map +1 -0
  87. package/options.d.mts +20 -0
  88. package/options.d.mts.map +1 -0
  89. package/options.d.ts +20 -0
  90. package/options.d.ts.map +1 -0
  91. package/options.js +122 -0
  92. package/options.js.map +1 -0
  93. package/options.mjs +115 -0
  94. package/options.mjs.map +1 -0
  95. package/package.json +224 -0
  96. package/server.d.mts +29 -0
  97. package/server.d.mts.map +1 -0
  98. package/server.d.ts +29 -0
  99. package/server.d.ts.map +1 -0
  100. package/server.js +158 -0
  101. package/server.js.map +1 -0
  102. package/server.mjs +148 -0
  103. package/server.mjs.map +1 -0
  104. package/src/auth.ts +42 -0
  105. package/src/code-tool-paths.cts +3 -0
  106. package/src/code-tool-types.ts +17 -0
  107. package/src/code-tool-worker.ts +283 -0
  108. package/src/code-tool.ts +383 -0
  109. package/src/docs-search-tool.ts +100 -0
  110. package/src/http.ts +159 -0
  111. package/src/index.ts +67 -0
  112. package/src/instructions.ts +65 -0
  113. package/src/logger.ts +28 -0
  114. package/src/methods.ts +164 -0
  115. package/src/options.ts +161 -0
  116. package/src/server.ts +188 -0
  117. package/src/stdio.ts +14 -0
  118. package/src/tsconfig.json +11 -0
  119. package/src/types.ts +123 -0
  120. package/src/util.ts +25 -0
  121. package/stdio.d.mts +3 -0
  122. package/stdio.d.mts.map +1 -0
  123. package/stdio.d.ts +3 -0
  124. package/stdio.d.ts.map +1 -0
  125. package/stdio.js +15 -0
  126. package/stdio.js.map +1 -0
  127. package/stdio.mjs +11 -0
  128. package/stdio.mjs.map +1 -0
  129. package/types.d.mts +59 -0
  130. package/types.d.mts.map +1 -0
  131. package/types.d.ts +59 -0
  132. package/types.d.ts.map +1 -0
  133. package/types.js +58 -0
  134. package/types.js.map +1 -0
  135. package/types.mjs +53 -0
  136. package/types.mjs.map +1 -0
  137. package/util.d.mts +4 -0
  138. package/util.d.mts.map +1 -0
  139. package/util.d.ts +4 -0
  140. package/util.d.ts.map +1 -0
  141. package/util.js +30 -0
  142. package/util.js.map +1 -0
  143. package/util.mjs +24 -0
  144. package/util.mjs.map +1 -0
@@ -0,0 +1,57 @@
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { Metadata, McpRequestContext } from "./types.mjs";
3
+ export declare const metadata: Metadata;
4
+ export declare const tool: Tool;
5
+ export declare const handler: ({ reqContext, args, }: {
6
+ reqContext: McpRequestContext;
7
+ args: Record<string, unknown> | undefined;
8
+ }) => Promise<import("./types").ToolCallResult>;
9
+ declare const _default: {
10
+ metadata: Metadata;
11
+ tool: {
12
+ inputSchema: {
13
+ [x: string]: unknown;
14
+ type: "object";
15
+ properties?: {
16
+ [x: string]: object;
17
+ } | undefined;
18
+ required?: string[] | undefined;
19
+ };
20
+ name: string;
21
+ description?: string | undefined;
22
+ outputSchema?: {
23
+ [x: string]: unknown;
24
+ type: "object";
25
+ properties?: {
26
+ [x: string]: object;
27
+ } | undefined;
28
+ required?: string[] | undefined;
29
+ } | undefined;
30
+ annotations?: {
31
+ title?: string | undefined;
32
+ readOnlyHint?: boolean | undefined;
33
+ destructiveHint?: boolean | undefined;
34
+ idempotentHint?: boolean | undefined;
35
+ openWorldHint?: boolean | undefined;
36
+ } | undefined;
37
+ execution?: {
38
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
39
+ } | undefined;
40
+ _meta?: {
41
+ [x: string]: unknown;
42
+ } | undefined;
43
+ icons?: {
44
+ src: string;
45
+ mimeType?: string | undefined;
46
+ sizes?: string[] | undefined;
47
+ theme?: "light" | "dark" | undefined;
48
+ }[] | undefined;
49
+ title?: string | undefined;
50
+ };
51
+ handler: ({ reqContext, args, }: {
52
+ reqContext: McpRequestContext;
53
+ args: Record<string, unknown> | undefined;
54
+ }) => Promise<import("./types").ToolCallResult>;
55
+ };
56
+ export default _default;
57
+ //# sourceMappingURL=docs-search-tool.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.d.mts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,IAAI,EAAE,MAAM,oCAAoC;OAClD,EAAE,QAAQ,EAAE,iBAAiB,EAAuB;AAG3D,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA2BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,uBAG3B;IACD,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,8CA8CA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAjDC;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;KAC3C;;AAgDD,wBAA2C"}
@@ -0,0 +1,57 @@
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { Metadata, McpRequestContext } from "./types.js";
3
+ export declare const metadata: Metadata;
4
+ export declare const tool: Tool;
5
+ export declare const handler: ({ reqContext, args, }: {
6
+ reqContext: McpRequestContext;
7
+ args: Record<string, unknown> | undefined;
8
+ }) => Promise<import("./types").ToolCallResult>;
9
+ declare const _default: {
10
+ metadata: Metadata;
11
+ tool: {
12
+ inputSchema: {
13
+ [x: string]: unknown;
14
+ type: "object";
15
+ properties?: {
16
+ [x: string]: object;
17
+ } | undefined;
18
+ required?: string[] | undefined;
19
+ };
20
+ name: string;
21
+ description?: string | undefined;
22
+ outputSchema?: {
23
+ [x: string]: unknown;
24
+ type: "object";
25
+ properties?: {
26
+ [x: string]: object;
27
+ } | undefined;
28
+ required?: string[] | undefined;
29
+ } | undefined;
30
+ annotations?: {
31
+ title?: string | undefined;
32
+ readOnlyHint?: boolean | undefined;
33
+ destructiveHint?: boolean | undefined;
34
+ idempotentHint?: boolean | undefined;
35
+ openWorldHint?: boolean | undefined;
36
+ } | undefined;
37
+ execution?: {
38
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
39
+ } | undefined;
40
+ _meta?: {
41
+ [x: string]: unknown;
42
+ } | undefined;
43
+ icons?: {
44
+ src: string;
45
+ mimeType?: string | undefined;
46
+ sizes?: string[] | undefined;
47
+ theme?: "light" | "dark" | undefined;
48
+ }[] | undefined;
49
+ title?: string | undefined;
50
+ };
51
+ handler: ({ reqContext, args, }: {
52
+ reqContext: McpRequestContext;
53
+ args: Record<string, unknown> | undefined;
54
+ }) => Promise<import("./types").ToolCallResult>;
55
+ };
56
+ export default _default;
57
+ //# sourceMappingURL=docs-search-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.d.ts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,IAAI,EAAE,MAAM,oCAAoC;OAClD,EAAE,QAAQ,EAAE,iBAAiB,EAAuB;AAG3D,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA2BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,uBAG3B;IACD,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,8CA8CA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAjDC;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;KAC3C;;AAgDD,wBAA2C"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.handler = exports.tool = exports.metadata = void 0;
5
+ const types_1 = require("./types.js");
6
+ const logger_1 = require("./logger.js");
7
+ exports.metadata = {
8
+ resource: 'all',
9
+ operation: 'read',
10
+ tags: [],
11
+ httpMethod: 'get',
12
+ };
13
+ exports.tool = {
14
+ name: 'search_docs',
15
+ description: 'Search SDK documentation to find methods, parameters, and usage examples for interacting with the API. Use this before writing code when you need to discover the right approach.',
16
+ inputSchema: {
17
+ type: 'object',
18
+ properties: {
19
+ query: {
20
+ type: 'string',
21
+ description: 'The query to search for.',
22
+ },
23
+ language: {
24
+ type: 'string',
25
+ description: 'The language for the SDK to search for.',
26
+ enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
27
+ },
28
+ detail: {
29
+ type: 'string',
30
+ description: 'The amount of detail to return.',
31
+ enum: ['default', 'verbose'],
32
+ },
33
+ },
34
+ required: ['query', 'language'],
35
+ },
36
+ annotations: {
37
+ readOnlyHint: true,
38
+ },
39
+ };
40
+ const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/revox/docs/search';
41
+ const handler = async ({ reqContext, args, }) => {
42
+ const body = args;
43
+ const query = new URLSearchParams(body).toString();
44
+ const startTime = Date.now();
45
+ const result = await fetch(`${docsSearchURL}?${query}`, {
46
+ headers: {
47
+ ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
48
+ },
49
+ });
50
+ const logger = (0, logger_1.getLogger)();
51
+ if (!result.ok) {
52
+ const errorText = await result.text();
53
+ logger.warn({
54
+ durationMs: Date.now() - startTime,
55
+ query: body.query,
56
+ status: result.status,
57
+ statusText: result.statusText,
58
+ errorText,
59
+ }, 'Got error response from docs search tool');
60
+ if (result.status === 404 && !reqContext.stainlessApiKey) {
61
+ throw new Error('Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.');
62
+ }
63
+ throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`);
64
+ }
65
+ const resultBody = await result.json();
66
+ logger.info({
67
+ durationMs: Date.now() - startTime,
68
+ query: body.query,
69
+ }, 'Got docs search result');
70
+ return (0, types_1.asTextContentResult)(resultBody);
71
+ };
72
+ exports.handler = handler;
73
+ exports.default = { metadata: exports.metadata, tool: exports.tool, handler: exports.handler };
74
+ //# sourceMappingURL=docs-search-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.js","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAGtF,sCAA2E;AAC3E,wCAAqC;AAExB,QAAA,QAAQ,GAAa;IAChC,QAAQ,EAAE,KAAK;IACf,SAAS,E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Ae,EAAE,CAAC;SACjF;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;IAE3B,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CACT;YACE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAClC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,SAAS;SACV,EACD,0CAA0C,CAC3C,CAAC;QAEF,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CACb,yMAAyM,CAC1M,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,yCAAyC,SAAS,EAAE,CAC3F,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACvC,MAAM,CAAC,IAAI,CACT;QACE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;QAClC,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,EACD,wBAAwB,CACzB,CAAC;IACF,OAAO,IAAA,2BAAmB,EAAC,UAAU,CAAC,CAAC;AACzC,CAAC,CAAC;AApDW,QAAA,OAAO,WAoDlB;AAEF,kBAAe,EAAE,QAAQ,EAAR,gBAAQ,EAAE,IAAI,EAAJ,YAAI,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC"}
@@ -0,0 +1,70 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { asTextContentResult } from "./types.mjs";
3
+ import { getLogger } from "./logger.mjs";
4
+ export const metadata = {
5
+ resource: 'all',
6
+ operation: 'read',
7
+ tags: [],
8
+ httpMethod: 'get',
9
+ };
10
+ export const tool = {
11
+ name: 'search_docs',
12
+ description: 'Search SDK documentation to find methods, parameters, and usage examples for interacting with the API. Use this before writing code when you need to discover the right approach.',
13
+ inputSchema: {
14
+ type: 'object',
15
+ properties: {
16
+ query: {
17
+ type: 'string',
18
+ description: 'The query to search for.',
19
+ },
20
+ language: {
21
+ type: 'string',
22
+ description: 'The language for the SDK to search for.',
23
+ enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
24
+ },
25
+ detail: {
26
+ type: 'string',
27
+ description: 'The amount of detail to return.',
28
+ enum: ['default', 'verbose'],
29
+ },
30
+ },
31
+ required: ['query', 'language'],
32
+ },
33
+ annotations: {
34
+ readOnlyHint: true,
35
+ },
36
+ };
37
+ const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/revox/docs/search';
38
+ export const handler = async ({ reqContext, args, }) => {
39
+ const body = args;
40
+ const query = new URLSearchParams(body).toString();
41
+ const startTime = Date.now();
42
+ const result = await fetch(`${docsSearchURL}?${query}`, {
43
+ headers: {
44
+ ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
45
+ },
46
+ });
47
+ const logger = getLogger();
48
+ if (!result.ok) {
49
+ const errorText = await result.text();
50
+ logger.warn({
51
+ durationMs: Date.now() - startTime,
52
+ query: body.query,
53
+ status: result.status,
54
+ statusText: result.statusText,
55
+ errorText,
56
+ }, 'Got error response from docs search tool');
57
+ if (result.status === 404 && !reqContext.stainlessApiKey) {
58
+ throw new Error('Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.');
59
+ }
60
+ throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`);
61
+ }
62
+ const resultBody = await result.json();
63
+ logger.info({
64
+ durationMs: Date.now() - startTime,
65
+ query: body.query,
66
+ }, 'Got docs search result');
67
+ return asTextContentResult(resultBody);
68
+ };
69
+ export default { metadata, tool, handler };
70
+ //# sourceMappingURL=docs-search-tool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.mjs","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAA+B,mBAAmB,EAAE;OACpD,EAAE,SAAS,EAAE;AAEpB,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,mLAAmL;IACrL,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;gBACtD,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;aAClG;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;gBAC9C,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;aAC7B;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KAChC;IACD,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;KACnB;CACF,CAAC;AAEF,MAAM,aAAa,GACjB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,0DAA0D,CAAC;AAE/F,MAAM,CAAC,MAAM,OAAO,GAAG,KA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AAK,EAAE,IAAI,CAAC,KAAK;KAClB,EACD,wBAAwB,CACzB,CAAC;IACF,OAAO,mBAAmB,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC"}
package/http.d.mts ADDED
@@ -0,0 +1,12 @@
1
+ import { ClientOptions } from '@revoxai/sdk';
2
+ import express from 'express';
3
+ import { McpOptions } from "./options.mjs";
4
+ export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
5
+ clientOptions?: ClientOptions;
6
+ mcpOptions: McpOptions;
7
+ }) => express.Express;
8
+ export declare const launchStreamableHTTPServer: ({ mcpOptions, port, }: {
9
+ mcpOptions: McpOptions;
10
+ port: number | string | undefined;
11
+ }) => Promise<void>;
12
+ //# sourceMappingURL=http.d.mts.map
package/http.d.mts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,cAAc;OACrC,OAAO,MAAM,SAAS;OAKtB,EAAE,UAAU,EAAE;AA0ErB,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;CACxB,KAAG,OAAO,CAAC,OA8CX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,uBAG9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAcA,CAAC"}
package/http.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { ClientOptions } from '@revoxai/sdk';
2
+ import express from 'express';
3
+ import { McpOptions } from "./options.js";
4
+ export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
5
+ clientOptions?: ClientOptions;
6
+ mcpOptions: McpOptions;
7
+ }) => express.Express;
8
+ export declare const launchStreamableHTTPServer: ({ mcpOptions, port, }: {
9
+ mcpOptions: McpOptions;
10
+ port: number | string | undefined;
11
+ }) => Promise<void>;
12
+ //# sourceMappingURL=http.d.ts.map
package/http.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,EAAE,aAAa,EAAE,MAAM,cAAc;OACrC,OAAO,MAAM,SAAS;OAKtB,EAAE,UAAU,EAAE;AA0ErB,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;CACxB,KAAG,OAAO,CAAC,OA8CX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,uBAG9C;IACD,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAcA,CAAC"}
package/http.js ADDED
@@ -0,0 +1,128 @@
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.launchStreamableHTTPServer = exports.streamableHTTPApp = void 0;
8
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
9
+ const express_1 = __importDefault(require("express"));
10
+ const pino_1 = __importDefault(require("pino"));
11
+ const pino_http_1 = __importDefault(require("pino-http"));
12
+ const auth_1 = require("./auth.js");
13
+ const logger_1 = require("./logger.js");
14
+ const server_1 = require("./server.js");
15
+ const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
16
+ const stainlessApiKey = (0, auth_1.getStainlessApiKey)(req, mcpOptions);
17
+ const server = await (0, server_1.newMcpServer)(stainlessApiKey);
18
+ const authOptions = (0, auth_1.parseClientAuthHeaders)(req, false);
19
+ await (0, server_1.initMcpServer)({
20
+ server: server,
21
+ mcpOptions: mcpOptions,
22
+ clientOptions: {
23
+ ...clientOptions,
24
+ ...authOptions,
25
+ },
26
+ stainlessApiKey: stainlessApiKey,
27
+ });
28
+ return server;
29
+ };
30
+ const post = (options) => async (req, res) => {
31
+ const server = await newServer({ ...options, req, res });
32
+ // If we return null, we already set the authorization error.
33
+ if (server === null)
34
+ return;
35
+ const transport = new streamableHttp_js_1.StreamableHTTPServerTransport();
36
+ await server.connect(transport);
37
+ await transport.handleRequest(req, res, req.body);
38
+ };
39
+ const get = async (req, res) => {
40
+ res.status(405).json({
41
+ jsonrpc: '2.0',
42
+ error: {
43
+ code: -32000,
44
+ message: 'Method not supported',
45
+ },
46
+ });
47
+ };
48
+ const del = async (req, res) => {
49
+ res.status(405).json({
50
+ jsonrpc: '2.0',
51
+ error: {
52
+ code: -32000,
53
+ message: 'Method not supported',
54
+ },
55
+ });
56
+ };
57
+ const redactHeaders = (headers) => {
58
+ const hiddenHeaders = /auth|cookie|key|token/i;
59
+ const filtered = { ...headers };
60
+ Object.keys(filtered).forEach((key) => {
61
+ if (hiddenHeaders.test(key)) {
62
+ filtered[key] = '[REDACTED]';
63
+ }
64
+ });
65
+ return filtered;
66
+ };
67
+ const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, }) => {
68
+ const app = (0, express_1.default)();
69
+ app.set('query parser', 'extended');
70
+ app.use(express_1.default.json());
71
+ app.use((0, pino_http_1.default)({
72
+ logger: (0, logger_1.getLogger)(),
73
+ customLogLevel: (req, res) => {
74
+ if (res.statusCode >= 500) {
75
+ return 'error';
76
+ }
77
+ else if (res.statusCode >= 400) {
78
+ return 'warn';
79
+ }
80
+ return 'info';
81
+ },
82
+ customSuccessMessage: function (req, res) {
83
+ return `Request ${req.method} to ${req.url} completed with status ${res.statusCode}`;
84
+ },
85
+ customErrorMessage: function (req, res, err) {
86
+ return `Request ${req.method} to ${req.url} errored with status ${res.statusCode}`;
87
+ },
88
+ serializers: {
89
+ req: pino_1.default.stdSerializers.wrapRequestSerializer((req) => {
90
+ return {
91
+ ...req,
92
+ headers: redactHeaders(req.raw.headers),
93
+ };
94
+ }),
95
+ res: pino_1.default.stdSerializers.wrapResponseSerializer((res) => {
96
+ return {
97
+ ...res,
98
+ headers: redactHeaders(res.headers),
99
+ };
100
+ }),
101
+ },
102
+ }));
103
+ app.get('/health', async (req, res) => {
104
+ res.status(200).send('OK');
105
+ });
106
+ app.get('/', get);
107
+ app.post('/', post({ clientOptions, mcpOptions }));
108
+ app.delete('/', del);
109
+ return app;
110
+ };
111
+ exports.streamableHTTPApp = streamableHTTPApp;
112
+ const launchStreamableHTTPServer = async ({ mcpOptions, port, }) => {
113
+ const app = (0, exports.streamableHTTPApp)({ mcpOptions });
114
+ const server = app.listen(port);
115
+ const address = server.address();
116
+ const logger = (0, logger_1.getLogger)();
117
+ if (typeof address === 'string') {
118
+ logger.info(`MCP Server running on streamable HTTP at ${address}`);
119
+ }
120
+ else if (address !== null) {
121
+ logger.info(`MCP Server running on streamable HTTP on port ${address.port}`);
122
+ }
123
+ else {
124
+ logger.info(`MCP Server running on streamable HTTP on port ${port}`);
125
+ }
126
+ };
127
+ exports.launchStreamableHTTPServer = launchStreamableHTTPServer;
128
+ //# sourceMappingURL=http.js.map
package/http.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AAEnG,sDAA8B;AAC9B,gDAAwB;AACxB,0DAAiC;AACjC,oCAAoE;AACpE,wCAAqC;AAErC,wCAAuD;AAEvD,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,UAAU,EACV,GAAG,EACH,GAAG,GAMJ,EAA6B,EAAE;IAC9B,MAAM,eAAe,GAAG,IAAA,yBAAkB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,IAA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,EAAE,EAAE;IACH,MAAM,GAAG,GAAG,IAAA,yBAAiB,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;IAE3B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC,CAAC;AApBW,QAAA,0BAA0B,8BAoBrC"}
package/http.mjs ADDED
@@ -0,0 +1,120 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
3
+ import express from 'express';
4
+ import pino from 'pino';
5
+ import pinoHttp from 'pino-http';
6
+ import { getStainlessApiKey, parseClientAuthHeaders } from "./auth.mjs";
7
+ import { getLogger } from "./logger.mjs";
8
+ import { initMcpServer, newMcpServer } from "./server.mjs";
9
+ const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
10
+ const stainlessApiKey = getStainlessApiKey(req, mcpOptions);
11
+ const server = await newMcpServer(stainlessApiKey);
12
+ const authOptions = parseClientAuthHeaders(req, false);
13
+ await initMcpServer({
14
+ server: server,
15
+ mcpOptions: mcpOptions,
16
+ clientOptions: {
17
+ ...clientOptions,
18
+ ...authOptions,
19
+ },
20
+ stainlessApiKey: stainlessApiKey,
21
+ });
22
+ return server;
23
+ };
24
+ const post = (options) => async (req, res) => {
25
+ const server = await newServer({ ...options, req, res });
26
+ // If we return null, we already set the authorization error.
27
+ if (server === null)
28
+ return;
29
+ const transport = new StreamableHTTPServerTransport();
30
+ await server.connect(transport);
31
+ await transport.handleRequest(req, res, req.body);
32
+ };
33
+ const get = async (req, res) => {
34
+ res.status(405).json({
35
+ jsonrpc: '2.0',
36
+ error: {
37
+ code: -32000,
38
+ message: 'Method not supported',
39
+ },
40
+ });
41
+ };
42
+ const del = async (req, res) => {
43
+ res.status(405).json({
44
+ jsonrpc: '2.0',
45
+ error: {
46
+ code: -32000,
47
+ message: 'Method not supported',
48
+ },
49
+ });
50
+ };
51
+ const redactHeaders = (headers) => {
52
+ const hiddenHeaders = /auth|cookie|key|token/i;
53
+ const filtered = { ...headers };
54
+ Object.keys(filtered).forEach((key) => {
55
+ if (hiddenHeaders.test(key)) {
56
+ filtered[key] = '[REDACTED]';
57
+ }
58
+ });
59
+ return filtered;
60
+ };
61
+ export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, }) => {
62
+ const app = express();
63
+ app.set('query parser', 'extended');
64
+ app.use(express.json());
65
+ app.use(pinoHttp({
66
+ logger: getLogger(),
67
+ customLogLevel: (req, res) => {
68
+ if (res.statusCode >= 500) {
69
+ return 'error';
70
+ }
71
+ else if (res.statusCode >= 400) {
72
+ return 'warn';
73
+ }
74
+ return 'info';
75
+ },
76
+ customSuccessMessage: function (req, res) {
77
+ return `Request ${req.method} to ${req.url} completed with status ${res.statusCode}`;
78
+ },
79
+ customErrorMessage: function (req, res, err) {
80
+ return `Request ${req.method} to ${req.url} errored with status ${res.statusCode}`;
81
+ },
82
+ serializers: {
83
+ req: pino.stdSerializers.wrapRequestSerializer((req) => {
84
+ return {
85
+ ...req,
86
+ headers: redactHeaders(req.raw.headers),
87
+ };
88
+ }),
89
+ res: pino.stdSerializers.wrapResponseSerializer((res) => {
90
+ return {
91
+ ...res,
92
+ headers: redactHeaders(res.headers),
93
+ };
94
+ }),
95
+ },
96
+ }));
97
+ app.get('/health', async (req, res) => {
98
+ res.status(200).send('OK');
99
+ });
100
+ app.get('/', get);
101
+ app.post('/', post({ clientOptions, mcpOptions }));
102
+ app.delete('/', del);
103
+ return app;
104
+ };
105
+ export const launchStreamableHTTPServer = async ({ mcpOptions, port, }) => {
106
+ const app = streamableHTTPApp({ mcpOptions });
107
+ const server = app.listen(port);
108
+ const address = server.address();
109
+ const logger = getLogger();
110
+ if (typeof address === 'string') {
111
+ logger.info(`MCP Server running on streamable HTTP at ${address}`);
112
+ }
113
+ else if (address !== null) {
114
+ logger.info(`MCP Server running on streamable HTTP on port ${address.port}`);
115
+ }
116
+ else {
117
+ logger.info(`MCP Server running on streamable HTTP on port ${port}`);
118
+ }
119
+ };
120
+ //# sourceMappingURL=http.mjs.map
package/http.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAE3F,OAAO,MAAM,SAAS;OACtB,IAAI,MAAM,MAAM;OAChB,QAAQ,MAAM,WAAW;OACzB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE;OAC9C,EAAE,SAAS,EAAE;OAEb,EAAE,aAAa,EAAE,YAAY,EAAE;AAEtC,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,UAAU,EACV,GAAG,EACH,GAAG,GAMJ,EAA6B,EAAE;IAC9B,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,eAAe,CAAC,CAAC;IAEnD,MAAM,WAAW,GAAG,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAEvD,MAAM,aAAa,CAAC;QAClB,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,UAAU;QACtB,aAA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SAAS,EAAE,CAAC;IAE3B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC,CAAC"}
package/index.d.mts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
package/index.js ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const server_1 = require("./server.js");
5
+ const options_1 = require("./options.js");
6
+ const stdio_1 = require("./stdio.js");
7
+ const http_1 = require("./http.js");
8
+ const logger_1 = require("./logger.js");
9
+ async function main() {
10
+ const options = parseOptionsOrError();
11
+ (0, logger_1.configureLogger)({
12
+ level: options.debug ? 'debug' : 'info',
13
+ pretty: options.logFormat === 'pretty',
14
+ });
15
+ const selectedTools = await selectToolsOrError(options);
16
+ (0, logger_1.getLogger)().info({ tools: selectedTools.map((e) => e.tool.name) }, `MCP Server starting with ${selectedTools.length} tools`);
17
+ switch (options.transport) {
18
+ case 'stdio':
19
+ await (0, stdio_1.launchStdioServer)(options);
20
+ break;
21
+ case 'http':
22
+ await (0, http_1.launchStreamableHTTPServer)({
23
+ mcpOptions: options,
24
+ port: options.socket ?? options.port,
25
+ });
26
+ break;
27
+ }
28
+ }
29
+ if (require.main === module) {
30
+ main().catch((error) => {
31
+ // Logger might not be initialized yet
32
+ console.error('Fatal error in main()', error);
33
+ process.exit(1);
34
+ });
35
+ }
36
+ function parseOptionsOrError() {
37
+ try {
38
+ return (0, options_1.parseCLIOptions)();
39
+ }
40
+ catch (error) {
41
+ // Logger is initialized after options, so use console.error here
42
+ console.error('Error parsing options', error);
43
+ process.exit(1);
44
+ }
45
+ }
46
+ async function selectToolsOrError(options) {
47
+ try {
48
+ const includedTools = (0, server_1.selectTools)(options);
49
+ if (includedTools.length === 0) {
50
+ (0, logger_1.getLogger)().error('No tools match the provided filters');
51
+ process.exit(1);
52
+ }
53
+ return includedTools;
54
+ }
55
+ catch (error) {
56
+ (0, logger_1.getLogger)().error({ error }, 'Error filtering tools');
57
+ process.exit(1);
58
+ }
59
+ }
60
+ //# sourceMappingURL=index.js.map