You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -196,21 +187,15 @@ Then, configure your client:
196
187
"command": "docker",
197
188
"args": [
198
189
"run", "-i", "--rm",
199
-
"-e", "DOCUMENT_URL",
200
-
"-e", "DOCUMENT_TOKEN",
201
-
"-e", "DOCUMENT_ID",
202
-
"-e", "RUNTIME_URL",
203
-
"-e", "RUNTIME_TOKEN",
190
+
"-e", "JUPYTER_URL",
191
+
"-e", "JUPYTER_TOKEN",
204
192
"-e", "ALLOW_IMG_OUTPUT",
205
193
"--network=host",
206
194
"datalayer/jupyter-mcp-server:latest"
207
195
],
208
196
"env": {
209
-
"DOCUMENT_URL": "http://localhost:8888",
210
-
"DOCUMENT_TOKEN": "MY_TOKEN",
211
-
"DOCUMENT_ID": "notebook.ipynb",
212
-
"RUNTIME_URL": "http://localhost:8888",
213
-
"RUNTIME_TOKEN": "MY_TOKEN",
197
+
"JUPYTER_URL": "http://localhost:8888",
198
+
"JUPYTER_TOKEN": "MY_TOKEN",
214
199
"ALLOW_IMG_OUTPUT": "true"
215
200
}
216
201
}
@@ -221,9 +206,10 @@ Then, configure your client:
221
206
</details>
222
207
223
208
> [!TIP]
224
-
> 1. Ensure the `port` of the `DOCUMENT_URL` and `RUNTIME_URL` match those used in the `jupyter lab` command.
225
-
> 2. In a basic setup, `DOCUMENT_URL` and `RUNTIME_URL` are the same. `DOCUMENT_TOKEN`, and `RUNTIME_TOKEN` are also the same and is actually the Jupyter Token.
226
-
> 3. The `DOCUMENT_ID` parameter specifies the path to the notebook you want to connect to. It should be relative to the directory where JupyterLab was started.
209
+
> 1.**Port Configuration**: Ensure the `port` in your Jupyter URLs matches the one used in the `jupyter lab` command. For simplified config, set this in `JUPYTER_URL`.
210
+
> 2.**Server Separation**: The different URL and token variables exist because some deployments separate notebook storage (`DOCUMENT_*`) from kernel execution (`RUNTIME_*`). Use `JUPYTER_URL` and `JUPYTER_TOKEN` when both services are on the same server, or set individual variables for advanced deployments.
211
+
> 3.**Authentication**: In most cases, document and runtime services use the same authentication token. Use `JUPYTER_TOKEN` for simplified config or set `DOCUMENT_TOKEN` and `RUNTIME_TOKEN` individually for different credentials.
212
+
> 4.**Notebook Path**: The `DOCUMENT_ID` parameter specifies the path to the notebook you want to connect to. It should be relative to the directory where JupyterLab was started.
227
213
> -**Optional:** If you omit `DOCUMENT_ID`, the MCP client can automatically list all available notebooks on the Jupyter server, allowing you to select one interactively via your prompts.
228
214
> -**Flexible:** Even if you set `DOCUMENT_ID`, the MCP client can still browse, list, switch to, or even create new notebooks at any time.
Copy file name to clipboardExpand all lines: jupyter_mcp_server/CLI.py
+98-10Lines changed: 98 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ def _common_options(f):
38
38
"--runtime-url",
39
39
envvar="RUNTIME_URL",
40
40
type=click.STRING,
41
-
default="http://localhost:8888",
41
+
default=None,
42
42
help="The runtime URL to use. For the jupyter provider, this is the Jupyter server URL. For the datalayer provider, this is the Datalayer runtime URL.",
43
43
),
44
44
click.option(
@@ -59,7 +59,7 @@ def _common_options(f):
59
59
"--document-url",
60
60
envvar="DOCUMENT_URL",
61
61
type=click.STRING,
62
-
default="http://localhost:8888",
62
+
default=None,
63
63
help="The document URL to use. For the jupyter provider, this is the Jupyter server URL. For the datalayer provider, this is the Datalayer document URL.",
64
64
),
65
65
click.option(
@@ -75,13 +75,77 @@ def _common_options(f):
75
75
type=click.STRING,
76
76
default=None,
77
77
help="The document token to use for authentication with the provider. If not provided, the provider should accept anonymous requests.",
78
+
),
79
+
click.option(
80
+
"--jupyter-url",
81
+
envvar="JUPYTER_URL",
82
+
type=click.STRING,
83
+
default=None,
84
+
help="The Jupyter URL to use as default for both document and runtime URLs. If not provided, individual URL settings take precedence.",
85
+
),
86
+
click.option(
87
+
"--jupyter-token",
88
+
envvar="JUPYTER_TOKEN",
89
+
type=click.STRING,
90
+
default=None,
91
+
help="The Jupyter token to use as default for both document and runtime tokens. If not provided, individual token settings take precedence.",
78
92
)
79
93
]
80
94
# Apply decorators in reverse order
81
95
foroptioninreversed(options):
82
96
f=option(f)
83
97
returnf
84
98
99
+
100
+
def_resolve_url_and_token_variables(
101
+
jupyter_url, jupyter_token,
102
+
document_url, document_token,
103
+
runtime_url, runtime_token,
104
+
) ->tuple[str, str|None, str, str|None]:
105
+
"""Resolve URL and token variables based on priority logic.
106
+
107
+
Priority order:
108
+
1. Individual URL/token variables take precedence if set
109
+
2. JUPYTER_URL/JUPYTER_TOKEN used as fallback if individual variables are None
110
+
3. Keep original default values if neither individual nor merged variables are set
111
+
112
+
Args:
113
+
jupyter_url: The merged Jupyter URL variable
114
+
jupyter_token: The merged Jupyter token variable
115
+
document_url: The individual document URL (takes precedence if set)
116
+
document_token: The individual document token (takes precedence if set)
117
+
runtime_url: The individual runtime URL (takes precedence if set)
118
+
runtime_token: The individual runtime token (takes precedence if set)
119
+
120
+
Returns:
121
+
Tuple of (resolved_document_url, resolved_document_token, resolved_runtime_url, resolved_runtime_token)
0 commit comments