diff --git a/CLAUDE.md b/CLAUDE.md index da0da7c..751834d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -38,13 +38,21 @@ mcp run --transport sse nextcloud_mcp_server.app:mcp # Docker development environment with Nextcloud instance docker-compose up -# After code changes, rebuild and restart only the MCP server container +# After code changes, rebuild and restart the appropriate MCP server container: +# For basic auth changes (most common) - uses admin credentials docker-compose up --build -d mcp +# For OAuth changes - uses OAuth authentication flow +docker-compose up --build -d mcp-oauth + # Build Docker image docker build -t nextcloud-mcp-server . ``` +**Important: Two MCP Server Containers** +- **`mcp`** (port 8000): Uses basic auth with admin credentials. Use this for most development and testing. +- **`mcp-oauth`** (port 8001): Uses OAuth authentication. Only use this when working on OAuth-specific features or tests. + ### Environment Setup ```bash # Install dependencies @@ -96,18 +104,23 @@ Each Nextcloud app has a corresponding server module that: ### Testing Structure -- **Integration tests** in `tests/integration/` - Test real Nextcloud API interactions +- **Integration tests** in `tests/integration/` and `tests/client/`, `tests/server/` - Test real Nextcloud API interactions - **Fixtures** in `tests/conftest.py` - Shared test setup and utilities - Tests are marked with `@pytest.mark.integration` for selective running -- **Important**: Integration tests run against live Docker containers. After making code changes to the MCP server, rebuild only the MCP container with `docker-compose up --build -d mcp` before running tests +- **Important**: Integration tests run against live Docker containers. After making code changes: + - For basic auth tests: rebuild with `docker-compose up --build -d mcp` + - For OAuth tests: rebuild with `docker-compose up --build -d mcp-oauth` #### Testing Best Practices - **MANDATORY: Always run tests after implementing features or fixing bugs** - Run tests to completion before considering any task complete - If tests require modifications to pass, ask for permission before proceeding - - Use `docker-compose up --build -d mcp` to rebuild MCP container after code changes + - **Rebuild the correct container** after code changes: + - For basic auth tests (most common): `docker-compose up --build -d mcp` + - For OAuth tests: `docker-compose up --build -d mcp-oauth` - **Use existing fixtures** from `tests/conftest.py` to avoid duplicate setup work: - - `nc_mcp_client` - MCP client session for tool/resource testing + - `nc_mcp_client` - MCP client session for tool/resource testing (uses `mcp` container) + - `nc_mcp_oauth_client` - MCP client session for OAuth testing (uses `mcp-oauth` container) - `nc_client` - Direct NextcloudClient for setup/cleanup operations - `temporary_note` - Creates and cleans up test notes automatically - `temporary_addressbook` - Creates and cleans up test address books @@ -115,6 +128,7 @@ Each Nextcloud app has a corresponding server module that: - **Test specific functionality** after changes: - For Notes changes: `uv run pytest tests/integration/test_mcp.py -k "notes" -v` - For specific API changes: `uv run pytest tests/integration/test_notes_api.py -v` + - For OAuth changes: `uv run pytest tests/server/test_oauth*.py -v` (remember to rebuild `mcp-oauth` container) - **Avoid creating standalone test scripts** - use pytest with proper fixtures instead #### OAuth/OIDC Testing @@ -160,8 +174,11 @@ OAuth integration tests support both **automated** (Playwright) and **interactiv ``` **Test Environment Setup:** +- **Two MCP server containers are available:** + - `mcp` (port 8000): Uses basic auth with admin credentials - for most testing + - `mcp-oauth` (port 8001): Uses OAuth authentication - for OAuth-specific testing - Start OAuth MCP server: `docker-compose up --build -d mcp-oauth` -- OAuth server runs on port 8001 (regular MCP on 8000) +- **Important**: When working on OAuth functionality, always rebuild `mcp-oauth` container, not `mcp` - Shared OAuth client is registered once and reused across test runs - Client credentials cached in `.nextcloud_oauth_shared_test_client.json`