Initial import
This commit is contained in:
commit
4cbf815430
1 changed files with 2986 additions and 0 deletions
24
tests/test_types.py
Normal file
24
tests/test_types.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from mcp_python.types import ClientRequest, JSONRPCMessage, JSONRPCRequest
|
||||
|
||||
|
||||
def test_jsonrpc_request():
|
||||
json_data = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "initialize",
|
||||
"params": {
|
||||
"protocolVersion": 1,
|
||||
"capabilities": {"batch": None, "sampling": None},
|
||||
"clientInfo": {"name": "mcp_python", "version": "0.1.0"},
|
||||
},
|
||||
}
|
||||
|
||||
request = JSONRPCMessage.model_validate(json_data)
|
||||
assert isinstance(request.root, JSONRPCRequest)
|
||||
ClientRequest.model_validate(request.model_dump(by_alias=True))
|
||||
|
||||
assert request.root.jsonrpc == "2.0"
|
||||
assert request.root.id == 1
|
||||
assert request.root.method == "initialize"
|
||||
assert request.root.params is not None
|
||||
assert request.root.params["protocolVersion"] == 1
|
||||
Loading…
Reference in a new issue