@nirvana-labs/nirvana-mcp 1.35.0 → 1.35.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/README.md +2 -2
- package/code-tool-types.d.mts +6 -9
- package/code-tool-types.d.mts.map +1 -1
- package/code-tool-types.d.ts +6 -9
- package/code-tool-types.d.ts.map +1 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +12 -2
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +13 -3
- package/code-tool.mjs.map +1 -1
- package/package.json +2 -2
- package/server.js +1 -1
- package/server.mjs +1 -1
- package/src/code-tool-types.ts +6 -9
- package/src/code-tool.ts +15 -5
- package/src/server.ts +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ For clients with a configuration JSON, it might look something like this:
|
|
|
37
37
|
If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
|
|
38
38
|
in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
|
|
39
39
|
|
|
40
|
-
[](https://cursor.com/en-US/install-mcp?name
|
|
40
|
+
[](https://cursor.com/en-US/install-mcp?name=%40nirvana-labs%2Fnirvana-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBuaXJ2YW5hLWxhYnMvbmlydmFuYS1tY3AiXSwiZW52Ijp7Ik5JUlZBTkFfTEFCU19BUElfS0VZIjoiU2V0IHlvdXIgTklSVkFOQV9MQUJTX0FQSV9LRVkgaGVyZS4ifX0)
|
|
41
41
|
|
|
42
42
|
### VS Code
|
|
43
43
|
|
|
@@ -52,7 +52,7 @@ If you use Claude Code, you can install the MCP server by running the command be
|
|
|
52
52
|
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
|
|
53
53
|
|
|
54
54
|
```
|
|
55
|
-
claude mcp add
|
|
55
|
+
claude mcp add nirvana_labs_nirvana_mcp_api --env NIRVANA_LABS_API_KEY="Your NIRVANA_LABS_API_KEY here." -- npx -y @nirvana-labs/nirvana-mcp
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
## Code Mode
|
package/code-tool-types.d.mts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { ClientOptions } from '@nirvana-labs/nirvana';
|
|
2
2
|
export type WorkerInput = {
|
|
3
|
-
|
|
3
|
+
project_name: string;
|
|
4
4
|
code: string;
|
|
5
|
+
client_opts: ClientOptions;
|
|
5
6
|
};
|
|
6
|
-
export type
|
|
7
|
+
export type WorkerOutput = {
|
|
8
|
+
is_error: boolean;
|
|
7
9
|
result: unknown | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type WorkerError = {
|
|
12
|
-
message: string | undefined;
|
|
13
|
-
logLines: string[];
|
|
14
|
-
errLines: string[];
|
|
10
|
+
log_lines: string[];
|
|
11
|
+
err_lines: string[];
|
|
15
12
|
};
|
|
16
13
|
//# sourceMappingURL=code-tool-types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,uBAAuB;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,uBAAuB;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
package/code-tool-types.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { ClientOptions } from '@nirvana-labs/nirvana';
|
|
2
2
|
export type WorkerInput = {
|
|
3
|
-
|
|
3
|
+
project_name: string;
|
|
4
4
|
code: string;
|
|
5
|
+
client_opts: ClientOptions;
|
|
5
6
|
};
|
|
6
|
-
export type
|
|
7
|
+
export type WorkerOutput = {
|
|
8
|
+
is_error: boolean;
|
|
7
9
|
result: unknown | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type WorkerError = {
|
|
12
|
-
message: string | undefined;
|
|
13
|
-
logLines: string[];
|
|
14
|
-
errLines: string[];
|
|
10
|
+
log_lines: string[];
|
|
11
|
+
err_lines: string[];
|
|
15
12
|
};
|
|
16
13
|
//# sourceMappingURL=code-tool-types.d.ts.map
|
package/code-tool-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,uBAAuB;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,uBAAuB;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
package/code-tool.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AAIhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAwDlC"}
|
package/code-tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AAIhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAwDlC"}
|
package/code-tool.js
CHANGED
|
@@ -38,14 +38,24 @@ function codeTool() {
|
|
|
38
38
|
},
|
|
39
39
|
body: JSON.stringify({
|
|
40
40
|
project_name: 'nirvana',
|
|
41
|
-
client_opts: {},
|
|
42
41
|
code,
|
|
42
|
+
client_opts: {},
|
|
43
43
|
}),
|
|
44
44
|
});
|
|
45
45
|
if (!res.ok) {
|
|
46
46
|
throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
const { is_error, result, log_lines, err_lines } = (await res.json());
|
|
49
|
+
const hasLogs = log_lines.length > 0 || err_lines.length > 0;
|
|
50
|
+
const output = {
|
|
51
|
+
result,
|
|
52
|
+
...(log_lines.length > 0 && { log_lines }),
|
|
53
|
+
...(err_lines.length > 0 && { err_lines }),
|
|
54
|
+
};
|
|
55
|
+
if (is_error) {
|
|
56
|
+
return (0, types_1.asErrorResult)(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
|
|
57
|
+
}
|
|
58
|
+
return (0, types_1.asTextContentResult)(output);
|
|
49
59
|
};
|
|
50
60
|
return { metadata, tool, handler };
|
|
51
61
|
}
|
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;;AAetF,
|
|
1
|
+
{"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AAetF,4BAwDC;AArED,sCAAgG;AAEhG,wCAAmC;AAEnC;;;;;;;;GAQG;AACH,SAAgB,QAAQ;IACtB,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,iiCAAiiC;QACniC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,EAAE,CAAU,EAAE,IAAS,EAA2B,EAAE;QACvE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAc,CAAC;QAEjC,sFAAsF;QACtF,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,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QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
package/code-tool.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
import { asTextContentResult } from "./types.mjs";
|
|
2
|
+
import { asErrorResult, asTextContentResult } from "./types.mjs";
|
|
3
3
|
import { readEnv } from "./server.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* A tool that runs code against a copy of the SDK.
|
|
@@ -35,14 +35,24 @@ export function codeTool() {
|
|
|
35
35
|
},
|
|
36
36
|
body: JSON.stringify({
|
|
37
37
|
project_name: 'nirvana',
|
|
38
|
-
client_opts: {},
|
|
39
38
|
code,
|
|
39
|
+
client_opts: {},
|
|
40
40
|
}),
|
|
41
41
|
});
|
|
42
42
|
if (!res.ok) {
|
|
43
43
|
throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
const { is_error, result, log_lines, err_lines } = (await res.json());
|
|
46
|
+
const hasLogs = log_lines.length > 0 || err_lines.length > 0;
|
|
47
|
+
const output = {
|
|
48
|
+
result,
|
|
49
|
+
...(log_lines.length > 0 && { log_lines }),
|
|
50
|
+
...(err_lines.length > 0 && { err_lines }),
|
|
51
|
+
};
|
|
52
|
+
if (is_error) {
|
|
53
|
+
return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
|
|
54
|
+
}
|
|
55
|
+
return asTextContentResult(output);
|
|
46
56
|
};
|
|
47
57
|
return { metadata, tool, handler };
|
|
48
58
|
}
|
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,EAAqC,mBAAmB,EAAE;
|
|
1
|
+
{"version":3,"file":"code-tool.m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AC;SACzB,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,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAiB,CAAC;QACtF,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG;YACb,MAAM;YACN,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;SAC3C,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,aAAa,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nirvana-labs/nirvana-mcp",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.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.35.
|
|
21
|
+
"@nirvana-labs/nirvana": "^1.35.2",
|
|
22
22
|
"@cloudflare/cabidela": "^0.2.4",
|
|
23
23
|
"@modelcontextprotocol/sdk": "^1.24.0",
|
|
24
24
|
"@valtown/deno-http-worker": "^0.0.21",
|
package/server.js
CHANGED
|
@@ -15,7 +15,7 @@ const code_tool_1 = require("./code-tool.js");
|
|
|
15
15
|
const docs_search_tool_1 = __importDefault(require("./docs-search-tool.js"));
|
|
16
16
|
const newMcpServer = () => new mcp_js_1.McpServer({
|
|
17
17
|
name: 'nirvana_labs_nirvana_api',
|
|
18
|
-
version: '1.35.
|
|
18
|
+
version: '1.35.2',
|
|
19
19
|
}, { capabilities: { tools: {}, logging: {} } });
|
|
20
20
|
exports.newMcpServer = newMcpServer;
|
|
21
21
|
// Create server instance
|
package/server.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { codeTool } from "./code-tool.mjs";
|
|
|
6
6
|
import docsSearchTool from "./docs-search-tool.mjs";
|
|
7
7
|
export const newMcpServer = () => new McpServer({
|
|
8
8
|
name: 'nirvana_labs_nirvana_api',
|
|
9
|
-
version: '1.35.
|
|
9
|
+
version: '1.35.2',
|
|
10
10
|
}, { capabilities: { tools: {}, logging: {} } });
|
|
11
11
|
// Create server instance
|
|
12
12
|
export const server = newMcpServer();
|
package/src/code-tool-types.ts
CHANGED
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
import { ClientOptions } from '@nirvana-labs/nirvana';
|
|
4
4
|
|
|
5
5
|
export type WorkerInput = {
|
|
6
|
-
|
|
6
|
+
project_name: string;
|
|
7
7
|
code: string;
|
|
8
|
+
client_opts: ClientOptions;
|
|
8
9
|
};
|
|
9
|
-
export type
|
|
10
|
+
export type WorkerOutput = {
|
|
11
|
+
is_error: boolean;
|
|
10
12
|
result: unknown | null;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
export type WorkerError = {
|
|
15
|
-
message: string | undefined;
|
|
16
|
-
logLines: string[];
|
|
17
|
-
errLines: string[];
|
|
13
|
+
log_lines: string[];
|
|
14
|
+
err_lines: string[];
|
|
18
15
|
};
|
package/src/code-tool.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { McpTool, Metadata, ToolCallResult, asTextContentResult } from './types';
|
|
3
|
+
import { McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult } from './types';
|
|
4
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import { readEnv } from './server';
|
|
6
|
-
import {
|
|
6
|
+
import { WorkerInput, WorkerOutput } from './code-tool-types';
|
|
7
7
|
/**
|
|
8
8
|
* A tool that runs code against a copy of the SDK.
|
|
9
9
|
*
|
|
@@ -42,9 +42,9 @@ export function codeTool(): McpTool {
|
|
|
42
42
|
},
|
|
43
43
|
body: JSON.stringify({
|
|
44
44
|
project_name: 'nirvana',
|
|
45
|
-
client_opts: {},
|
|
46
45
|
code,
|
|
47
|
-
|
|
46
|
+
client_opts: {},
|
|
47
|
+
} satisfies WorkerInput),
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
if (!res.ok) {
|
|
@@ -55,7 +55,17 @@ export function codeTool(): McpTool {
|
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
const { is_error, result, log_lines, err_lines } = (await res.json()) as WorkerOutput;
|
|
59
|
+
const hasLogs = log_lines.length > 0 || err_lines.length > 0;
|
|
60
|
+
const output = {
|
|
61
|
+
result,
|
|
62
|
+
...(log_lines.length > 0 && { log_lines }),
|
|
63
|
+
...(err_lines.length > 0 && { err_lines }),
|
|
64
|
+
};
|
|
65
|
+
if (is_error) {
|
|
66
|
+
return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
|
|
67
|
+
}
|
|
68
|
+
return asTextContentResult(output);
|
|
59
69
|
};
|
|
60
70
|
|
|
61
71
|
return { metadata, tool, handler };
|