@nirvana-labs/nirvana-mcp 1.26.1 → 1.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/code-tool.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Endpoint } from "./tools/types.mjs";
1
+ import { Metadata, ToolCallResult } from "./tools/types.mjs";
2
2
  /**
3
3
  * A tool that runs code against a copy of the SDK.
4
4
  *
@@ -8,5 +8,47 @@ import { Endpoint } from "./tools/types.mjs";
8
8
  *
9
9
  * @param endpoints - The endpoints to include in the list.
10
10
  */
11
- export declare function codeTool(): Promise<Endpoint>;
11
+ export declare function codeTool(): Promise<{
12
+ metadata: Metadata;
13
+ tool: {
14
+ inputSchema: {
15
+ [x: string]: unknown;
16
+ type: "object";
17
+ properties?: {
18
+ [x: string]: object;
19
+ } | undefined;
20
+ required?: string[] | undefined;
21
+ };
22
+ name: string;
23
+ description?: string | undefined;
24
+ outputSchema?: {
25
+ [x: string]: unknown;
26
+ type: "object";
27
+ properties?: {
28
+ [x: string]: object;
29
+ } | undefined;
30
+ required?: string[] | undefined;
31
+ } | undefined;
32
+ annotations?: {
33
+ title?: string | undefined;
34
+ readOnlyHint?: boolean | undefined;
35
+ destructiveHint?: boolean | undefined;
36
+ idempotentHint?: boolean | undefined;
37
+ openWorldHint?: boolean | undefined;
38
+ } | undefined;
39
+ execution?: {
40
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
41
+ } | undefined;
42
+ _meta?: {
43
+ [x: string]: unknown;
44
+ } | undefined;
45
+ icons?: {
46
+ src: string;
47
+ mimeType?: string | undefined;
48
+ sizes?: string[] | undefined;
49
+ }[] | undefined;
50
+ title?: string | undefined;
51
+ };
52
+ handler: (_: unknown, args: any) => Promise<ToolCallResult>;
53
+ }>;
12
54
  //# sourceMappingURL=code-tool.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAKO,EAAgB,QAAQ,EAA4B;AAM3D;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CAyJlD"}
1
+ {"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAE,cAAc,EAAuB;AAIxD;;;;;;;;GAQG;AACH,wBAAsB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQF,OAAO,QAAQ,GAAG,KAAG,OAAO,CAAC,cAAc,CAAC;GAkCvE"}
package/code-tool.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Endpoint } from "./tools/types.js";
1
+ import { Metadata, ToolCallResult } from "./tools/types.js";
2
2
  /**
3
3
  * A tool that runs code against a copy of the SDK.
4
4
  *
@@ -8,5 +8,47 @@ import { Endpoint } from "./tools/types.js";
8
8
  *
9
9
  * @param endpoints - The endpoints to include in the list.
10
10
  */
11
- export declare function codeTool(): Promise<Endpoint>;
11
+ export declare function codeTool(): Promise<{
12
+ metadata: Metadata;
13
+ tool: {
14
+ inputSchema: {
15
+ [x: string]: unknown;
16
+ type: "object";
17
+ properties?: {
18
+ [x: string]: object;
19
+ } | undefined;
20
+ required?: string[] | undefined;
21
+ };
22
+ name: string;
23
+ description?: string | undefined;
24
+ outputSchema?: {
25
+ [x: string]: unknown;
26
+ type: "object";
27
+ properties?: {
28
+ [x: string]: object;
29
+ } | undefined;
30
+ required?: string[] | undefined;
31
+ } | undefined;
32
+ annotations?: {
33
+ title?: string | undefined;
34
+ readOnlyHint?: boolean | undefined;
35
+ destructiveHint?: boolean | undefined;
36
+ idempotentHint?: boolean | undefined;
37
+ openWorldHint?: boolean | undefined;
38
+ } | undefined;
39
+ execution?: {
40
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
41
+ } | undefined;
42
+ _meta?: {
43
+ [x: string]: unknown;
44
+ } | undefined;
45
+ icons?: {
46
+ src: string;
47
+ mimeType?: string | undefined;
48
+ sizes?: string[] | undefined;
49
+ }[] | undefined;
50
+ title?: string | undefined;
51
+ };
52
+ handler: (_: unknown, args: any) => Promise<ToolCallResult>;
53
+ }>;
12
54
  //# sourceMappingURL=code-tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAKO,EAAgB,QAAQ,EAA4B;AAM3D;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CAyJlD"}
