49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
"""Drive a built image over stdio: initialize, list tools, one safe call, EOF.
|
|
|
|
Only the standard library is used, so it runs outside the project venv.
|
|
Prints the JSON-RPC traffic to stdout for the CI log; asserts exit cleanliness
|
|
in the caller, not here.
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
import time
|
|
|
|
HOLD = 1.5
|
|
|
|
CALL = {
|
|
"jsonrpc": "2.0",
|
|
"id": 3,
|
|
"method": "tools/call",
|
|
"params": {"name": "reports", "arguments": {"status": "open"}},
|
|
}
|
|
MESSAGES = [
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "initialize",
|
|
"params": {
|
|
"protocolVersion": "2025-06-18",
|
|
"capabilities": {},
|
|
"clientInfo": {"name": "ci-smoke", "version": "1"},
|
|
},
|
|
},
|
|
{"jsonrpc": "2.0", "method": "notifications/initialized"},
|
|
{"jsonrpc": "2.0", "id": 2, "method": "tools/list"},
|
|
CALL,
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
for message in MESSAGES:
|
|
sys.stdout.write(json.dumps(message) + "\n")
|
|
sys.stdout.flush()
|
|
time.sleep(0.2)
|
|
# Keep stdin open until the last reply lands, then signal EOF by exiting.
|
|
time.sleep(HOLD)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|