@roarkanalytics/sdk-mcp 2.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +101 -0
  3. package/code-tool-types.d.mts +14 -0
  4. package/code-tool-types.d.mts.map +1 -0
  5. package/code-tool-types.d.ts +14 -0
  6. package/code-tool-types.d.ts.map +1 -0
  7. package/code-tool-types.js +4 -0
  8. package/code-tool-types.js.map +1 -0
  9. package/code-tool-types.mjs +3 -0
  10. package/code-tool-types.mjs.map +1 -0
  11. package/code-tool.d.mts +12 -0
  12. package/code-tool.d.mts.map +1 -0
  13. package/code-tool.d.ts +12 -0
  14. package/code-tool.d.ts.map +1 -0
  15. package/code-tool.js +96 -0
  16. package/code-tool.js.map +1 -0
  17. package/code-tool.mjs +93 -0
  18. package/code-tool.mjs.map +1 -0
  19. package/docs-search-tool.d.mts +51 -0
  20. package/docs-search-tool.d.mts.map +1 -0
  21. package/docs-search-tool.d.ts +51 -0
  22. package/docs-search-tool.d.ts.map +1 -0
  23. package/docs-search-tool.js +51 -0
  24. package/docs-search-tool.js.map +1 -0
  25. package/docs-search-tool.mjs +47 -0
  26. package/docs-search-tool.mjs.map +1 -0
  27. package/headers.d.mts +4 -0
  28. package/headers.d.mts.map +1 -0
  29. package/headers.d.ts +4 -0
  30. package/headers.d.ts.map +1 -0
  31. package/headers.js +25 -0
  32. package/headers.js.map +1 -0
  33. package/headers.mjs +21 -0
  34. package/headers.mjs.map +1 -0
  35. package/http.d.mts +14 -0
  36. package/http.d.mts.map +1 -0
  37. package/http.d.ts +14 -0
  38. package/http.d.ts.map +1 -0
  39. package/http.js +104 -0
  40. package/http.js.map +1 -0
  41. package/http.mjs +96 -0
  42. package/http.mjs.map +1 -0
  43. package/index.d.mts +3 -0
  44. package/index.d.mts.map +1 -0
  45. package/index.d.ts +3 -0
  46. package/index.d.ts.map +1 -0
  47. package/index.js +59 -0
  48. package/index.js.map +1 -0
  49. package/index.mjs +57 -0
  50. package/index.mjs.map +1 -0
  51. package/options.d.mts +12 -0
  52. package/options.d.mts.map +1 -0
  53. package/options.d.ts +12 -0
  54. package/options.d.ts.map +1 -0
  55. package/options.js +74 -0
  56. package/options.js.map +1 -0
  57. package/options.mjs +67 -0
  58. package/options.mjs.map +1 -0
  59. package/package.json +67 -0
  60. package/server.d.mts +30 -0
  61. package/server.d.mts.map +1 -0
  62. package/server.d.ts +30 -0
  63. package/server.d.ts.map +1 -0
  64. package/server.js +120 -0
  65. package/server.js.map +1 -0
  66. package/server.mjs +107 -0
  67. package/server.mjs.map +1 -0
  68. package/src/code-tool-types.ts +16 -0
  69. package/src/code-tool.ts +111 -0
  70. package/src/docs-search-tool.ts +59 -0
  71. package/src/headers.ts +27 -0
  72. package/src/http.ts +127 -0
  73. package/src/index.ts +65 -0
  74. package/src/options.ts +95 -0
  75. package/src/server.ts +147 -0
  76. package/src/stdio.ts +12 -0
  77. package/src/tsconfig.json +11 -0
  78. package/src/types.ts +115 -0
  79. package/stdio.d.mts +2 -0
  80. package/stdio.d.mts.map +1 -0
  81. package/stdio.d.ts +2 -0
  82. package/stdio.d.ts.map +1 -0
  83. package/stdio.js +14 -0
  84. package/stdio.js.map +1 -0
  85. package/stdio.mjs +10 -0
  86. package/stdio.mjs.map +1 -0
  87. package/types.d.mts +52 -0
  88. package/types.d.mts.map +1 -0
  89. package/types.d.ts +52 -0
  90. package/types.d.ts.map +1 -0
  91. package/types.js +58 -0
  92. package/types.js.map +1 -0
  93. package/types.mjs +53 -0
  94. package/types.mjs.map +1 -0