1
+ {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAE,cAAc,EAAuB;AAIxD;;;;;;;;GAQG;AACH,wBAAsB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQF,OAAO,QAAQ,GAAG,KAAG,OAAO,CAAC,cAAc,CAAC;GAkCvE"}
package/code-tool.js CHANGED
@@ -1,45 +1,9 @@
1
1
  "use strict";
2
2
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
3
  Object.defineProperty(exports, "__esModule", { value: true });
40
4
  exports.codeTool = codeTool;
41
- const node_path_1 = __importDefault(require("node:path"));
42
- const node_url_1 = __importDefault(require("node:url"));
5
+ const types_1 = require("./tools/types.js");
6
+ const server_1 = require("./server.js");
43
7
  /**
44
8
  * A tool that runs code against a copy of the SDK.
45
9
  *
@@ -53,126 +17,31 @@ async function codeTool() {
53
17
  const metadata = { resource: 'all', operation: 'write', tags: [] };
54
18
  const tool = {
55
19
  name: 'execute',
56
- description: 'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client named "client", and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
20
+ description: 'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
57
21
  inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
58
22
  };
59
- // Import dynamically to avoid failing at import time in cases where the environment is not well-supported.
60
- const { newDenoHTTPWorker } = await Promise.resolve().then(() => __importStar(require('@valtown/deno-http-worker')));
61
- const { workerPath } = await Promise.resolve().then(() => __importStar(require('./code-tool-paths.cjs')));
62
- const handler = async (client, args) => {
63
- const baseURLHostname = new URL(client.baseURL).hostname;
64
- const { code } = args;
65
- const allowRead = [
66
- 'code-tool-worker.mjs',
67
- `${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
68
- node_path_1.default.resolve(node_path_1.default.dirname(workerPath), '..'),
69
- ].join(',');
70
- const worker = await newDenoHTTPWorker(node_url_1.default.pathToFileURL(workerPath), {
71
- runFlags: [
72
- `--node-modules-dir=manual`,
73
- `--allow-read=${allowRead}`,
74
- `--allow-net=${baseURLHostname}`,
75
- // Allow environment variables because instantiating the client will try to read from them,
76
- // even though they are not set.
77
- '--allow-env',
78
- ],
79
- printOutput: true,
80
- spawnOptions: {
81
- cwd: node_path_1.default.dirname(workerPath),
23
+ const handler = async (_, args) => {
24
+ const code = args.code;
25
+ // this is not required, but passing a Stainless API key for the matching project_name
26
+ // will allow you to run code-mode queries against non-published versions of your SDK.
27
+ const stainlessAPIKey = (0, server_1.readEnv)('STAINLESS_API_KEY');
28
+ const codeModeEndpoint = (0, server_1.readEnv)('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
29
+ const res = await fetch(codeModeEndpoint, {
30
+ method: 'POST',
31
+ headers: {
32
+ ...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
33
+ 'Content-Type': 'application/json',
34
+ client_envs: JSON.stringify({ NIRVANA_LABS_API_KEY: (0, server_1.readEnv)('NIRVANA_LABS_API_KEY') }),
82
35
  },
36
+ body: JSON.stringify({
37
+ project_name: 'nirvana',
38
+ code,
39
+ }),
83
40
  });
84
- try {
85
- const resp = await new Promise((resolve, reject) => {
86
- worker.addEventListener('exit', (exitCode) => {
87
- reject(new Error(`Worker exited with code ${exitCode}`));
88
- });
89
- const opts = {
90
- baseURL: client.baseURL,
91
- apiKey: client.apiKey,
92
- defaultHeaders: {
93
- 'X-Stainless-MCP': 'true',
94
- },
95
- };
96
- const req = worker.request('http://localhost', {
97
- headers: {
98
- 'content-type': 'application/json',
99
- },
100
- method: 'POST',
101
- }, (resp) => {
102
- const body = [];
103
- resp.on('error', (err) => {
104
- reject(err);
105
- });
106
- resp.on('data', (chunk) => {
107
- body.push(chunk);
108
- });
109
- resp.on('end', () => {
110
- resolve(new Response(Buffer.concat(body).toString(), {
111
- status: resp.statusCode ?? 200,
112
- headers: resp.headers,
113
- }));
114
- });
115
- });
116
- const body = JSON.stringify({
117
- opts,
118
- code,
119
- });
120
- req.write(body, (err) => {
121
- if (err != null) {
122
- reject(err);
123
- }
124
- });
125
- req.end();
126
- });
127
- if (resp.status === 200) {
128
- const { result, logLines, errLines } = (await resp.json());
129
- const returnOutput = result == null ? null : ({
130
- type: 'text',
131
- text: typeof result === 'string' ? result : JSON.stringify(result),
132
- });
133
- const logOutput = logLines.length === 0 ?
134
- null
135
- : {
136
- type: 'text',
137
- text: logLines.join('\n'),
138
- };
139
- const errOutput = errLines.length === 0 ?
140
- null
141
- : {
142
- type: 'text',
143
- text: 'Error output:\n' + errLines.join('\n'),
144
- };
145
- return {
146
- content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
147
- };
148
- }
149
- else {
150
- const { message, logLines, errLines } = (await resp.json());
151
- const messageOutput = message == null ? null : ({
152
- type: 'text',
153
- text: message,
154
- });
155
- const logOutput = logLines.length === 0 ?
156
- null
157
- : {
158
- type: 'text',
159
- text: logLines.join('\n'),
160
- };
161
- const errOutput = errLines.length === 0 ?
162
- null
163
- : {
164
- type: 'text',
165
- text: 'Error output:\n' + errLines.join('\n'),
166
- };
167
- return {
168
- content: [messageOutput, logOutput, errOutput].filter((block) => block !== null),
169
- isError: true,
170
- };
171
- }
172
- }
173
- finally {
174
- worker.terminate();
41
+ if (!res.ok) {
42
+ throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
175
43
  }
44
+ return (0, types_1.asTextContentResult)((await res.json()));
176
45
  };
177
46
  return { metadata, tool, handler };
178
47
  }
package/code-tool.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBtF,4BAyJC;AA3KD,0DAA6B;AAC7B,wDAA2B;AAQ3B;;;;;;;;GAQG;AACI,KAAK,UAAU,QAAQ;IAC5B,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EACT,6iCAA6iC;QAC/iC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IAEF,2GAA2G;IAC3G,MAAM,EAAE,iBAAiB,EAAE,GAAG,wDAAa,2BAA2B,GAAC,CAAC;IACxE,MAAM,EAAE,UAAU,EAAE,GAAG,wDAAa,uBAAuB,GAAC,CAAC;IAE7D,MAAM,OAAO,GAAG,KAAK,EAAE,MAAmB,EAAE,IAAa,EAA2B,EAAE;QACpF,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,MAAM,C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ACtF,sFAAsF;QACtF,MAAM,eAAe,GAAG,IAAA,gBAAO,EAAC,mBAAmB,CAAC,CAAC;QACrD,MAAM,gBAAgB,GACpB,IAAA,gBAAO,EAAC,wBAAwB,CAAC,IAAI,4CAA4C,CAAC;QAEpF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,GAAG,CAAC,eAAe,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;gBAC1D,cAAc,EAAE,kBAAkB;gBAClC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,oBAAoB,EAAE,IAAA,gBAAO,EAAC,sBAAsB,CAAC,EAAE,CAAC;aACvF;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,YAAY,EAAE,SAAS;gBACvB,IAAI;aACL,CAAC;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,CAAC,MAAM,KACX,GAAG,CAAC,UACN,4DAA4D,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,CAC/E,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,2BAAmB,EAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAkB,CAAC,CAAC;IAClE,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
package/code-tool.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
- import path from 'node:path';
3
- import url from 'node:url';
2
+ import { asTextContentResult } from "./tools/types.mjs";
3
+ import { readEnv } from "./server.mjs";
4
4
  /**
5
5
  * A tool that runs code against a copy of the SDK.
6
6
  *
@@ -14,126 +14,31 @@ export async function codeTool() {
14
14
  const metadata = { resource: 'all', operation: 'write', tags: [] };
15
15
  const tool = {
16
16
  name: 'execute',
17
- description: 'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client named "client", and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
17
+ description: 'Runs JavaScript code to interact with the API.\n\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.\nWrite code within this template:\n\n```\nasync function run(client) {\n // Fill this out\n}\n```\n\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
18
18
  inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
19
19
  };
20
- // Import dynamically to avoid failing at import time in cases where the environment is not well-supported.
21
- const { newDenoHTTPWorker } = await import('@valtown/deno-http-worker');
22
- const { workerPath } = await import('./code-tool-paths.cjs');
23
- const handler = async (client, args) => {
24
- const baseURLHostname = new URL(client.baseURL).hostname;
25
- const { code } = args;
26
- const allowRead = [
27
- 'code-tool-worker.mjs',
28
- `${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
29
- path.resolve(path.dirname(workerPath), '..'),
30
- ].join(',');
31
- const worker = await newDenoHTTPWorker(url.pathToFileURL(workerPath), {
32
- runFlags: [
33
- `--node-modules-dir=manual`,
34
- `--allow-read=${allowRead}`,
35
- `--allow-net=${baseURLHostname}`,
36
- // Allow environment variables because instantiating the client will try to read from them,
37
- // even though they are not set.
38
- '--allow-env',
39
- ],
40
- printOutput: true,
41
- spawnOptions: {
42
- cwd: path.dirname(workerPath),
20
+ const handler = async (_, args) => {
21
+ const code = args.code;
22
+ // this is not required, but passing a Stainless API key for the matching project_name
23
+ // will allow you to run code-mode queries against non-published versions of your SDK.
24
+ const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
25
+ const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
26
+ const res = await fetch(codeModeEndpoint, {
27
+ method: 'POST',
28
+ headers: {
29
+ ...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
30
+ 'Content-Type': 'application/json',
31
+ client_envs: JSON.stringify({ NIRVANA_LABS_API_KEY: readEnv('NIRVANA_LABS_API_KEY') }),
43
32
  },
33
+ body: JSON.stringify({
34
+ project_name: 'nirvana',
35
+ code,
36
+ }),
44
37
  });
45
- try {
46
- const resp = await new Promise((resolve, reject) => {
47
- worker.addEventListener('exit', (exitCode) => {
48
- reject(new Error(`Worker exited with code ${exitCode}`));
49
- });
50
- const opts = {
51
- baseURL: client.baseURL,
52
- apiKey: client.apiKey,
53
- defaultHeaders: {
54
- 'X-Stainless-MCP': 'true',
55
- },
56
- };
57
- const req = worker.request('http://localhost', {
58
- headers: {
59
- 'content-type': 'application/json',
60
- },
61
- method: 'POST',
62
- }, (resp) => {
63
- const body = [];
64
- resp.on('error', (err) => {
65
- reject(err);
66
- });
67
- resp.on('data', (chunk) => {
68
- body.push(chunk);
69
- });
70
- resp.on('end', () => {
71
- resolve(new Response(Buffer.concat(body).toString(), {
72
- status: resp.statusCode ?? 200,
73
- headers: resp.headers,
74
- }));
75
- });
76
- });
77
- const body = JSON.stringify({
78
- opts,
79
- code,
80
- });
81
- req.write(body, (err) => {
82
- if (err != null) {
83
- reject(err);
84
- }
85
- });
86
- req.end();
87
- });
88
- if (resp.status === 200) {
89
- const { result, logLines, errLines } = (await resp.json());
90
- const returnOutput = result == null ? null : ({
91
- type: 'text',
92
- text: typeof result === 'string' ? result : JSON.stringify(result),
93
- });
94
- const logOutput = logLines.length === 0 ?
95
- null
96
- : {
97
- type: 'text',
98
- text: logLines.join('\n'),
99
- };
100
- const errOutput = errLines.length === 0 ?
101
- null
102
- : {
103
- type: 'text',
104
- text: 'Error output:\n' + errLines.join('\n'),
105
- };
106
- return {
107
- content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
108
- };
109
- }
110
- else {
111
- const { message, logLines, errLines } = (await resp.json());
112
- const messageOutput = message == null ? null : ({
113
- type: 'text',
114
- text: message,
115
- });
116
- const logOutput = logLines.length === 0 ?
117
- null
118
- : {
119
- type: 'text',
120
- text: logLines.join('\n'),
121
- };
122
- const errOutput = errLines.length === 0 ?
123
- null
124
- : {
125
- type: 'text',
126
- text: 'Error output:\n' + errLines.join('\n'),
127
- };
128
- return {
129
- content: [messageOutput, logOutput, errOutput].filter((block) => block !== null),
130
- isError: true,
131
- };
132
- }
133
- }
134
- finally {
135
- worker.terminate();
38
+ if (!res.ok) {
39
+ throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
136
40
  }
41
+ return asTextContentResult((await res.json()));
137
42
  };
138
43
  return { metadata, tool, handler };
139
44
  }
package/code-tool.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool.mjs","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,IAAI,MAAM,WAAW;OACrB,GAAG,MAAM,UAAU;AAQ1B;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAA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QACJ,CAAC;QAED,OAAO,mBAAmB,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAkB,CAAC,CAAC;IAClE,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"docs-search-tool.d.mts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,oDAKlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAL+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAOnF,wBAA2C"}
1
+ {"version":3,"file":"docs-search-tool.d.mts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,oDAYlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAZ+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAcnF,wBAA2C"}
@@ -1 +1 @@
1
- {"version":3,"file":"docs-search-tool.d.ts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,oDAKlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAL+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAOnF,wBAA2C"}
1
+ {"version":3,"file":"docs-search-tool.d.ts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,oDAYlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAZ+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAcnF,wBAA2C"}
@@ -41,6 +41,9 @@ const handler = async (_, args) => {
41
41
  const body = args;
42
42
  const query = new URLSearchParams(body).toString();
43
43
  const result = await fetch(`${docsSearchURL}?${query}`);
44
+ if (!result.ok) {
45
+ throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
46
+ }
44
47
  return (0, types_1.asTextContentResult)(await result.json());
45
48
  };
46
49
  exports.handler = handler;
@@ -1 +1 @@
1
- {"version":3,"file":"docs-search-t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KAAK,EAAE,CAAU,EAAE,IAAyC,EAAE,EAAE;IACrF,MAAM,IAAI,GAAG,IAAW,CAAC;IACzB,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC,CAAC;IAExD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,yCAAyC,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,2BAAmB,EAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AAZW,QAAA,OAAO,WAYlB;AAEF,kBAAe,EAAE,QAAQ,EAAR,gBAAQ,EAAE,IAAI,EAAJ,YAAI,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC"}
@@ -38,6 +38,9 @@ export const handler = async (_, args) => {
38
38
  const body = args;
39
39
  const query = new URLSearchParams(body).toString();
40
40
  const result = await fetch(`${docsSearchURL}?${query}`);
41
+ if (!result.ok) {
42
+ throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
43
+ }
41
44
  return asTextContentResult(await result.json());
42
45
  };
43
46
  export default { metadata, tool, handler };
@@ -1 +1 @@
1
- {"version":3,"file":"docs-search-tool.mjs","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAY,mBAAmB,EAAE;AAIxC,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,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AM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,yCAAyC,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,mBAAmB,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nirvana-labs/nirvana-mcp",
3
- "version": "1.26.1",
3
+ "version": "1.26.2",
4
4
  "description": "The official MCP Server for the Nirvana Labs API",
5
5
  "author": "Nirvana Labs <engineering@nirvanalabs.io>",
6
6
  "types": "./index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@nirvana-labs/nirvana": "^1.26.1",
21
+ "@nirvana-labs/nirvana": "^1.26.2",
22
22
  "@cloudflare/cabidela": "^0.2.4",
23
23
  "@modelcontextprotocol/sdk": "^1.24.0",
24
24
  "@valtown/deno-http-worker": "^0.0.21",
@@ -49,12 +49,6 @@
49
49
  "types": "./index.d.mts",
50
50
  "default": "./index.mjs"
51
51
  },
52
- "./code-tool-paths": {
53
- "require": "./code-tool-paths.cjs"
54
- },
55
- "./code-tool-paths.cjs": {
56
- "default": "./code-tool-paths.cjs"
57
- },
58
52
  "./code-tool-types": {
59
53
  "import": "./code-tool-types.mjs",
60
54
  "require": "./code-tool-types.js"
@@ -65,16 +59,6 @@
65
59
  "./code-tool-types.mjs": {
66
60
  "default": "./code-tool-types.mjs"
67
61
  },
68
- "./code-tool-worker": {
69
- "import": "./code-tool-worker.mjs",
70
- "require": "./code-tool-worker.js"
71
- },
72
- "./code-tool-worker.js": {
73
- "default": "./code-tool-worker.js"
74
- },
75
- "./code-tool-worker.mjs": {
76
- "default": "./code-tool-worker.mjs"
77
- },
78
62
  "./code-tool": {
79
63
  "import": "./code-tool.mjs",
80
64
  "require": "./code-tool.js"
package/server.js CHANGED
@@ -22,7 +22,7 @@ var tools_2 = require("./tools.js");
22
22
  Object.defineProperty(exports, "endpoints", { enumerable: true, get: function () { return tools_2.endpoints; } });
23
23
  const newMcpServer = () => new mcp_js_1.McpServer({
24
24
  name: 'nirvana_labs_nirvana_api',
25
- version: '1.26.1',
25
+ version: '1.26.2',
26
26
  }, { capabilities: { tools: {}, logging: {} } });
27
27
  exports.newMcpServer = newMcpServer;
28
28
  // Create server instance
package/server.mjs CHANGED
@@ -11,7 +11,7 @@ export { ClientType } from "./compat.mjs";
11
11
  export { endpoints } from "./tools.mjs";
12
12
  export const newMcpServer = () => new McpServer({
13
13
  name: 'nirvana_labs_nirvana_api',
14
- version: '1.26.1',
14
+ version: '1.26.2',
15
15
  }, { capabilities: { tools: {}, logging: {} } });
16
16
  // Create server instance
17
17
  export const server = newMcpServer();