@akram1110/notebook-mcp 1.0.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/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/notebook-mcp.js +9 -0
- package/lib/launcher.js +84 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# notebook-mcp (NPM)
|
|
2
|
+
|
|
3
|
+
This is an NPM wrapper for the **Python** package `notebook-mcp`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g @akram1110/notebook-mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Run
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
notebook-mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Configuration
|
|
18
|
+
|
|
19
|
+
- `NOTEBOOK_MCP_PYTHON`: path to the Python executable to use
|
|
20
|
+
- `NOTEBOOK_MCP_PIP_SPEC`: pip spec to install (default: `notebook-mcp`)
|
|
21
|
+
- `NOTEBOOK_MCP_PIP_ARGS`: extra args passed to `pip install` (space-separated)
|
|
22
|
+
|
|
23
|
+
Environment variables used by the server:
|
|
24
|
+
|
|
25
|
+
- `MCP_TRANSPORT`: `stdio` (default) or `streamable-http`
|
|
26
|
+
- `MCP_HOST`, `MCP_PORT`
|
|
27
|
+
- `JUPYTER_BASE_URL`, `JUPYTER_TOKEN`
|
package/lib/launcher.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const { spawnSync, spawn } = require("node:child_process");
|
|
2
|
+
const process = require("node:process");
|
|
3
|
+
const which = require("which");
|
|
4
|
+
|
|
5
|
+
function findPython() {
|
|
6
|
+
const explicit = process.env.NOTEBOOK_MCP_PYTHON;
|
|
7
|
+
if (explicit) return explicit;
|
|
8
|
+
|
|
9
|
+
const candidates = ["python", "python3", "py"]; // py is Windows launcher
|
|
10
|
+
for (const c of candidates) {
|
|
11
|
+
try {
|
|
12
|
+
const p = which.sync(c);
|
|
13
|
+
if (p) return p;
|
|
14
|
+
} catch {
|
|
15
|
+
// ignore
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function runChecked(cmd, args, opts = {}) {
|
|
22
|
+
const res = spawnSync(cmd, args, { stdio: "inherit", ...opts });
|
|
23
|
+
if (res.error) throw res.error;
|
|
24
|
+
if (typeof res.status === "number" && res.status !== 0) {
|
|
25
|
+
const e = new Error(`${cmd} ${args.join(" ")} exited with code ${res.status}`);
|
|
26
|
+
e.exitCode = res.status;
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function canImportNotebookMcp(python) {
|
|
32
|
+
const res = spawnSync(python, ["-c", "import notebook_mcp"], { stdio: "ignore" });
|
|
33
|
+
return res.status === 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ensureInstalled(python) {
|
|
37
|
+
if (canImportNotebookMcp(python)) return;
|
|
38
|
+
|
|
39
|
+
const spec = process.env.NOTEBOOK_MCP_PIP_SPEC || "notebook-mcp";
|
|
40
|
+
const extraArgs = (process.env.NOTEBOOK_MCP_PIP_ARGS || "").split(" ").filter(Boolean);
|
|
41
|
+
|
|
42
|
+
// Use module invocation so we don't rely on pip.exe being on PATH.
|
|
43
|
+
runChecked(python, ["-m", "pip", "install", "-U", spec, ...extraArgs]);
|
|
44
|
+
|
|
45
|
+
if (!canImportNotebookMcp(python)) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"Installed notebook-mcp but it is still not importable. " +
|
|
48
|
+
"Check that your Python environment is the one you expect (NOTEBOOK_MCP_PYTHON)."
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function launch(argv) {
|
|
54
|
+
const python = findPython();
|
|
55
|
+
if (!python) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"Python was not found on PATH. Install Python 3.11+ and ensure `python` is available, " +
|
|
58
|
+
"or set NOTEBOOK_MCP_PYTHON to the full path of your python executable."
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
ensureInstalled(python);
|
|
63
|
+
|
|
64
|
+
// Run as module so this works even if Scripts/ is not on PATH.
|
|
65
|
+
const child = spawn(python, ["-m", "notebook_mcp.server", ...argv], {
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
env: process.env,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
child.on("error", reject);
|
|
72
|
+
child.on("exit", (code, signal) => {
|
|
73
|
+
if (signal) {
|
|
74
|
+
const e = new Error(`notebook-mcp exited due to signal ${signal}`);
|
|
75
|
+
e.exitCode = 1;
|
|
76
|
+
reject(e);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
resolve(code || 0);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = { launch };
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@akram1110/notebook-mcp",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "NPM wrapper that launches the notebook-mcp Python MCP server",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "lib/launcher.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"notebook-mcp": "bin/notebook-mcp.js"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"jupyter",
|
|
17
|
+
"notebook",
|
|
18
|
+
"ipynb",
|
|
19
|
+
"cli"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"bin/notebook-mcp.js",
|
|
23
|
+
"lib/launcher.js",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/your-org/notebook-mcp"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/your-org/notebook-mcp/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/your-org/notebook-mcp#readme",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"which": "^4.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|