Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3c36239
add conformance tests for server and client
devcrocod Mar 2, 2026
42d14f0
rewrite conformance tests, rework server-client implementation
devcrocod Mar 5, 2026
21846f5
add OAuth authorization and client credentials scenarios to conforman…
devcrocod Mar 5, 2026
c241bda
add OAuth authorization and client credentials scenarios to conforman…
devcrocod Mar 6, 2026
4c7900a
replace `System.err` with KotlinLogging in ConformanceClient, add bas…
devcrocod Mar 6, 2026
aebff7a
remove toolLists from basic client
devcrocod Mar 6, 2026
6e30638
update protocol version constants
devcrocod Mar 6, 2026
09ff656
remove unused `allowedOrigins` configuration from ConformanceServer s…
devcrocod Mar 6, 2026
0e80c11
add support for baseline file of expected failures in conformance tests
devcrocod Mar 6, 2026
b37f568
update elicitation schema to include `username` and `email`, adjust r…
devcrocod Mar 6, 2026
70ace75
delete `results` directory during `clean` task in conformance-test build
devcrocod Mar 6, 2026
928c68e
conditionally apply Detekt plugin to exclude conformance-test
devcrocod Mar 6, 2026
30ab88e
add resource parameter support and pre-registration in OAuth authoriz…
devcrocod Mar 6, 2026
914b531
remove OAuth authorization handler and simplify resource metadata dis…
devcrocod Mar 6, 2026
1ba27f8
add CSRF state parameter validation and enhance error handling in OAu…
devcrocod Mar 7, 2026
7c3b6ce
remove redundant non-null assertions in authCodeFlow implementation
devcrocod Mar 7, 2026
d0c0d96
add new expected failures to conformance test baseline
devcrocod Mar 7, 2026
5369a57
specify explicit types for cached discovery and credentials in authCo…
devcrocod Mar 7, 2026
451940f
improve error handling in `run-conformance.sh` by adding fallback for…
devcrocod Mar 7, 2026
94dfe80
update README to reflect 18 OAuth scenarios in client-auth suite and …
devcrocod Mar 7, 2026
c465ffe
add Cross-App Access scenario and validate PRM resource in authCodeFl…
devcrocod Mar 7, 2026
c7695d3
fix: handle sse 404 (#593)
devcrocod Mar 9, 2026
d9e82b2
fix: serialization empty response without id (#592)
devcrocod Mar 9, 2026
5ef15e9
add HTTP timeout configuration to ConformanceClient for improved requ…
devcrocod Mar 9, 2026
6e9c082
refactor ConformanceClient to centralize HTTP client creation with sh…
devcrocod Mar 9, 2026
7c1a1cf
parameterize JDK and Node.js versions in workflow, add new auth scena…
devcrocod Mar 9, 2026
4892b7c
add support for additional auth scenarios in conformance tests and re…
devcrocod Mar 9, 2026
0a3b4bd
feat: add SSE reconnection with retry support (#596)
devcrocod Mar 11, 2026
6f1ae61
feat(conformance): add `list` command to conformance test script
kpavlov Mar 11, 2026
a3d09d1
Merge branch 'main' into devcrocod/conformance-tests
kpavlov Mar 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 137 additions & 38 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,166 @@ on:
push:
branches: [ main ]

env:
JAVA_VERSION: '21'
JAVA_DISTRIBUTION: temurin
NODE_VERSION: '22'


concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Cancel only when the run is NOT on `main` branch
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
run-conformance:
runs-on: ${{ matrix.os }}
name: Run Conformance Tests on ${{ matrix.os }}
server:
runs-on: ubuntu-latest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observation: Conformance tests are no longer being run on different platforms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, it's jvm

name: Conformance Server Tests
timeout-minutes: 20

steps:
- uses: actions/checkout@v6

- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}

- name: Build
run: ./gradlew :conformance-test:installDist

- name: Start server
run: |
MCP_PORT=3001 conformance-test/build/install/conformance-test/bin/conformance-test &
for i in $(seq 1 30); do
if curl -s -o /dev/null http://localhost:3001/mcp; then
echo "Server is ready"
break
fi
sleep 1
done

- name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.15
Copy link
Copy Markdown
Contributor

@kpavlov kpavlov Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's run the same run-conformance.sh here so it is consistent with the local testing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doen't work for uses field

with:
mode: server
url: http://localhost:3001/mcp
suite: active
node-version: ${{ env.NODE_VERSION }}
expected-failures: ./conformance-test/conformance-baseline.yml

client:
runs-on: ubuntu-latest
name: "Conformance Client Tests: ${{ matrix.scenario }}"
timeout-minutes: 20
env:
JAVA_OPTS: "-Xmx8g -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dkotlin.daemon.jvm.options=-Xmx6g"

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
max-workers: 3
- os: windows-latest
max-workers: 3
- os: macos-latest
max-workers: 2
scenario:
- initialize
- tools_call
- elicitation-sep1034-client-defaults
- sse-retry

steps:
- uses: actions/checkout@v6

- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}

- name: Build
run: ./gradlew :conformance-test:installDist

- name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.15
with:
mode: client
command: conformance-test/build/install/conformance-test/bin/conformance-client
scenario: ${{ matrix.scenario }}
node-version: ${{ env.NODE_VERSION }}
expected-failures: ./conformance-test/conformance-baseline.yml

auth:
runs-on: ubuntu-latest
name: Conformance Auth Tests
timeout-minutes: 20

steps:
- uses: actions/checkout@v6

- name: Set up JDK 21
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Setup Node.js
uses: actions/setup-node@v6
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
node-version: '22' # increase only after https://github.com/nodejs/node/issues/56645 will be fixed
cache-read-only: ${{ github.ref != 'refs/heads/main' }}

- name: Setup Conformance Tests
working-directory: conformance-test
run: |-
npm install -g @modelcontextprotocol/conformance@0.1.8
- name: Build
run: ./gradlew :conformance-test:installDist

- name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.15
with:
mode: client
command: conformance-test/build/install/conformance-test/bin/conformance-client
suite: auth
node-version: ${{ env.NODE_VERSION }}
expected-failures: ./conformance-test/conformance-baseline.yml

auth-scenarios:
runs-on: ubuntu-latest
name: "Conformance Auth Scenario: ${{ matrix.scenario }}"
timeout-minutes: 20

strategy:
fail-fast: false
matrix:
scenario:
- auth/client-credentials-jwt
- auth/client-credentials-basic
- auth/cross-app-access-complete-flow

steps:
- uses: actions/checkout@v6

- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
add-job-summary: 'always'
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
gradle-home-cache-includes: |
caches
notifications
sdks
../.konan/**

- name: Run Conformance Tests
run: |-
./gradlew :conformance-test:test --no-daemon --max-workers ${{ matrix.max-workers }}

- name: Upload Conformance Results
if: always()
uses: actions/upload-artifact@v7

- name: Build
run: ./gradlew :conformance-test:installDist

- name: Run conformance tests
uses: modelcontextprotocol/conformance@v0.1.15
with:
name: conformance-results-${{ matrix.os }}
path: conformance-test/results/
mode: client
command: conformance-test/build/install/conformance-test/bin/conformance-client
scenario: ${{ matrix.scenario }}
node-version: ${{ env.NODE_VERSION }}
expected-failures: ./conformance-test/conformance-baseline.yml
13 changes: 8 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ dependencies {
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "org.jetbrains.kotlinx.kover")
apply(plugin = "dev.detekt")

detekt {
config = files("$rootDir/config/detekt/detekt.yml")
buildUponDefaultConfig = true
failOnSeverity.set(FailOnSeverity.Error)
if (name != "conformance-test" && name != "docs") {
apply(plugin = "dev.detekt")

detekt {
config = files("$rootDir/config/detekt/detekt.yml")
buildUponDefaultConfig = true
failOnSeverity.set(FailOnSeverity.Error)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions conformance-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/results/
130 changes: 130 additions & 0 deletions conformance-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# MCP Conformance Tests

Conformance tests for the Kotlin MCP SDK. Uses the external
[`@modelcontextprotocol/conformance`](https://www.npmjs.com/package/@modelcontextprotocol/conformance)
runner (pinned to **0.1.15**) to validate compliance with the MCP specification.

## Prerequisites

- **JDK 17+**
- **Node.js 18+** and `npx` (for the conformance runner)
- **curl** (used to poll server readiness)

## Quick Start

Run **all** suites (server, client core, client auth) from the project root:

```bash
./conformance-test/run-conformance.sh all
```

## Commands

```
./conformance-test/run-conformance.sh <command> [extra-args...]
```

| Command | What it does |
|---------------|--------------------------------------------------------------------------------------|
| `list` | [List scenarios available in MCP Conformance Test Framework][list-scenarios-command] |
| `server` | Starts the Ktor conformance server, runs the server test suite against it |
| `client` | Runs the client test suite (`initialize`, `tools_call`, `elicitation`, `sse-retry`) |
| `client-auth` | Runs the client auth test suite (20 OAuth scenarios) |
| `all` | Runs all three suites sequentially |

Any `[extra-args]` are forwarded to the conformance runner (e.g. `--verbose`).

## What the Script Does

1. **Builds** the module via `./gradlew :conformance-test:installDist`
2. For `server` — starts the conformance server on `localhost:3001`, polls until ready
3. Invokes `npx @modelcontextprotocol/conformance@0.1.15` with the appropriate arguments
4. Saves results to `conformance-test/results/<command>/`
5. Cleans up the server process on exit
6. Exits non-zero if any suite fails

## Environment Variables

| Variable | Default | Description |
|------------|---------|---------------------------------|
| `MCP_PORT` | `3001` | Port for the conformance server |

## Project Structure

```
conformance-test/
├── run-conformance.sh # Single entry point script
├── conformance-baseline.yml # Expected failures for known SDK limitations
└── src/main/kotlin/.../conformance/
├── ConformanceServer.kt # Ktor server entry point (StreamableHTTP, DNS rebinding, EventStore)
├── ConformanceClient.kt # Scenario-based client entry point (MCP_CONFORMANCE_SCENARIO routing)
├── ConformanceTools.kt # 18 tool registrations
├── ConformanceResources.kt # 5 resource registrations (static, binary, template, watched, dynamic)
├── ConformancePrompts.kt # 5 prompt registrations (simple, args, image, embedded, dynamic)
├── ConformanceCompletions.kt # completion/complete handler
├── InMemoryEventStore.kt # EventStore impl for SSE resumability (SEP-1699)
└── auth/ # OAuth client for 20 auth scenarios
├── registration.kt # Scenario handler registration
├── utils.kt # Shared utilities: JSON instance, constants, extractOrigin()
├── discovery.kt # Protected Resource Metadata + AS Metadata discovery
├── pkce.kt # PKCE code verifier/challenge generation + AS capability check
├── tokenExchange.kt # Token endpoint interaction (exchange code, error handling)
├── authCodeFlow.kt # Main Authorization Code flow handler (runAuthClient + interceptor)
├── scopeHandling.kt # Scope selection strategy + step-up 403 handling
├── clientRegistration.kt # Client registration logic (pre-reg, CIMD, dynamic)
├── JWTScenario.kt # Client Credentials JWT scenario
├── basicScenario.kt # Client Credentials Basic scenario
└── crossAppAccessScenario.kt # Cross-App Access (SEP-990) scenario
```

## Test Suites

### Server Suite

Tests the conformance server against all server scenarios:

| Category | Scenarios |
|-------------|-------------------------------------------------------------------------------------------------------------------------------------|
| Lifecycle | initialize, ping |
| Tools | text, image, audio, embedded, multiple, progress, logging, error, sampling, elicitation, dynamic, reconnection, JSON Schema 2020-12 |
| Resources | list, read-text, read-binary, templates, subscribe, dynamic |
| Prompts | simple, with-args, with-image, with-embedded-resource, dynamic |
| Completions | complete |
| Security | DNS rebinding protection |

### Client Core Suite

| Scenario | Description |
|---------------------------------------|-----------------------------------------------|
| `initialize` | Connect, list tools, close |
| `tools_call` | Connect, call `add_numbers(a=5, b=3)`, close |
| `elicitation-sep1034-client-defaults` | Elicitation with `applyDefaults` capability |
| `sse-retry` | Call `test_reconnection`, verify reconnection |

### Client Auth Suite

17 OAuth Authorization Code scenarios + 2 Client Credentials scenarios (`jwt`, `basic`) + 1 Cross-App Access scenario = 20 total.

> [!NOTE]
> Auth scenarios are implemented using Ktor's `HttpClient` plugins (`HttpSend` interceptor,
> `ktor-client-auth`) as a standalone OAuth client. They do not use the SDK's built-in auth support.

## Known SDK Limitations

8 scenarios are expected to fail due to current SDK limitations (tracked in [
`conformance-baseline.yml`](conformance-baseline.yml).

| Scenario | Suite | Root Cause |
|---------------------------------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| `tools-call-with-logging` | server | Notifications from tool handlers have no `relatedRequestId`; transport routes them to the standalone SSE stream instead of the request-specific stream |
| `tools-call-with-progress` | server | *(same as above)* |
| `tools-call-sampling` | server | *(same as above)* |
| `tools-call-elicitation` | server | *(same as above)* |
| `elicitation-sep1034-defaults` | server | *(same as above)* |
| `elicitation-sep1330-enums` | server | *(same as above)* |
| `resources-templates-read` | server | SDK does not implement `addResourceTemplate()` with URI pattern matching; resources are looked up by exact URI |
| `elicitation-sep1034-client-defaults` | client | SDK does not fill in `default` values from the elicitation request schema before sending the response |

These failures reveal SDK gaps and are intentionally not fixed in this module.

[list-scenarios-command]: https://github.com/modelcontextprotocol/conformance/tree/main?tab=readme-ov-file#list-available-scenarios
Loading
Loading