Skip to content

Commit a8c71e6

Browse files
committed
test: enable supported draft SEP coverage
1 parent d8331d9 commit a8c71e6

2 files changed

Lines changed: 54 additions & 7 deletions

File tree

.github/workflows/conformance.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ concurrency:
1414
env:
1515
# Pinned for reproducible runs; bump deliberately when the suite updates.
1616
CONFORMANCE_VERSION: "0.1.16"
17+
DRAFT_CONFORMANCE_VERSION: "0.2.0-alpha.9"
1718

1819
jobs:
1920
server:
@@ -64,6 +65,33 @@ jobs:
6465
-o conformance-results
6566
done
6667
68+
- name: Start draft conformance server
69+
run: |
70+
STATELESS=1 PORT=8002 ./target/debug/conformance-server &
71+
echo $! > draft-server.pid
72+
for _ in $(seq 1 30); do
73+
if curl -s -o /dev/null http://127.0.0.1:8002/mcp; then
74+
exit 0
75+
fi
76+
sleep 1
77+
done
78+
echo "draft conformance server did not become ready" >&2
79+
exit 1
80+
81+
- name: Run draft SEP scenarios
82+
run: |
83+
for scenario in sep-2164-resource-not-found caching http-header-validation; do
84+
npx -y "@modelcontextprotocol/conformance@${DRAFT_CONFORMANCE_VERSION}" server \
85+
--url http://127.0.0.1:8002/mcp \
86+
--scenario "$scenario" \
87+
--spec-version draft \
88+
-o conformance-results
89+
done
90+
91+
- name: Stop draft conformance server
92+
if: always()
93+
run: kill "$(cat draft-server.pid)" 2>/dev/null || true
94+
6795
- name: Stop conformance server
6896
if: always()
6997
run: kill "$(cat server.pid)" 2>/dev/null || true

conformance/src/bin/server.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use tracing_subscriber::EnvFilter;
1818
const TEST_IMAGE_DATA: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==";
1919
// Small base64-encoded WAV (silence)
2020
const TEST_AUDIO_DATA: &str = "UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=";
21+
const CACHE_TTL_MS: u64 = 60_000;
2122

2223
/// Helper to convert a serde_json::Value (must be an object) into a JsonObject
2324
fn json_object(v: Value) -> JsonObject {
@@ -45,7 +46,7 @@ impl ConformanceServer {
4546
impl ServerHandler for ConformanceServer {
4647
async fn initialize(
4748
&self,
48-
_request: InitializeRequestParams,
49+
request: InitializeRequestParams,
4950
_cx: RequestContext<RoleServer>,
5051
) -> Result<InitializeResult, ErrorData> {
5152
Ok(InitializeResult::new(
@@ -56,6 +57,7 @@ impl ServerHandler for ConformanceServer {
5657
.enable_logging()
5758
.build(),
5859
)
60+
.with_protocol_version(request.protocol_version)
5961
.with_server_info(Implementation::new("rust-conformance-server", "0.1.0"))
6062
.with_instructions("Rust MCP conformance test server"))
6163
}
@@ -206,7 +208,9 @@ impl ServerHandler for ConformanceServer {
206208
Ok(ListToolsResult {
207209
tools,
208210
..Default::default()
209-
})
211+
}
212+
.with_ttl_ms(CACHE_TTL_MS)
213+
.with_cache_scope(CacheScope::Public))
210214
}
211215

212216
async fn call_tool(
@@ -549,7 +553,9 @@ impl ServerHandler for ConformanceServer {
549553
.with_mime_type("image/png"),
550554
],
551555
..Default::default()
552-
})
556+
}
557+
.with_ttl_ms(CACHE_TTL_MS)
558+
.with_cache_scope(CacheScope::Public))
553559
}
554560

555561
async fn read_resource(
@@ -600,7 +606,13 @@ impl ServerHandler for ConformanceServer {
600606
}
601607
}
602608
};
603-
result.map(Into::into)
609+
result
610+
.map(|result| {
611+
result
612+
.with_ttl_ms(CACHE_TTL_MS)
613+
.with_cache_scope(CacheScope::Public)
614+
})
615+
.map(Into::into)
604616
}
605617

606618
async fn list_resource_templates(
@@ -615,7 +627,9 @@ impl ServerHandler for ConformanceServer {
615627
.with_mime_type("application/json"),
616628
],
617629
..Default::default()
618-
})
630+
}
631+
.with_ttl_ms(CACHE_TTL_MS)
632+
.with_cache_scope(CacheScope::Public))
619633
}
620634

621635
async fn subscribe(
@@ -674,7 +688,9 @@ impl ServerHandler for ConformanceServer {
674688
),
675689
],
676690
..Default::default()
677-
})
691+
}
692+
.with_ttl_ms(CACHE_TTL_MS)
693+
.with_cache_scope(CacheScope::Public))
678694
}
679695

680696
async fn get_prompt(
@@ -782,7 +798,10 @@ async fn main() -> anyhow::Result<()> {
782798
tracing::info!("Starting conformance server on {}", bind_addr);
783799

784800
let server = ConformanceServer::new();
785-
let config = StreamableHttpServerConfig::default();
801+
let stateless = std::env::var_os("STATELESS").is_some();
802+
let config = StreamableHttpServerConfig::default()
803+
.with_stateful_mode(!stateless)
804+
.with_json_response(stateless);
786805
let service = StreamableHttpService::new(
787806
move || Ok(server.clone()),
788807
LocalSessionManager::default().into(),

0 commit comments

Comments
 (0)