|
| 1 | +# MCP Conformance Tests - Spring HTTP Client (Auth Suite) |
| 2 | + |
| 3 | +This module provides a conformance test client implementation for the Java MCP SDK's **auth** suite. |
| 4 | + |
| 5 | +OAuth2 support is not implemented in the SDK itself, but we provide hooks to implement the Authorization section of the specification. One such implementation is done in Spring, with Sprign AI and the [mcp-client-security](https://github.com/springaicommunity/mcp-client-security) library. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +The conformance test client is designed to work with the [MCP Conformance Test Framework](https://github.com/modelcontextprotocol/conformance). It validates that the Java MCP SDK client, combined with Spring Security's OAuth2 support, properly implements the MCP authorization specification. |
| 10 | + |
| 11 | +Test with @modelcontextprotocol/conformance@0.1.15. |
| 12 | + |
| 13 | +## Conformance Test Results |
| 14 | + |
| 15 | +**Status: 178 passed, 1 failed, 1 warning across 14 scenarios** |
| 16 | + |
| 17 | +| Scenario | Result | Details | |
| 18 | +|---|---|---| |
| 19 | +| auth/metadata-default | ✅ Pass | 12/12 | |
| 20 | +| auth/metadata-var1 | ✅ Pass | 12/12 | |
| 21 | +| auth/metadata-var2 | ✅ Pass | 12/12 | |
| 22 | +| auth/metadata-var3 | ✅ Pass | 12/12 | |
| 23 | +| auth/basic-cimd | ⚠️ Warning | 12/12 passed, 1 warning | |
| 24 | +| auth/scope-from-www-authenticate | ✅ Pass | 13/13 | |
| 25 | +| auth/scope-from-scopes-supported | ✅ Pass | 13/13 | |
| 26 | +| auth/scope-omitted-when-undefined | ✅ Pass | 13/13 | |
| 27 | +| auth/scope-step-up | ❌ Fail | 11/12 (1 failed) | |
| 28 | +| auth/scope-retry-limit | ✅ Pass | 11/11 | |
| 29 | +| auth/token-endpoint-auth-basic | ✅ Pass | 17/17 | |
| 30 | +| auth/token-endpoint-auth-post | ✅ Pass | 17/17 | |
| 31 | +| auth/token-endpoint-auth-none | ✅ Pass | 17/17 | |
| 32 | +| auth/pre-registration | ✅ Pass | 6/6 | |
| 33 | + |
| 34 | +See [VALIDATION_RESULTS.md](../VALIDATION_RESULTS.md) for the full project validation results. |
| 35 | + |
| 36 | +## Architecture |
| 37 | + |
| 38 | +The client is a Spring Boot application that reads test scenarios from environment variables and accepts the server URL as a command-line argument, following the conformance framework's conventions: |
| 39 | + |
| 40 | +- **MCP_CONFORMANCE_SCENARIO**: Environment variable specifying which test scenario to run |
| 41 | +- **MCP_CONFORMANCE_CONTEXT**: Environment variable with JSON context (used by `auth/pre-registration`) |
| 42 | +- **Server URL**: Passed as the last command-line argument |
| 43 | + |
| 44 | +### Scenario Routing |
| 45 | + |
| 46 | +The application uses Spring's conditional configuration to select the appropriate scenario at startup: |
| 47 | + |
| 48 | +- **`DefaultConfiguration`** — Activated for all scenarios except `auth/pre-registration`. Uses the OAuth2 Authorization Code flow with dynamic client registration via `McpClientOAuth2Configurer`. |
| 49 | +- **`PreRegistrationConfiguration`** — Activated only for `auth/pre-registration`. Uses the Client Credentials flow with pre-registered client credentials read from `MCP_CONFORMANCE_CONTEXT`. |
| 50 | + |
| 51 | +### Key Dependencies |
| 52 | + |
| 53 | +- **Spring Boot 4.0** with Spring Security OAuth2 Client |
| 54 | +- **Spring AI MCP Client** (`spring-ai-starter-mcp-client`) |
| 55 | +- **mcp-client-security** — Community library providing MCP-specific OAuth2 integration (metadata discovery, dynamic client registration, transport context) |
| 56 | + |
| 57 | +## Building |
| 58 | + |
| 59 | +Build the executable JAR: |
| 60 | + |
| 61 | +```bash |
| 62 | +cd conformance-tests/client-spring-http-client |
| 63 | +../../mvnw clean package -DskipTests |
| 64 | +``` |
| 65 | + |
| 66 | +This creates an executable JAR at: |
| 67 | +``` |
| 68 | +target/client-spring-http-client-0.18.0-SNAPSHOT.jar |
| 69 | +``` |
| 70 | + |
| 71 | +## Running Tests |
| 72 | + |
| 73 | +### Using the Conformance Framework |
| 74 | + |
| 75 | +Run the full auth suite: |
| 76 | + |
| 77 | +```bash |
| 78 | +npx @modelcontextprotocol/conformance@0.1.15 client \ |
| 79 | + --spec-version 2025-11-25 \ |
| 80 | + --command "java -jar conformance-tests/client-spring-http-client/target/client-spring-http-client-0.18.0-SNAPSHOT.jar" \ |
| 81 | + --suite auth |
| 82 | +``` |
| 83 | + |
| 84 | +Run a single scenario: |
| 85 | + |
| 86 | +```bash |
| 87 | +npx @modelcontextprotocol/conformance@0.1.15 client \ |
| 88 | + --spec-version 2025-11-25 \ |
| 89 | + --command "java -jar conformance-tests/client-spring-http-client/target/client-spring-http-client-0.18.0-SNAPSHOT.jar" \ |
| 90 | + --scenario auth/metadata-default |
| 91 | +``` |
| 92 | + |
| 93 | +Run with verbose output: |
| 94 | + |
| 95 | +```bash |
| 96 | +npx @modelcontextprotocol/conformance@0.1.15 client \ |
| 97 | + --spec-version 2025-11-25 \ |
| 98 | + --command "java -jar conformance-tests/client-spring-http-client/target/client-spring-http-client-0.18.0-SNAPSHOT.jar" \ |
| 99 | + --scenario auth/metadata-default \ |
| 100 | + --verbose |
| 101 | +``` |
| 102 | + |
| 103 | +### Manual Testing |
| 104 | + |
| 105 | +You can also run the client manually if you have a test server: |
| 106 | + |
| 107 | +```bash |
| 108 | +export MCP_CONFORMANCE_SCENARIO=auth/metadata-default |
| 109 | +java -jar conformance-tests/client-spring-http-client/target/client-spring-http-client-0.18.0-SNAPSHOT.jar http://localhost:3000/mcp |
| 110 | +``` |
| 111 | + |
| 112 | +## Known Issues |
| 113 | + |
| 114 | +1. **auth/scope-step-up** (1 failure) — The client does not fully handle scope step-up challenges where the server requests additional scopes after initial authorization. |
| 115 | +2. **auth/basic-cimd** (1 warning) — Minor conformance warning in the basic Client-Initiated Metadata Discovery flow. |
| 116 | + |
| 117 | +## References |
| 118 | + |
| 119 | +- [MCP Specification — Authorization](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization) |
| 120 | +- [MCP Conformance Tests](https://github.com/modelcontextprotocol/conformance) |
| 121 | +- [mcp-client-security Library](https://github.com/springaicommunity/mcp-client-security) |
| 122 | +- [SDK Integration Guide](https://github.com/modelcontextprotocol/conformance/blob/main/SDK_INTEGRATION.md) |
0 commit comments