codeocean-mcp-server 0.13.0__tar.gz → 0.13.1__tar.gz

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 (31) hide show
  1. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/CHANGELOG.md +4 -0
  2. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/PKG-INFO +3 -1
  3. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/README.md +2 -0
  4. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/pyproject.toml +2 -2
  5. codeocean_mcp_server-0.13.1/src/codeocean_mcp_server/logging_config.py +70 -0
  6. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/server.py +2 -1
  7. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/test_logging_config.py +36 -5
  8. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/uv.lock +1 -1
  9. codeocean_mcp_server-0.13.0/src/codeocean_mcp_server/logging_config.py +0 -67
  10. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/.gitignore +0 -0
  11. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/.python-version +0 -0
  12. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/LICENSE +0 -0
  13. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/RELEASE.md +0 -0
  14. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/__init__.py +0 -0
  15. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/client.py +0 -0
  16. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/file_utils.py +0 -0
  17. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/models.py +0 -0
  18. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/search.py +0 -0
  19. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/tools/__init__.py +0 -0
  20. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/tools/capsules.py +0 -0
  21. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/tools/computations.py +0 -0
  22. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/tools/custom_metadata.py +0 -0
  23. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/src/codeocean_mcp_server/tools/data_assets.py +0 -0
  24. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/bedrock_call.py +0 -0
  25. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/bedrock_tools_converter.py +0 -0
  26. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/conftest.py +0 -0
  27. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/mcp_client.py +0 -0
  28. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/test_http_transport.py +0 -0
  29. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/test_multi_tool_calling.py +0 -0
  30. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/test_search.py +0 -0
  31. {codeocean_mcp_server-0.13.0 → codeocean_mcp_server-0.13.1}/tests/test_tool_calling.py +0 -0
