Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a8372b0
test(mcp): Simulate stdio transport with memory streams
alexander-alderman-webb Jan 16, 2026
87a2e26
test(fastmcp): Simulate stdio transport with memory streams
alexander-alderman-webb Jan 19, 2026
70edb6d
cleaning up
alexander-alderman-webb Jan 27, 2026
c238f84
Merge branch 'webb/test-mcp-stdio' into webb/test-fastmcp-stdio
alexander-alderman-webb Jan 27, 2026
f1362bd
send initialization response
alexander-alderman-webb Jan 27, 2026
34dba91
Merge branch 'webb/test-mcp-stdio' into webb/test-fastmcp-stdio
alexander-alderman-webb Jan 27, 2026
46659c5
cleanup
alexander-alderman-webb Jan 27, 2026
ac8e6e4
gate import in conftest
alexander-alderman-webb Jan 27, 2026
2766b40
test(mcp): Use TestClient for Streamable HTTP
alexander-alderman-webb Jan 28, 2026
d3afb38
test(fastmcp): Use TestClient for Streamable HTTP
alexander-alderman-webb Jan 28, 2026
270636d
clean up merge
alexander-alderman-webb Jan 28, 2026
8c9aa86
remove mixed method test
alexander-alderman-webb Jan 30, 2026
6579935
rename tests
alexander-alderman-webb Jan 30, 2026
8aa6363
merge
alexander-alderman-webb Jan 30, 2026
30e9ec3
rename tests
alexander-alderman-webb Jan 30, 2026
aaf69c3
Merge branch 'webb/test-fastmcp-stdio' into webb/test-mcp-streamable-…
alexander-alderman-webb Jan 30, 2026
0ab862c
merge
alexander-alderman-webb Jan 30, 2026
1380f56
remove mocks
alexander-alderman-webb Jan 30, 2026
0e37050
Merge branch 'webb/test-mcp-streamable-http' into webb/test-fastmcp-s…
alexander-alderman-webb Jan 30, 2026
5976135
remove test
alexander-alderman-webb Jan 30, 2026
317c002
Merge branch 'master' into webb/test-mcp-stdio
alexander-alderman-webb Jan 30, 2026
9097b69
merge and remove duplicate asyncio marker
alexander-alderman-webb Jan 30, 2026
7703379
Merge branch 'webb/test-fastmcp-stdio' into webb/test-mcp-streamable-…
alexander-alderman-webb Jan 30, 2026
1133d9e
merge and remove duplicate import
alexander-alderman-webb Jan 30, 2026
0bd14e3
address comments
alexander-alderman-webb Jan 30, 2026
ef33e1f
add missing import fallback
alexander-alderman-webb Jan 30, 2026
4715afa
Merge branch 'webb/test-fastmcp-stdio' into webb/test-mcp-streamable-…
alexander-alderman-webb Jan 30, 2026
2df9629
Merge branch 'webb/test-mcp-streamable-http' into webb/test-fastmcp-s…
alexander-alderman-webb Jan 30, 2026
1bf6876
simplify assertions and use stdio in more tests cases
alexander-alderman-webb Feb 2, 2026
fd2cc42
Merge branch 'webb/test-fastmcp-stdio' into webb/test-mcp-streamable-…
alexander-alderman-webb Feb 2, 2026
771f60e
forgot conftest
alexander-alderman-webb Feb 2, 2026
8f57fcd
Merge branch 'webb/test-fastmcp-stdio' into webb/test-mcp-streamable-…
alexander-alderman-webb Feb 2, 2026
cc4a19d
merge and simplify assertions
alexander-alderman-webb Feb 2, 2026
ef06a2d
fix no-return assertion
alexander-alderman-webb Feb 2, 2026
955d525
Merge branch 'webb/test-fastmcp-stdio' into webb/test-mcp-streamable-…
alexander-alderman-webb Feb 2, 2026
6b81f86
Merge branch 'webb/test-mcp-streamable-http' into webb/test-fastmcp-s…
alexander-alderman-webb Feb 2, 2026
5a26c3b
merge master
alexander-alderman-webb Feb 2, 2026
aaf1a55
import order
alexander-alderman-webb Feb 2, 2026
cdab483
import order
alexander-alderman-webb Feb 2, 2026
16f9b60
remove unused helpers
alexander-alderman-webb Feb 2, 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
79 changes: 79 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
from werkzeug.wrappers import Request, Response
import jsonschema

try:
from starlette.testclient import TestClient
# Catch RuntimeError to prevent the following exception in aws_lambda tests.
# RuntimeError: The starlette.testclient module requires the httpx package to be installed.
except (ImportError, RuntimeError):
TestClient = None

try:
import gevent
Expand Down Expand Up @@ -708,6 +714,79 @@ async def simulate_client(tg, result):
return inner


@pytest.fixture()
def json_rpc():
def inner(app, method: str, params, request_id: str):
with TestClient(app) as client: # type: ignore
init_response = client.post(
"/mcp/",
headers={
"Accept": "application/json, text/event-stream",
"Content-Type": "application/json",
},
json={
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"clientInfo": {"name": "test-client", "version": "1.0"},
"protocolVersion": "2025-11-25",
"capabilities": {},
},
"id": request_id,
},
)

session_id = init_response.headers["mcp-session-id"]

# Notification response is mandatory.
# https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle
client.post(
"/mcp/",
headers={
"Accept": "application/json, text/event-stream",
"Content-Type": "application/json",
"mcp-session-id": session_id,
},
json={
"jsonrpc": "2.0",
"method": "notifications/initialized",
"params": {},
},
)

response = client.post(
"/mcp/",
headers={
"Accept": "application/json, text/event-stream",
"Content-Type": "application/json",
"mcp-session-id": session_id,
},
json={
"jsonrpc": "2.0",
"method": method,
"params": params,
"id": request_id,
},
)

return session_id, response

return inner


@pytest.fixture()
def select_mcp_transactions():
def inner(events):
return [
event
for event in events
if event["type"] == "transaction"
and event["contexts"]["trace"]["op"] == "mcp.server"
]

return inner


class MockServerRequestHandler(BaseHTTPRequestHandler):
def do_GET(self): # noqa: N802
# Process an HTTP GET request and return a response.
Expand Down
Loading
Loading