package/options.d.mts ADDED
@@ -0,0 +1,12 @@
1
+ export type CLIOptions = McpOptions & {
2
+ debug: boolean;
3
+ transport: 'stdio' | 'http';
4
+ port: number | undefined;
5
+ socket: string | undefined;
6
+ };
7
+ export type McpOptions = {
8
+ includeDocsTools?: boolean | undefined;
9
+ };
10
+ export declare function parseCLIOptions(): CLIOptions;
11
+ export declare function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions;
12
+ //# sourceMappingURL=options.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.mts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CAiD5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
package/options.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export type CLIOptions = McpOptions & {
2
+ debug: boolean;
3
+ transport: 'stdio' | 'http';
4
+ port: number | undefined;
5
+ socket: string | undefined;
6
+ };
7
+ export type McpOptions = {
8
+ includeDocsTools?: boolean | undefined;
9
+ };
10
+ export declare function parseCLIOptions(): CLIOptions;
11
+ export declare function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions;
12
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CAiD5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
package/options.js ADDED
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseCLIOptions = parseCLIOptions;
7
+ exports.parseQueryOptions = parseQueryOptions;
8
+ const qs_1 = __importDefault(require("qs"));
9
+ const yargs_1 = __importDefault(require("yargs"));
10
+ const helpers_1 = require("yargs/helpers");
11
+ const zod_1 = __importDefault(require("zod"));
12
+ function parseCLIOptions() {
13
+ const opts = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
14
+ .option('debug', { type: 'boolean', description: 'Enable debug logging' })
15
+ .option('no-tools', {
16
+ type: 'string',
17
+ array: true,
18
+ choices: ['code', 'docs'],
19
+ description: 'Tools to explicitly disable',
20
+ })
21
+ .option('port', {
22
+ type: 'number',
23
+ default: 3000,
24
+ description: 'Port to serve on if using http transport',
25
+ })
26
+ .option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
27
+ .option('tools', {
28
+ type: 'string',
29
+ array: true,
30
+ choices: ['code', 'docs'],
31
+ description: 'Tools to explicitly enable',
32
+ })
33
+ .option('transport', {
34
+ type: 'string',
35
+ choices: ['stdio', 'http'],
36
+ default: 'stdio',
37
+ description: 'What transport to use; stdio for local servers or http for remote servers',
38
+ })
39
+ .env('MCP_SERVER')
40
+ .version(true)
41
+ .help();
42
+ const argv = opts.parseSync();
43
+ const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
44
+ : argv.tools?.includes(toolType) ? true
45
+ : undefined;
46
+ const includeDocsTools = shouldIncludeToolType('docs');
47
+ const transport = argv.transport;
48
+ return {
49
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
50
+ debug: !!argv.debug,
51
+ transport,
52
+ port: argv.port,
53
+ socket: argv.socket,
54
+ };
55
+ }
56
+ const coerceArray = (zodType) => zod_1.default.preprocess((val) => Array.isArray(val) ? val
57
+ : val ? [val]
58
+ : val, zod_1.default.array(zodType).optional());
59
+ const QueryOptions = zod_1.default.object({
60
+ tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
61
+ no_tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
62
+ tool: coerceArray(zod_1.default.string()).describe('Include tools matching the specified names'),
63
+ });
64
+ function parseQueryOptions(defaultOptions, query) {
65
+ const queryObject = typeof query === 'string' ? qs_1.default.parse(query) : query;
66
+ const queryOptions = QueryOptions.parse(queryObject);
67
+ let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
68
+ : queryOptions.tools?.includes('docs') ? true
69
+ : defaultOptions.includeDocsTools;
70
+ return {
71
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
72
+ };
73
+ }
74
+ //# 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":";;;;;AAgBA,0CAiDC;AAiBD,8CAYC;AA9FD,4CAAoB;AACpB,kDAA0B;AAC1B,2CAAwC;AACxC,8CAAoB;AAapB,SAAgB,eAAe;IAC7B,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;SACzE,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,C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AC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC"}
package/options.mjs ADDED
@@ -0,0 +1,67 @@
1
+ import qs from 'qs';
2
+ import yargs from 'yargs';
3
+ import { hideBin } from 'yargs/helpers';
4
+ import z from 'zod';
5
+ export function parseCLIOptions() {
6
+ const opts = yargs(hideBin(process.argv))
7
+ .option('debug', { type: 'boolean', description: 'Enable debug logging' })
8
+ .option('no-tools', {
9
+ type: 'string',
10
+ array: true,
11
+ choices: ['code', 'docs'],
12
+ description: 'Tools to explicitly disable',
13
+ })
14
+ .option('port', {
15
+ type: 'number',
16
+ default: 3000,
17
+ description: 'Port to serve on if using http transport',
18
+ })
19
+ .option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
20
+ .option('tools', {
21
+ type: 'string',
22
+ array: true,
23
+ choices: ['code', 'docs'],
24
+ description: 'Tools to explicitly enable',
25
+ })
26
+ .option('transport', {
27
+ type: 'string',
28
+ choices: ['stdio', 'http'],
29
+ default: 'stdio',
30
+ description: 'What transport to use; stdio for local servers or http for remote servers',
31
+ })
32
+ .env('MCP_SERVER')
33
+ .version(true)
34
+ .help();
35
+ const argv = opts.parseSync();
36
+ const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
37
+ : argv.tools?.includes(toolType) ? true
38
+ : undefined;
39
+ const includeDocsTools = shouldIncludeToolType('docs');
40
+ const transport = argv.transport;
41
+ return {
42
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
43
+ debug: !!argv.debug,
44
+ transport,
45
+ port: argv.port,
46
+ socket: argv.socket,
47
+ };
48
+ }
49
+ const coerceArray = (zodType) => z.preprocess((val) => Array.isArray(val) ? val
50
+ : val ? [val]
51
+ : val, z.array(zodType).optional());
52
+ const QueryOptions = z.object({
53
+ tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
54
+ no_tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
55
+ tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
56
+ });
57
+ export function parseQueryOptions(defaultOptions, query) {
58
+ const queryObject = typeof query === 'string' ? qs.parse(query) : query;
59
+ const queryOptions = QueryOptions.parse(queryObject);
60
+ let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
61
+ : queryOptions.tools?.includes('docs') ? true
62
+ : defaultOptions.includeDocsTools;
63
+ return {
64
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
65
+ };
66
+ }
67
+ //# sourceMappingURL=options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;AAanB,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;SACzE,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,6BAA6B;KAC3C,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,0CAA0C;KACxD,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,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,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@roarkanalytics/sdk-mcp",
3
+ "version": "2.19.1",
4
+ "description": "The official MCP Server for the Roark API",
5
+ "author": "Roark <james@roark.ai>",
6
+ "types": "./index.d.ts",
7
+ "main": "./index.js",
8
+ "type": "commonjs",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/roarkhq/sdk-roark-analytics-node.git",
12
+ "directory": "packages/mcp-server"
13
+ },
14
+ "homepage": "https://github.com/roarkhq/sdk-roark-analytics-node/tree/main/packages/mcp-server#readme",
15
+ "license": "Apache-2.0",
16
+ "packageManager": "yarn@1.22.22",
17
+ "private": false,
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "test": "jest",
23
+ "build": "bash ./build",
24
+ "format": "prettier --write --cache --cache-strategy metadata . !dist",
25
+ "tsn": "ts-node -r tsconfig-paths/register",
26
+ "lint": "eslint --ext ts,js .",
27
+ "fix": "eslint --fix --ext ts,js ."
28
+ },
29
+ "dependencies": {
30
+ "@roarkanalytics/sdk": "^2.19.1",
31
+ "@cloudflare/cabidela": "^0.2.4",
32
+ "@modelcontextprotocol/sdk": "^1.25.2",
33
+ "@valtown/deno-http-worker": "^0.0.21",
34
+ "cookie-parser": "^1.4.6",
35
+ "cors": "^2.8.5",
36
+ "express": "^5.1.0",
37
+ "fuse.js": "^7.1.0",
38
+ "jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.8/jq-web.tar.gz",
39
+ "morgan": "^1.10.0",
40
+ "morgan-body": "^2.6.9",
41
+ "qs": "^6.14.1",
42
+ "typescript": "5.8.3",
43
+ "yargs": "^17.7.2",
44
+ "zod": "^3.25.20",
45
+ "zod-to-json-schema": "^3.24.5",
46
+ "zod-validation-error": "^4.0.1"
47
+ },
48
+ "bin": {
49
+ "mcp-server": "./index.js"
50
+ },
51
+ "imports": {
52
+ "@roarkanalytics/sdk-mcp": ".",
53
+ "@roarkanalytics/sdk-mcp/*": "./src/*"
54
+ },
55
+ "exports": {
56
+ ".": {
57
+ "require": "./index.js",
58
+ "default": "./index.mjs"
59
+ },
60
+ "./*.mjs": "./*.mjs",
61
+ "./*.js": "./*.js",
62
+ "./*": {
63
+ "require": "./*.js",
64
+ "default": "./*.mjs"
65
+ }
66
+ }
67
+ }
package/server.d.mts ADDED
@@ -0,0 +1,30 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { ClientOptions } from '@roarkanalytics/sdk';
4
+ import Roark from '@roarkanalytics/sdk';
5
+ import { McpOptions } from "./options.mjs";
6
+ import { HandlerFunction, McpTool } from "./types.mjs";
7
+ export { McpOptions } from "./options.mjs";
8
+ export { ClientOptions } from '@roarkanalytics/sdk';
9
+ export declare const newMcpServer: () => 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
+ }): Promise<void>;
19
+ /**
20
+ * Selects the tools to include in the MCP Server based on the provided options.
21
+ */
22
+ export declare function selectTools(options?: McpOptions): McpTool[];
23
+ /**
24
+ * Runs the provided handler with the given client and arguments.
25
+ */
26
+ export declare function executeHandler(handler: HandlerFunction, client: Roark, args: Record<string, unknown> | undefined): Promise<import("./types").ToolCallResult>;
27
+ export declare const readEnv: (env: string) => string | undefined;
28
+ export declare const readEnvOrError: (env: string) => string;
29
+ export declare const requireValue: <T>(value: T | undefined, description: string) => T;
30
+ //# 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;OAE5D,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAC5C,KAAK,MAAM,qBAAqB;OAGhC,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAsCnD,eAAO,MAAM,YAAY,0BAUtB,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;CACzB,iBA6BA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAM3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,KAAK,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,CAK3E,CAAC"}
package/server.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { ClientOptions } from '@roarkanalytics/sdk';
4
+ import Roark from '@roarkanalytics/sdk';
5
+ import { McpOptions } from "./options.js";
6
+ import { HandlerFunction, McpTool } from "./types.js";
7
+ export { McpOptions } from "./options.js";
8
+ export { ClientOptions } from '@roarkanalytics/sdk';
9
+ export declare const newMcpServer: () => 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
+ }): Promise<void>;
19
+ /**
20
+ * Selects the tools to include in the MCP Server based on the provided options.
21
+ */
22
+ export declare function selectTools(options?: McpOptions): McpTool[];
23
+ /**
24
+ * Runs the provided handler with the given client and arguments.
25
+ */
26
+ export declare function executeHandler(handler: HandlerFunction, client: Roark, args: Record<string, unknown> | undefined): Promise<import("./types").ToolCallResult>;
27
+ export declare const readEnv: (env: string) => string | undefined;
28
+ export declare const readEnvOrError: (env: string) => string;
29
+ export declare const requireValue: <T>(value: T | undefined, description: string) => T;
30
+ //# 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;OAE5D,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAC5C,KAAK,MAAM,qBAAqB;OAGhC,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAsCnD,eAAO,MAAM,YAAY,0BAUtB,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;CACzB,iBA6BA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAM3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,KAAK,EACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,CAK3E,CAAC"}
package/server.js ADDED
@@ -0,0 +1,120 @@
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.requireValue = exports.readEnvOrError = exports.readEnv = exports.newMcpServer = void 0;
8
+ exports.initMcpServer = initMcpServer;
9
+ exports.selectTools = selectTools;
10
+ exports.executeHandler = executeHandler;
11
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
12
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
13
+ const sdk_1 = __importDefault(require("@roarkanalytics/sdk"));
14
+ const code_tool_1 = require("./code-tool.js");
15
+ const docs_search_tool_1 = __importDefault(require("./docs-search-tool.js"));
16
+ async function getInstructions() {
17
+ // This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
18
+ const stainlessAPIKey = (0, exports.readEnv)('STAINLESS_API_KEY');
19
+ const response = await fetch((0, exports.readEnv)('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/roark-analytics', {
20
+ method: 'GET',
21
+ headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
22
+ });
23
+ let instructions;
24
+ if (!response.ok) {
25
+ console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
26
+ instructions = `
27
+ This is the roark-analytics MCP server. You will use Code Mode to help the user perform
28
+ actions. You can use search_docs tool to learn about how to take action with this server. Then,
29
+ you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
30
+ thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
31
+ block: it can be as long as you need to get the job done!
32
+ `;
33
+ }
34
+ instructions ??= (await response.json()).instructions;
35
+ instructions = `
36
+ The current time in Unix timestamps is ${Date.now()}.
37
+
38
+ ${instructions}
39
+ `;
40
+ return instructions;
41
+ }
42
+ const newMcpServer = async () => new mcp_js_1.McpServer({
43
+ name: 'roarkanalytics_sdk_api',
44
+ version: '2.19.1',
45
+ }, {
46
+ instructions: await getInstructions(),
47
+ capabilities: { tools: {}, logging: {} },
48
+ });
49
+ exports.newMcpServer = newMcpServer;
50
+ /**
51
+ * Initializes the provided MCP Server with the given tools and handlers.
52
+ * If not provided, the default client, tools and handlers will be used.
53
+ */
54
+ async function initMcpServer(params) {
55
+ const server = params.server instanceof mcp_js_1.McpServer ? params.server.server : params.server;
56
+ const client = new sdk_1.default({
57
+ ...params.clientOptions,
58
+ defaultHeaders: {
59
+ ...params.clientOptions?.defaultHeaders,
60
+ 'X-Stainless-MCP': 'true',
61
+ },
62
+ });
63
+ const providedTools = selectTools(params.mcpOptions);
64
+ const toolMap = Object.fromEntries(providedTools.map((mcpTool) => [mcpTool.tool.name, mcpTool]));
65
+ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
66
+ return {
67
+ tools: providedTools.map((mcpTool) => mcpTool.tool),
68
+ };
69
+ });
70
+ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
71
+ const { name, arguments: args } = request.params;
72
+ const mcpTool = toolMap[name];
73
+ if (!mcpTool) {
74
+ throw new Error(`Unknown tool: ${name}`);
75
+ }
76
+ return executeHandler(mcpTool.handler, client, args);
77
+ });
78
+ }
79
+ /**
80
+ * Selects the tools to include in the MCP Server based on the provided options.
81
+ */
82
+ function selectTools(options) {
83
+ const includedTools = [(0, code_tool_1.codeTool)()];
84
+ if (options?.includeDocsTools ?? true) {
85
+ includedTools.push(docs_search_tool_1.default);
86
+ }
87
+ return includedTools;
88
+ }
89
+ /**
90
+ * Runs the provided handler with the given client and arguments.
91
+ */
92
+ async function executeHandler(handler, client, args) {
93
+ return await handler(client, args || {});
94
+ }
95
+ const readEnv = (env) => {
96
+ if (typeof globalThis.process !== 'undefined') {
97
+ return globalThis.process.env?.[env]?.trim();
98
+ }
99
+ else if (typeof globalThis.Deno !== 'undefined') {
100
+ return globalThis.Deno.env?.get?.(env)?.trim();
101
+ }
102
+ return;
103
+ };
104
+ exports.readEnv = readEnv;
105
+ const readEnvOrError = (env) => {
106
+ let envValue = (0, exports.readEnv)(env);
107
+ if (envValue === undefined) {
108
+ throw new Error(`Environment variable ${env} is not set`);
109
+ }
110
+ return envValue;
111
+ };
112
+ exports.readEnvOrError = readEnvOrError;
113
+ const requireValue = (value, description) => {
114
+ if (value === undefined) {
115
+ throw new Error(`Missing required value: ${description}`);
116
+ }
117
+ return value;
118
+ };
119
+ exports.requireValue = requireValue;
120
+ //# sourceMappingURL=server.js.map
package/server.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAmEtF,sCAiCC;AAKD,kCAMC;AAKD,wCAMC;AAvHD,oEAAoE;AACpE,iEAAmG;AAEnG,8DAAwC;AACxC,8CAAuC;AACvC,6EAAgD;AAOhD,KAAK,UAAU,eAAe;IAC5B,0GAA0G;IAC1G,MAAM,eAAe,GAAG,IAAA,eAAO,EAAC,mBAAmB,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,IAAA,eAAO,EAAC,4BAA4B,CAAC,IAAI,+DAA+D,EACxG;QACE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,EAAE,GAAG,CAAC,eAAe,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,CA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AAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAPW,QAAA,OAAO,WAOlB;AAEK,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,IAAA,eAAO,EAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEK,MAAM,YAAY,GAAG,CAAI,KAAoB,EAAE,WAAmB,EAAK,EAAE;IAC9E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB"}
package/server.mjs ADDED
@@ -0,0 +1,107 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
+ import Roark from '@roarkanalytics/sdk';
5
+ import { codeTool } from "./code-tool.mjs";
6
+ import docsSearchTool from "./docs-search-tool.mjs";
7
+ async function getInstructions() {
8
+ // This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
9
+ const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
10
+ const response = await fetch(readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/roark-analytics', {
11
+ method: 'GET',
12
+ headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
13
+ });
14
+ let instructions;
15
+ if (!response.ok) {
16
+ console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
17
+ instructions = `
18
+ This is the roark-analytics MCP server. You will use Code Mode to help the user perform
19
+ actions. You can use search_docs tool to learn about how to take action with this server. Then,
20
+ you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
21
+ thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
22
+ block: it can be as long as you need to get the job done!
23
+ `;
24
+ }
25
+ instructions ??= (await response.json()).instructions;
26
+ instructions = `
27
+ The current time in Unix timestamps is ${Date.now()}.
28
+
29
+ ${instructions}
30
+ `;
31
+ return instructions;
32
+ }
33
+ export const newMcpServer = async () => new McpServer({
34
+ name: 'roarkanalytics_sdk_api',
35
+ version: '2.19.1',
36
+ }, {
37
+ instructions: await getInstructions(),
38
+ capabilities: { tools: {}, logging: {} },
39
+ });
40
+ /**
41
+ * Initializes the provided MCP Server with the given tools and handlers.
42
+ * If not provided, the default client, tools and handlers will be used.
43
+ */
44
+ export async function initMcpServer(params) {
45
+ const server = params.server instanceof McpServer ? params.server.server : params.server;
46
+ const client = new Roark({
47
+ ...params.clientOptions,
48
+ defaultHeaders: {
49
+ ...params.clientOptions?.defaultHeaders,
50
+ 'X-Stainless-MCP': 'true',
51
+ },
52
+ });
53
+ const providedTools = selectTools(params.mcpOptions);
54
+ const toolMap = Object.fromEntries(providedTools.map((mcpTool) => [mcpTool.tool.name, mcpTool]));
55
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
56
+ return {
57
+ tools: providedTools.map((mcpTool) => mcpTool.tool),
58
+ };
59
+ });
60
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
61
+ const { name, arguments: args } = request.params;
62
+ const mcpTool = toolMap[name];
63
+ if (!mcpTool) {
64
+ throw new Error(`Unknown tool: ${name}`);
65
+ }
66
+ return executeHandler(mcpTool.handler, client, args);
67
+ });
68
+ }
69
+ /**
70
+ * Selects the tools to include in the MCP Server based on the provided options.
71
+ */
72
+ export function selectTools(options) {
73
+ const includedTools = [codeTool()];
74
+ if (options?.includeDocsTools ?? true) {
75
+ includedTools.push(docsSearchTool);
76
+ }
77
+ return includedTools;
78
+ }
79
+ /**
80
+ * Runs the provided handler with the given client and arguments.
81
+ */
82
+ export async function executeHandler(handler, client, args) {
83
+ return await handler(client, args || {});
84
+ }
85
+ export const readEnv = (env) => {
86
+ if (typeof globalThis.process !== 'undefined') {
87
+ return globalThis.process.env?.[env]?.trim();
88
+ }
89
+ else if (typeof globalThis.Deno !== 'undefined') {
90
+ return globalThis.Deno.env?.get?.(env)?.trim();
91
+ }
92
+ return;
93
+ };
94
+ export const readEnvOrError = (env) => {
95
+ let envValue = readEnv(env);
96
+ if (envValue === undefined) {
97
+ throw new Error(`Environment variable ${env} is not set`);
98
+ }
99
+ return envValue;
100
+ };
101
+ export const requireValue = (value, description) => {
102
+ if (value === undefined) {
103
+ throw new Error(`Missing required value: ${description}`);
104
+ }
105
+ return value;
106
+ };
107
+ //# sourceMappingURL=server.mjs.map
package/server.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC;OAE3F,KAAK,MAAM,qBAAqB;OAChC,EAAE,QAAQ,EAAE;OACZ,cAAc;AAOrB,KAAK,UAAU,eAAe;IAC5B,0GAA0G;IAC1G,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,KAA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AAM,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAsB,EAAE;IACzD,IAAI,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,KAAoB,EAAE,WAAmB,EAAK,EAAE;IAC9E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { ClientOptions } from '@roarkanalytics/sdk';
4
+
5
+ export type WorkerInput = {
6
+ project_name: string;
7
+ code: string;
8
+ client_opts: ClientOptions;
9
+ intent?: string | undefined;
10
+ };
11
+ export type WorkerOutput = {
12
+ is_error: boolean;
13
+ result: unknown | null;
14
+ log_lines: string[];
15
+ err_lines: string[];
16
+ };