@@ -1,6 +1,10 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ ## 0.13.1 (2026-09-16)
5
+
6
+ - [#49](https://github.com/codeocean/codeocean-mcp-server/pull/49) feat: take the log level from `LOG_LEVEL`
7
+
4
8
  ## 0.13.0 (2026-09-16)
5
9
 
6
10
  - [#46](https://github.com/codeocean/codeocean-mcp-server/pull/46) fix: bump mcp to 1.29.x and refresh locked dependencies
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeocean-mcp-server
3
- Version: 0.13.0
3
+ Version: 0.13.1
4
4
  Summary: Code Ocean MCP Server
5
5
  Project-URL: Homepage, https://github.com/codeocean/codeocean-mcp-server
6
6
  Project-URL: Issues, https://github.com/codeocean/codeocean-mcp-server/issues
@@ -249,3 +249,5 @@ This will start a web server where you can:
249
249
  The MCP server supports custom log formatting through the `LOG_FORMAT` environment variable. This allows you to control the format of log messages output by the server.
250
250
  **Example Format Strings:** `"%(asctime)s %(levelname)s [%(name)s] %(message)s"`.
251
251
  If `LOG_FORMAT` is not set, the server uses FastMCP's default logging configuration.
252
+
253
+ The `LOG_LEVEL` environment variable sets the level the server logs at: `DEBUG`, `INFO` (the default), `WARNING`, `ERROR` or `CRITICAL`. Raising it drops the record the server writes for every request it serves, which is worth doing when the server runs alongside a caller that logs those requests itself.
@@ -230,3 +230,5 @@ This will start a web server where you can:
230
230
  The MCP server supports custom log formatting through the `LOG_FORMAT` environment variable. This allows you to control the format of log messages output by the server.
231
231
  **Example Format Strings:** `"%(asctime)s %(levelname)s [%(name)s] %(message)s"`.
232
232
  If `LOG_FORMAT` is not set, the server uses FastMCP's default logging configuration.
233
+
234
+ The `LOG_LEVEL` environment variable sets the level the server logs at: `DEBUG`, `INFO` (the default), `WARNING`, `ERROR` or `CRITICAL`. Raising it drops the record the server writes for every request it serves, which is worth doing when the server runs alongside a caller that logs those requests itself.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codeocean-mcp-server"
3
- version = "0.13.0"
3
+ version = "0.13.1"
4
4
  authors = [{ name = "Code Ocean", email = "dev@codeocean.com" }]
5
5
  description = "Code Ocean MCP Server"
6
6
  readme = "README.md"
@@ -37,7 +37,7 @@ Changelog = "https://github.com/codeocean/codeocean-mcp-server/blob/main/CHANGEL
37
37
  codeocean-mcp-server = "codeocean_mcp_server.server:main"
38
38
 
39
39
  [build-system]
40
- requires = ["hatchling"]
40
+ requires = ["hatchling!=1.32.1"]
41
41
  build-backend = "hatchling.build"
42
42
 
43
43
  [tool.hatch.build.targets.sdist]
@@ -0,0 +1,70 @@
1
+ import logging
2
+ import os
3
+ import sys
4
+
5
+
6
+ def log_level() -> str:
7
+ """Return the level to log at, from the LOG_LEVEL environment variable.
8
+
9
+ FastMCP has to be constructed with it as well: it configures uvicorn's loggers from its own level,
10
+ which it takes as a constructor argument that wins over its FASTMCP_LOG_LEVEL environment variable.
11
+
12
+ Environment variables:
13
+ LOG_LEVEL: DEBUG, INFO, WARNING, ERROR or CRITICAL (optional, defaults to INFO)
14
+ """
15
+ return os.getenv("LOG_LEVEL", "").strip().upper() or "INFO"
16
+
17
+
18
+ def configure_logging(transport: str = "stdio") -> None:
19
+ """Configure the root logger from the LOG_LEVEL and LOG_FORMAT environment variables.
20
+
21
+ LOG_LEVEL sets the root logger's level. LOG_FORMAT gives the root logger a stderr handler
22
+ with that format and, for a transport uvicorn serves, applies the same format to uvicorn's
23
+ own loggers. With neither set, logging is left as it is, for whoever embeds the server, or
24
+ else FastMCP with its defaults, to configure. Must be called before FastMCP is constructed.
25
+
26
+ Args:
27
+ transport: The transport the server is about to serve on.
28
+
29
+ Environment variables:
30
+ LOG_LEVEL: DEBUG, INFO, WARNING, ERROR or CRITICAL (optional, defaults to INFO)
31
+ LOG_FORMAT: Python logging format string (optional)
32
+
33
+ Examples:
34
+ - "%(asctime)s agent %(levelname)s [%(name)s] %(message)s"
35
+ - "%(levelname)s: %(message)s"
36
+ - "[%(name)s] %(message)s"
37
+
38
+ Note:
39
+ A malformed format string fails here, at startup. One that names a field records do not
40
+ have fails with a ValueError when the first record is formatted instead.
41
+
42
+ """
43
+ log_format = os.getenv("LOG_FORMAT", "").strip()
44
+
45
+ # The level is applied when either variable is set: a handler of our own leaves FastMCP's own
46
+ # logging.basicConfig() with nothing to do, so the level would otherwise stay at the default.
47
+ if log_format or "LOG_LEVEL" in os.environ:
48
+ logging.root.setLevel(log_level())
49
+
50
+ if not log_format:
51
+ return
52
+
53
+ handler = logging.StreamHandler(sys.stderr)
54
+ handler.setFormatter(logging.Formatter(log_format))
55
+ logging.root.addHandler(handler)
56
+
57
+ if transport == "stdio":
58
+ return
59
+
60
+ # Serving over HTTP, uvicorn logs through its own loggers, which it gives handlers that do not
61
+ # propagate to the root logger. It configures them from this dictionary, which FastMCP leaves
62
+ # at its default value, so its contents have to be replaced to be reached at all. The import
63
+ # is local because uvicorn, like in FastMCP itself, is only needed for the transports it serves.
64
+ from uvicorn.config import LOGGING_CONFIG
65
+
66
+ LOGGING_CONFIG["formatters"]["default"]["fmt"] = log_format
67
+ # Access records carry the request in fields of their own rather than in the message.
68
+ LOGGING_CONFIG["formatters"]["access"]["fmt"] = log_format.replace(
69
+ "%(message)s", '%(client_addr)s - "%(request_line)s" %(status_code)s'
70
+ )
@@ -9,7 +9,7 @@ from codeocean import CodeOcean
9
9
  from mcp.server.fastmcp import FastMCP
10
10
 
11
11
  from codeocean_mcp_server.client import RequestScopedClient
12
- from codeocean_mcp_server.logging_config import configure_logging
12
+ from codeocean_mcp_server.logging_config import configure_logging, log_level
13
13
  from codeocean_mcp_server.tools import (
14
14
  capsules,
15
15
  computations,
@@ -80,6 +80,7 @@ def main():
80
80
  host=args.host,
81
81
  port=args.port,
82
82
  stateless_http=True,
83
+ log_level=log_level(),
83
84
  )
84
85
 
85
86
  if stdio:
@@ -1,4 +1,4 @@
1
- """End-to-end test for LOG_FORMAT, over the transport that brings a logger of its own along."""
1
+ """End-to-end tests for LOG_LEVEL and LOG_FORMAT, over the transport that brings a logger of its own along."""
2
2
 
3
3
  import os
4
4
  import re
@@ -30,9 +30,15 @@ def _wait_until_listening(port: int, timeout: float = 30.0):
30
30
  raise TimeoutError(f"MCP server did not start listening on port {port}")
31
31
 
32
32
 
33
- def _serve_and_request(port: int) -> str:
34
- """Serve over streamable HTTP, make one request, and return everything the server logged."""
35
- env = {**os.environ, "CODEOCEAN_DOMAIN": "test-domain", "LOG_FORMAT": LOG_FORMAT}
33
+ def _serve_and_request(**variables: str) -> str:
34
+ """Serve over streamable HTTP with exactly these LOG_* variables set, request once, and return the log.
35
+
36
+ Whatever LOG_LEVEL and LOG_FORMAT the test run itself has are dropped, so that only the test
37
+ decides what the server logs.
38
+ """
39
+ env = {name: value for name, value in os.environ.items() if name not in ("LOG_LEVEL", "LOG_FORMAT")}
40
+ env |= {"CODEOCEAN_DOMAIN": "test-domain", **variables}
41
+ port = _free_port()
36
42
  process = subprocess.Popen(
37
43
  [sys.executable, SERVER_SCRIPT_PATH, "--transport", "streamable-http", "--port", str(port)],
38
44
  env=env,
@@ -55,7 +61,7 @@ def _serve_and_request(port: int) -> str:
55
61
 
56
62
  def test_log_format_applies_to_uvicorns_own_records():
57
63
  """Uvicorn brings its own logging configuration, in whose format these records would be."""
58
- log = _serve_and_request(_free_port())
64
+ log = _serve_and_request(LOG_FORMAT=LOG_FORMAT)
59
65
 
60
66
  timestamp = r"^[\d-]{10} [\d:,]+"
61
67
  assert re.search(rf"{timestamp} server INFO \[uvicorn\.error\] Uvicorn running", log, re.MULTILINE)
@@ -66,3 +72,28 @@ def test_log_format_applies_to_uvicorns_own_records():
66
72
  log,
67
73
  re.MULTILINE,
68
74
  )
75
+
76
+
77
+ def test_log_level_quiets_a_request_the_caller_does_not_want_logged():
78
+ """Both loggers have to be reached: uvicorn takes its level from FastMCP, the SDK from the root."""
79
+ log = _serve_and_request(LOG_LEVEL="WARNING", LOG_FORMAT=LOG_FORMAT)
80
+
81
+ assert "[uvicorn.access]" not in log
82
+ assert "[uvicorn.error]" not in log
83
+ assert "server INFO" not in log
84
+ # The rejected request is still warned about: the level drops the chatter, not the record
85
+ # that says something went wrong.
86
+ assert "server WARNING [" in log
87
+
88
+
89
+ def test_log_level_applies_without_a_log_format():
90
+ """Without LOG_FORMAT the records are FastMCP's own, and the level has to reach those too."""
91
+ noisy = _serve_and_request()
92
+ quiet = _serve_and_request(LOG_LEVEL="WARNING")
93
+
94
+ # FastMCP's rich-formatted records wrap, so match a word of each.
95
+ assert "Uvicorn running" in noisy
96
+ assert "streamable_http_manager" in noisy
97
+ assert "Uvicorn running" not in quiet
98
+ assert "streamable_http_manager" not in quiet
99
+ assert "Invalid Content-Type" in quiet # The rejected request's WARNING is still logged.
@@ -852,7 +852,7 @@ wheels = [
852
852
 
853
853
  [[package]]
854
854
  name = "codeocean-mcp-server"
855
- version = "0.13.0"
855
+ version = "0.13.1"
856
856
  source = { editable = "." }
857
857
  dependencies = [
858
858
  { name = "anyio" },
@@ -1,67 +0,0 @@
1
- import logging
2
- import os
3
- import sys
4
-
5
-
6
- def configure_logging(transport: str = "stdio") -> None:
7
- """Configure logging based on LOG_FORMAT environment variable.
8
-
9
- If LOG_FORMAT is set, configures the root logger with a StreamHandler
10
- using the specified format string, and, for a transport uvicorn serves,
11
- applies the same format to uvicorn's own loggers. This must be called
12
- before FastMCP initialization to ensure our configuration takes
13
- precedence.
14
-
15
- If LOG_FORMAT is not set or is empty, does nothing and lets FastMCP
16
- configure logging with its default settings.
17
-
18
- Args:
19
- transport: The transport the server is about to serve on.
20
-
21
- Environment variables:
22
- LOG_FORMAT: Python logging format string (optional)
23
-
24
- Examples:
25
- - "%(asctime)s agent %(levelname)s [%(name)s] %(message)s"
26
- - "%(levelname)s: %(message)s"
27
- - "[%(name)s] %(message)s"
28
-
29
- Note:
30
- Invalid format strings will cause errors when log records are formatted,
31
- not during initialization. This typically results in ValueError, KeyError,
32
- or AttributeError being raised when logging occurs.
33
-
34
- """
35
- log_format = os.getenv("LOG_FORMAT", "").strip()
36
-
37
- # If LOG_FORMAT is not set or empty, do nothing
38
- if not log_format:
39
- return
40
-
41
- # Create handler for stderr (same as FastMCP default)
42
- handler = logging.StreamHandler(sys.stderr)
43
-
44
- # Create formatter with the specified format string
45
- # This will raise an error if the format string is invalid (fail fast)
46
- formatter = logging.Formatter(log_format)
47
- handler.setFormatter(formatter)
48
-
49
- # Configure root logger
50
- # This must be done before FastMCP calls logging.basicConfig()
51
- logging.root.addHandler(handler)
52
- logging.root.setLevel(logging.INFO)
53
-
54
- if transport == "stdio":
55
- return
56
-
57
- # Serving over HTTP, uvicorn logs through its own loggers, which it gives handlers that do not
58
- # propagate to the root logger. It configures them from this dictionary, which FastMCP leaves
59
- # at its default value, so its contents have to be replaced to be reached at all. The import
60
- # is local because uvicorn, like in FastMCP itself, is only needed for the transports it serves.
61
- from uvicorn.config import LOGGING_CONFIG
62
-
63
- LOGGING_CONFIG["formatters"]["default"]["fmt"] = log_format
64
- # Access records carry the request in fields of their own rather than in the message.
65
- LOGGING_CONFIG["formatters"]["access"]["fmt"] = log_format.replace(
66
- "%(message)s", '%(client_addr)s - "%(request_line)s" %(status_code)s'
67
- )