fix: address PR review feedback and fix CI test failures
- Revert default transport to streamable-http (not a breaking change) - Extract AVAILABLE_APPS constant to server/__init__.py (DRY) - Wrap get_stdio_mcp ValueError in click.ClickException for clean errors - Fix test_stdio.py: call _reload_config() so dynaconf sees env changes - Use lazy %-style logging in stdio.py - Add private API comments in test assertions - Derive --enable-app CLI choices from AVAILABLE_APPS - README: show explicit --transport stdio in uvx examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
09006fcea9
commit
e9c46a04a0
+4
-10
@@ -108,8 +108,6 @@ def test_cli_options_set_environment_variables(runner, clean_env, monkeypatch):
|
||||
_ = runner.invoke(
|
||||
run,
|
||||
[
|
||||
"--transport",
|
||||
"streamable-http",
|
||||
"--nextcloud-host",
|
||||
"https://test.example.com",
|
||||
"--nextcloud-username",
|
||||
@@ -166,8 +164,6 @@ def test_cli_options_override_environment_variables(runner, monkeypatch):
|
||||
_ = runner.invoke(
|
||||
run,
|
||||
[
|
||||
"--transport",
|
||||
"streamable-http",
|
||||
"--nextcloud-host",
|
||||
"https://from-cli.example.com",
|
||||
"--nextcloud-username",
|
||||
@@ -218,7 +214,7 @@ def test_environment_variables_used_when_cli_not_provided(runner, monkeypatch):
|
||||
monkeypatch.setattr("nextcloud_mcp_server.cli.get_app", mock_get_app)
|
||||
|
||||
# Don't provide any CLI options - should use env vars
|
||||
_ = runner.invoke(run, ["--transport", "streamable-http"])
|
||||
_ = runner.invoke(run, [])
|
||||
|
||||
# Verify env vars were used
|
||||
assert captured_env["NEXTCLOUD_HOST"] == "https://from-env.example.com"
|
||||
@@ -250,7 +246,7 @@ def test_default_values(runner, clean_env, monkeypatch):
|
||||
monkeypatch.setattr("nextcloud_mcp_server.cli.get_app", mock_get_app)
|
||||
|
||||
# Don't provide CLI options or env vars - should use defaults
|
||||
_ = runner.invoke(run, ["--transport", "streamable-http"])
|
||||
_ = runner.invoke(run, [])
|
||||
|
||||
# Verify default values
|
||||
assert captured_env["NEXTCLOUD_OIDC_SCOPES"] == (
|
||||
@@ -282,14 +278,12 @@ def test_oauth_token_type_case_normalization(runner, clean_env, monkeypatch):
|
||||
monkeypatch.setattr("nextcloud_mcp_server.cli.get_app", mock_get_app)
|
||||
|
||||
# Test uppercase JWT
|
||||
runner.invoke(run, ["--transport", "streamable-http", "--oauth-token-type", "JWT"])
|
||||
runner.invoke(run, ["--oauth-token-type", "JWT"])
|
||||
assert captured_env["NEXTCLOUD_OIDC_TOKEN_TYPE"] in ["JWT", "jwt"]
|
||||
|
||||
# Test mixed case Bearer
|
||||
captured_env.clear()
|
||||
runner.invoke(
|
||||
run, ["--transport", "streamable-http", "--oauth-token-type", "Bearer"]
|
||||
)
|
||||
runner.invoke(run, ["--oauth-token-type", "Bearer"])
|
||||
assert captured_env["NEXTCLOUD_OIDC_TOKEN_TYPE"] in ["Bearer", "bearer"]
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import pytest
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
from nextcloud_mcp_server.config import _reload_config
|
||||
from nextcloud_mcp_server.config_validators import AuthMode
|
||||
from nextcloud_mcp_server.stdio import get_stdio_mcp
|
||||
|
||||
@@ -13,6 +14,9 @@ def single_user_env(monkeypatch):
|
||||
monkeypatch.setenv("NEXTCLOUD_HOST", "https://cloud.example.com")
|
||||
monkeypatch.setenv("NEXTCLOUD_USERNAME", "admin")
|
||||
monkeypatch.setenv("NEXTCLOUD_PASSWORD", "secret")
|
||||
# Ensure multi-user mode is off (may leak from other tests)
|
||||
monkeypatch.delenv("ENABLE_MULTI_USER_BASIC_AUTH", raising=False)
|
||||
_reload_config()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@@ -48,6 +52,7 @@ def test_get_stdio_mcp_rejects_non_single_user_mode(monkeypatch):
|
||||
def test_get_stdio_mcp_registers_all_apps_by_default(single_user_env):
|
||||
"""All app tool groups are registered when no filter is specified."""
|
||||
mcp = get_stdio_mcp()
|
||||
# NOTE: _tool_manager is a FastMCP internal; may break on SDK upgrades
|
||||
tools = mcp._tool_manager.list_tools()
|
||||
tool_names = {t.name for t in tools}
|
||||
|
||||
@@ -68,6 +73,7 @@ def test_get_stdio_mcp_registers_all_apps_by_default(single_user_env):
|
||||
def test_get_stdio_mcp_respects_enabled_apps(single_user_env):
|
||||
"""Only specified apps have their tools registered."""
|
||||
mcp = get_stdio_mcp(enabled_apps=["notes"])
|
||||
# NOTE: _tool_manager is a FastMCP internal; may break on SDK upgrades
|
||||
tools = mcp._tool_manager.list_tools()
|
||||
tool_names = {t.name for t in tools}
|
||||
|
||||
@@ -81,6 +87,7 @@ def test_get_stdio_mcp_respects_enabled_apps(single_user_env):
|
||||
def test_get_stdio_mcp_no_semantic_tools(single_user_env):
|
||||
"""Semantic search tools are never registered in stdio mode."""
|
||||
mcp = get_stdio_mcp()
|
||||
# NOTE: _tool_manager is a FastMCP internal; may break on SDK upgrades
|
||||
tools = mcp._tool_manager.list_tools()
|
||||
tool_names = {t.name for t in tools}
|
||||
|
||||
@@ -92,5 +99,6 @@ def test_get_stdio_mcp_no_semantic_tools(single_user_env):
|
||||
def test_get_stdio_mcp_registers_capabilities_resource(single_user_env):
|
||||
"""The nc://capabilities resource is registered."""
|
||||
mcp = get_stdio_mcp()
|
||||
# NOTE: _resource_manager._resources is a FastMCP internal; may break on SDK upgrades
|
||||
resources = mcp._resource_manager._resources
|
||||
assert "nc://capabilities" in resources
|
||||
|
||||
Reference in New Issue
Block a user