Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

Support modern MCP SDK transports in protected URL probes (#465)

Narendran Raghavana0b65a91d512
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1d339116..c8f17392 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -163,6 +163,59 @@ jobs:
tests/validators/test_markdown.py
tests/test_cli_html_parser_compat.py
+ mcp-sdk-compatibility:
+ name: MCP probe compatibility (SDK ${{ matrix.mcp-version }})
+ needs: classify-changes
+ if: ${{ !cancelled() && needs.classify-changes.outputs.docs_only != 'true' }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ mcp-version: ["1.28.1", "2.3.0"]
+ env:
+ MCP_SDK_VERSION: ${{ matrix.mcp-version }}
+ steps:
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+ with:
+ persist-credentials: false
+ - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
+ with:
+ python-version: "3.12"
+ - uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
+ with:
+ version: "0.11.27"
+ - name: Build the public wheel
+ run: uv build --wheel --python 3.12 --no-sources
+ - name: Install the isolated probe contract
+ shell: bash
+ run: |
+ set -euo pipefail
+ wheel="$(find "$PWD/dist" -maxdepth 1 -type f -name 'skillevaluator-*.whl' -print -quit)"
+ test -n "$wheel"
+ uv venv --python 3.12 "$RUNNER_TEMP/mcp-probe-compat"
+ # Keep the public tier3 extra's supported SDK range unchanged. The
+ # base wheel lets this forward-compatibility contract exercise SDK 2.
+ # The direct legacy-client tests also need the original HTTP stack.
+ uv pip install --python "$RUNNER_TEMP/mcp-probe-compat/bin/python" \
+ "$wheel" "mcp==$MCP_SDK_VERSION" "pytest>=8.4.0" "httpx>=0.27"
+ - name: Verify the installed probe with the selected SDK
+ shell: bash
+ run: |
+ set -euo pipefail
+ "$RUNNER_TEMP/mcp-probe-compat/bin/python" - <<'PY'
+ import os
+ import sys
+ from importlib.metadata import version
+ from pathlib import Path
+
+ import skillevaluator
+
+ assert version("mcp") == os.environ["MCP_SDK_VERSION"]
+ assert Path(skillevaluator.__file__).resolve().is_relative_to(Path(sys.prefix).resolve())
+ PY
+ "$RUNNER_TEMP/mcp-probe-compat/bin/python" -m pytest -q \
+ tests/tier3/test_mcp_proof.py tests/tier3/test_mcp_proof_sdk_compat.py
+
rhel8-security-install:
name: RHEL 8 security install
needs: classify-changes
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e8fda5ad..3b03212f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -308,6 +308,12 @@ All notable changes to SkillEvaluator are documented in this file.
### Fixed
+- Public MCP URL probes handle modern SDK client and stream APIs while retaining
+ checked-address connections, header grants, response limits, and bounded
+ cleanup. Redirect responses are refused before SDK-level redirect handling.
+ Isolated wheel tests cover SDK 1.28.1 and 2.3.0; the supported Tier 3 dependency
+ range remains unchanged.
+
- Repository CI can opt in to reviewed, per-skill SkillSpector baselines from
the PR or merge request's target revision. Policy files from the proposed
changes cannot approve their own exceptions.
diff --git a/src/skillevaluator/tier3/mcp_proof.py b/src/skillevaluator/tier3/mcp_proof.py
index 197c7ee2..a39238af 100644
--- a/src/skillevaluator/tier3/mcp_proof.py
+++ b/src/skillevaluator/tier3/mcp_proof.py
@@ -425,8 +425,9 @@ def _capped_client(
connect_timeout: float,
read_timeout: float,
on_failure: Callable[[str], None] | None = None,
+ http_stack: tuple[Any, Any] | None = None,
):
- """An httpx client that never follows redirects, ignores proxy/.netrc settings, and caps bodies.
+ """A client that never follows redirects, ignores proxy/.netrc settings, and caps bodies.
Its TCP connections go only to ``addresses`` (the endpoint policy's checked
addresses) and only for ``url``'s host and port. TLS still verifies the
@@ -436,8 +437,11 @@ def _capped_client(
told first: the ``mcp`` client catches transport errors and would otherwise
wait for a reply until the total timeout.
"""
- import httpcore
- import httpx
+ if http_stack is None:
+ import httpcore
+ import httpx
+ else:
+ httpx, httpcore = http_stack
target = httpx.URL(url)
pinned_host = target.raw_host.decode("ascii").lower()
@@ -509,6 +513,14 @@ def _capped_client(
async def handle_async_request(self, request: httpx.Request) -> httpx.Response:
request.headers["Accept-Encoding"] = "identity"
response = await self._inner.handle_async_request(request)
+ if 300 <= response.status_code < 400:
+ # SDK2 follows some redirects itself, ignoring follow_redirects.
+ # Refuse before its transport can replay headers or requests.
+ await response.aclose()
+ message = "redirect responses are not followed"
+ if on_failure is not None:
+ on_failure(message)
+ raise _ResponseRefused(message)
encoding = response.headers.get("content-encoding", "identity").strip().casefold()
if encoding != "identity":
# Inspect headers before exposing the stream to HTTPX's decoder.
@@ -615,8 +627,16 @@ async def _probe_session(
) -> tuple[list[str], dict[str, dict[str, Any]]]:
import anyio
from mcp import ClientSession
+ from mcp.client import streamable_http
from mcp.client.sse import sse_client
- from mcp.client.streamable_http import streamable_http_client
+
+ # Read the SDK's module alias without constructing its unconstrained default
+ # client. Both transports must use the same matching HTTP client/core stack.
+ http_stack = None
+ if (sdk_http := getattr(streamable_http, "httpx2", None)) is not None:
+ import httpcore2
+
+ http_stack = (sdk_http, httpcore2)
abort = _ProbeAbort()
@@ -629,6 +649,7 @@ async def _probe_session(
connect_timeout=CONNECT_TIMEOUT_S,
read_timeout=READ_TIMEOUT_S,
on_failure=abort.fail,
+ http_stack=http_stack,
)
listed: Any = None
@@ -650,8 +671,8 @@ async def _probe_session(
else:
async with (
factory(headers) as client,
- streamable_http_client(url, http_client=client) as (read, write, _session_id),
- ClientSession(read, write) as session,
+ streamable_http.streamable_http_client(url, http_client=client) as streams,
+ ClientSession(*streams[:2]) as session,
):
await session.initialize()
listed = await session.list_tools()
@@ -668,7 +689,10 @@ async def _probe_session(
if isinstance(name, str) and name and len(names) < MAX_PROBE_TOOLS:
safe = _detail(name)[:MAX_TOOL_NAME_CHARS]
names.append(safe)
- schema = _input_schema(getattr(tool, "inputSchema", None))
+ raw_schema = getattr(tool, "inputSchema", None)
+ if raw_schema is None: # SDK2 uses native snake-case model attributes.
+ raw_schema = getattr(tool, "input_schema", None)
+ schema = _input_schema(raw_schema)
if schema is not None and safe == name:
schemas[name] = schema
return names, schemas
@@ -713,7 +737,6 @@ def probe_mcp_server(
note = _header_note(missing, withheld, sent, _target_host(url))
try:
import anyio
- import httpx # noqa: F401 -- availability check
import mcp # noqa: F401 -- availability check
except ImportError:
return _entry(
diff --git a/tests/tier3/test_mcp_proof.py b/tests/tier3/test_mcp_proof.py
index f6616a8f..85c010ce 100644
--- a/tests/tier3/test_mcp_proof.py
+++ b/tests/tier3/test_mcp_proof.py
@@ -622,8 +622,11 @@ def test_a_slow_dns_lookup_counts_against_the_probe_deadline() -> None:
def test_probed_tool_names_and_details_are_printable(fake_mcp: str, monkeypatch: pytest.MonkeyPatch) -> None:
hostile = [
- {"name": "\x1b[31mred\x1b[0m", "inputSchema": {"type": [["x"]]}},
- {"name": "\x1b]0;pwned\x07title", "inputSchema": {"type": [{"x": "string"}]}},
+ {"name": "\x1b[31mred\x1b[0m", "inputSchema": {"type": "object", "properties": {"bad": {"type": [["x"]]}}}},
+ {
+ "name": "\x1b]0;pwned\x07title",
+ "inputSchema": {"type": "object", "properties": {"bad": {"type": [{"x": "string"}]}}},
+ },
{
"name": "bell\x07\x9bcsi",
"inputSchema": {"type": "object", "properties": {"nested": {"type": [["x"]], "minimum": 1}}},
diff --git a/tests/tier3/test_mcp_proof_sdk_compat.py b/tests/tier3/test_mcp_proof_sdk_compat.py
new file mode 100644
index 00000000..5da50e7b
--- /dev/null
+++ b/tests/tier3/test_mcp_proof_sdk_compat.py
@@ -0,0 +1,391 @@
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""SDK compatibility retains the private URL probe's constrained transport."""
+
+from __future__ import annotations
+
+import asyncio
+import builtins
+import gzip
+import netrc
+import ssl
+import threading
+from contextlib import asynccontextmanager
+from importlib import import_module
+from importlib.metadata import version
+
+import anyio
+import pytest
+import test_mcp_proof as protocol_peer
+from test_mcp_proof import LOCAL, _FakeServer, _Handler
+from test_mcp_proof import fake_mcp as fake_mcp # noqa: PLC0414 -- pytest fixture re-export
+
+from skillevaluator.tier3 import mcp_proof as proof
+
+
+def _native_stack():
+ modern = int(version("mcp").split(".", 1)[0]) >= 2
+ return (
+ (import_module("httpx2"), import_module("httpcore2"))
+ if modern
+ else (import_module("httpx"), import_module("httpcore"))
+ )
+
+
+def test_two_stream_transport_uses_real_session(monkeypatch, fake_mcp):
+ """A modern two-stream boundary must work even in locked SDK1 CI."""
+ from mcp.client import streamable_http
+
+ native = streamable_http.streamable_http_client
+
+ @asynccontextmanager
+ async def two_streams(url, *, http_client):
+ async with native(url, http_client=http_client) as streams:
+ yield streams[:2]
+
+ monkeypatch.setattr(streamable_http, "streamable_http_client", two_streams)
+
+ entry = proof.probe_mcp_server({"name": "docs", "url": f"{fake_mcp}/mcp"}, allowed_private_hosts=LOCAL)
+
+ assert entry["status"] == "reachable-host", entry
+ assert entry["tools"] == ["search", "get_page"]
+
+
+def test_session_owns_constrained_client_from_installed_sdk_family(monkeypatch, fake_mcp):
+ clients = []
+ original = proof._capped_client
+
+ def recording_client(headers, **kwargs):
+ client = original(headers, **kwargs)
+ clients.append(client)
+ return client
+
+ monkeypatch.setattr(proof, "_capped_client", recording_client)
+
+ entry = proof.probe_mcp_server({"name": "docs", "url": f"{fake_mcp}/mcp"}, allowed_private_hosts=LOCAL)
+
+ expected = import_module("httpx2" if int(version("mcp").split(".", 1)[0]) >= 2 else "httpx")
+ assert entry["status"] == "reachable-host", entry
+ assert len(clients) == 1
+ assert isinstance(clients[0], expected.AsyncClient)
+ assert clients[0].is_closed
+ assert clients[0].trust_env is False
+ assert clients[0].follow_redirects is False
+
+
[email protected]("oversize", [False, True])
+def test_real_protocol_preserves_sanitized_and_bounded_argument_schema(monkeypatch, fake_mcp, oversize):
+ schema = (
+ {"type": "object", "properties": {f"p{i}": {"type": "string", "enum": ["a" * 50]} for i in range(64)}}
+ if oversize
+ else {
+ "type": "object",
+ "description": "not exported",
+ "required": ["count"],
+ "properties": {"count": {"type": "integer", "minimum": 1, "description": "not exported"}},
+ }
+ )
+ monkeypatch.setattr(protocol_peer, "TOOLS", [{"name": "search", "inputSchema": schema}])
+
+ entry = proof.probe_mcp_server({"name": "docs", "url": f"{fake_mcp}/mcp"}, allowed_private_hosts=LOCAL)
+
+ assert entry["status"] == "reachable-host", entry
+ assert entry["tools"] == ["search"]
+ if oversize:
+ assert "input_schemas" not in entry
+ else:
+ assert entry["input_schemas"] == {
+ "search": {
+ "type": "object",
+ "required": ["count"],
+ "properties": {"count": {"type": "integer", "minimum": 1}},
+ }
+ }
+
+
[email protected]("malformed_type", [[["x"]], [{"x": "string"}], [{}]])
+def test_untrusted_root_schema_type_is_not_exported(malformed_type):
+ assert proof._input_schema({"type": malformed_type}) is None
+
+
+ ("transport", "method", "status"),
+ [("http", "POST", 307), ("http", "POST", 308), ("sse", "GET", 302), ("sse", "POST", 307)],
+)
+def test_same_origin_redirect_never_reaches_functional_target(monkeypatch, fake_mcp, transport, method, status):
+ """SDK2 follows these itself unless the constrained transport refuses them."""
+ seen = []
+ source = "/messages" if transport == "sse" and method == "POST" else "/same-origin-redirect"
+ sink = "/messages-target" if source == "/messages" else "/sse" if transport == "sse" else "/mcp"
+ original = getattr(_Handler, f"do_{method}")
+
+ def redirect_or_record(self):
+ seen.append(self.path)
+ if self.path.startswith(source) and not self.path.startswith(sink):
+ self.send_response(status)
+ self.send_header("Location", sink)
+ self.send_header("Content-Length", "0")
+ self.end_headers()
+ return
+ original(self)
+
+ monkeypatch.setattr(_Handler, f"do_{method}", redirect_or_record)
+ start_path = "/sse" if source == "/messages" else source
+
+ entry = proof.probe_mcp_server(
+ {"name": "redirect", "url": f"{fake_mcp}{start_path}", "transport": transport}, allowed_private_hosts=LOCAL
+ )
+
+ assert not any(path.startswith(sink) for path in seen), seen
+ assert entry["status"] == "unreachable", entry
+
+
[email protected](int(version("mcp").split(".", 1)[0]) < 2, reason="SDK1 itself requires legacy HTTPX")
[email protected]("transport", ["http", "sse"])
+def test_sdk2_protocol_does_not_require_legacy_http_packages(monkeypatch, fake_mcp, transport):
+ original = builtins.__import__
+
+ def deny_legacy(name, *args, **kwargs):
+ if name in {"httpx", "httpcore"} or name.startswith(("httpx.", "httpcore.")):
+ raise ImportError("legacy HTTP package deliberately unavailable")
+ return original(name, *args, **kwargs)
+
+ monkeypatch.setattr(builtins, "__import__", deny_legacy)
+ path = "/sse" if transport == "sse" else "/mcp"
+
+ entry = proof.probe_mcp_server(
+ {"name": "docs", "url": f"{fake_mcp}{path}", "transport": transport}, allowed_private_hosts=LOCAL
+ )
+
+ assert entry["status"] == "reachable-host", entry
+ assert entry["tools"] == ["search", "get_page"]
+
+
[email protected]("mode", ["gzip", "chunks"])
+def test_native_transport_rejects_encoding_and_aggregate_oversize(monkeypatch, fake_mcp, mode):
+ monkeypatch.setattr(proof, "MAX_RESPONSE_BYTES", 16_384)
+ sent_encodings = []
+
+ def oversized(self):
+ self.rfile.read(int(self.headers["Content-Length"]))
+ sent_encodings.append(self.headers.get("Accept-Encoding"))
+ self.protocol_version = "HTTP/1.1"
+ self.send_response(200)
+ self.send_header("Content-Type", "application/json")
+ if mode == "gzip":
+ data = gzip.compress(b"x" * 32_768)
+ self.send_header("Content-Encoding", "gzip")
+ self.send_header("Content-Length", str(len(data)))
+ else:
+ self.send_header("Transfer-Encoding", "chunked")
+ self.end_headers()
+ try:
+ if mode == "gzip":
+ self.wfile.write(data)
+ else:
+ for _ in range(3):
+ self.wfile.write(b"2000\r\n" + b"x" * 8192 + b"\r\n")
+ self.wfile.flush()
+ self.wfile.write(b"0\r\n\r\n")
+ except OSError:
+ pass # The constrained client can close as soon as it rejects the response.
+
+ monkeypatch.setattr(_Handler, "do_POST", oversized)
+
+ entry = proof.probe_mcp_server(
+ {"name": "large", "url": f"{fake_mcp}/mcp", "headers": {"Accept-Encoding": "gzip"}},
+ allowed_private_hosts=LOCAL,
+ )
+
+ assert sent_encodings == ["identity"]
+ assert entry["status"] == "unreachable", entry
+ assert ("content encoding must be identity" if mode == "gzip" else "response exceeded 16384 bytes") in entry[
+ "detail"
+ ]
+
+
+def test_native_transport_ignores_proxy_and_netrc_credentials(monkeypatch, tmp_path, fake_mcp):
+ path = tmp_path / "fixture.netrc"
+ path.write_text("machine 127.0.0.1 login ambient-fixture password never-send-this\n")
+ monkeypatch.setenv("NETRC", str(path))
+ monkeypatch.setenv("HTTP_PROXY", fake_mcp)
+ monkeypatch.setenv("ALL_PROXY", fake_mcp)
+ monkeypatch.setenv("NO_PROXY", "")
+
+ def refuse_netrc(*_args, **_kwargs):
+ raise AssertionError("the probe must not read ambient netrc credentials")
+
+ monkeypatch.setattr(netrc, "netrc", refuse_netrc)
+ requests = []
+ original = _Handler.do_POST
+
+ def record(self):
+ requests.append((self.path, self.headers.get("Authorization")))
+ original(self)
+
+ monkeypatch.setattr(_Handler, "do_POST", record)
+
+ entry = proof.probe_mcp_server({"name": "docs", "url": f"{fake_mcp}/mcp"}, allowed_private_hosts=LOCAL)
+
+ assert entry["status"] == "reachable-host", entry
+ assert requests and all(path == "/mcp" and authorization is None for path, authorization in requests)
+
+
+def test_off_origin_sse_endpoint_never_contacts_live_sink(monkeypatch, fake_mcp):
+ hits = []
+ release = threading.Event()
+ original_get, original_post = _Handler.do_GET, _Handler.do_POST
+
+ def endpoint(self):
+ if self.path != "/sse-to-sink":
+ original_get(self)
+ return
+ self.send_response(200)
+ self.send_header("Content-Type", "text/event-stream")
+ self.end_headers()
+ self.wfile.write(f"event: endpoint\ndata: {fake_mcp}/messages\n\n".encode())
+ self.wfile.flush()
+ release.wait(5)
+
+ def record(self):
+ hits.append(self.path)
+ original_post(self)
+
+ monkeypatch.setattr(_Handler, "do_GET", endpoint)
+ monkeypatch.setattr(_Handler, "do_POST", record)
+ server = _FakeServer()
+ worker = threading.Thread(target=server.serve_forever, daemon=True)
+ worker.start()
+ try:
+ entry = proof.probe_mcp_server(
+ {"name": "sse", "url": f"http://127.0.0.1:{server.server_port}/sse-to-sink", "transport": "sse"},
+ allowed_private_hosts=LOCAL,
+ )
+ finally:
+ release.set()
+ server.sse_queue.put(None)
+ server.shutdown()
+ server.server_close()
+ worker.join(timeout=2)
+
+ assert hits == []
+ assert entry["status"] == "unreachable", entry
+ assert "origin" in entry["detail"]
+
+
+def test_native_pinned_pool_preserves_host_and_verifying_tls_identity(monkeypatch):
+ http, core = _native_stack()
+ seen = {"request": b""}
+
+ class Stream(core.AsyncNetworkStream):
+ sent = False
+
+ async def read(self, max_bytes, timeout=None):
+ del max_bytes, timeout
+ if self.sent:
+ return b""
+ self.sent = True
+ return b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nOK"
+
+ async def write(self, buffer, timeout=None):
+ del timeout
+ seen["request"] += buffer
+
+ async def aclose(self):
+ seen["closed"] = True
+
+ async def start_tls(self, ssl_context, server_hostname=None, timeout=None):
+ del timeout
+ seen["tls"] = (server_hostname, ssl_context.check_hostname, ssl_context.verify_mode)
+ return self
+
+ class Backend(core.AsyncNetworkBackend):
+ async def connect_tcp(self, host, port, **_kwargs):
+ seen["address"] = (host, port)
+ return Stream()
+
+ async def sleep(self, seconds):
+ pass
+
+ monkeypatch.setattr(core, "AnyIOBackend", Backend)
+
+ async def fetch():
+ async with proof._capped_client(
+ {},
+ url="https://mcp.example.invalid/mcp",
+ addresses=("192.0.2.10",),
+ max_bytes=1024,
+ connect_timeout=1,
+ read_timeout=1,
+ http_stack=(http, core),
+ ) as client:
+ assert (await client.get("https://mcp.example.invalid/mcp")).text == "OK"
+
+ anyio.run(fetch)
+
+ assert seen["address"] == ("192.0.2.10", 443)
+ assert seen["tls"] == ("mcp.example.invalid", True, ssl.CERT_REQUIRED)
+ assert b"Host: mcp.example.invalid\r\n" in seen["request"]
+ assert seen["closed"] is True
+
+
+def test_native_transport_refuses_unknown_pool_layout(monkeypatch):
+ http, core = _native_stack()
+
+ class UnsupportedTransport:
+ _pool = object()
+
+ def __init__(self, **_kwargs):
+ pass
+
+ monkeypatch.setattr(http, "AsyncHTTPTransport", UnsupportedTransport)
+
+ with pytest.raises(RuntimeError, match="cannot pin"):
+ proof._capped_client(
+ {},
+ url="https://mcp.example.invalid/mcp",
+ addresses=("192.0.2.10",),
+ max_bytes=1024,
+ connect_timeout=1,
+ read_timeout=1,
+ http_stack=(http, core),
+ )
+
+
+def test_cancelled_native_session_closes_constrained_client(monkeypatch, fake_mcp):
+ started, release = threading.Event(), threading.Event()
+ clients = []
+ original = proof._capped_client
+
+ def record_client(headers, **kwargs):
+ client = original(headers, **kwargs)
+ clients.append(client)
+ return client
+
+ def stall(self):
+ self.rfile.read(int(self.headers["Content-Length"]))
+ started.set()
+ release.wait(5)
+
+ monkeypatch.setattr(proof, "_capped_client", record_client)
+ monkeypatch.setattr(_Handler, "do_POST", stall)
+
+ async def cancel():
+ task = asyncio.create_task(
+ proof._probe_session(f"{fake_mcp}/mcp", "streamable-http", {}, addresses=LOCAL, total_timeout=10)
+ )
+ try:
+ assert await asyncio.to_thread(started.wait, 5)
+ task.cancel()
+ with pytest.raises(asyncio.CancelledError):
+ await asyncio.wait_for(task, timeout=2)
+ finally:
+ release.set()
+ if not task.done():
+ task.cancel()
+ await asyncio.gather(task, return_exceptions=True)
+
+ asyncio.run(cancel())
+
+ assert clients and all(client.is_closed for client in clients)