#!/usr/bin/env python3
"""
Simple JSON-RPC echo server for testing StdioTransport.
Echoes back the params of any request as the result.
"""
import json
import sys


def main():
    while True:
        try:
            line = sys.stdin.readline()
            if not line:
                break

            request = json.loads(line.strip())
            response = {
                "jsonrpc": "2.0",
                "id": request.get("id"),
                "result": request.get("params", {})
            }
            sys.stdout.write(json.dumps(response) + "\n")
            sys.stdout.flush()
        except json.JSONDecodeError:
            # Invalid JSON, ignore
            pass
        except Exception:
            # Other errors, continue
            pass


if __name__ == "__main__":
    main()
