Xbase++ Requires Chilkat v11.6.0+
Xbase++
Get the Last JSON-RPC Response from an MCP Server
See more MCP Client Examples
Demonstrates Mcp.GetLastJsonData, which returns the complete JSON-RPC response envelope (the jsonrpc, id, and result members) from the most recent request into a JsonObject.
Tip: Code to parse the returned JSON can be generated with Chilkat's online tool at https://tools.chilkat.io/jsonParse.
Background. This exposes the full protocol-level response for inspection or debugging after any MCP request.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oMcp
LOCAL oToolsResult
LOCAL oJson
nSuccess := 0
oMcp := CreateObject("Chilkat.Mcp")
// Connect to a public MCP (Model Context Protocol) server over its Streamable HTTP endpoint. The
// Microsoft Learn MCP server is public and requires no authentication.
nSuccess := oMcp:Connect("https://learn.microsoft.com/api/mcp")
IF (nSuccess == 0)
? oMcp:LastErrorText
oMcp:destroy()
RETURN
ENDIF
// Perform an MCP request.
oToolsResult := CreateObject("Chilkat.JsonObject")
nSuccess := oMcp:ListTools(oToolsResult)
IF (nSuccess == 0)
? oMcp:LastErrorText
oMcp:destroy()
oToolsResult:destroy()
RETURN
ENDIF
// Get the complete JSON-RPC response envelope (the jsonrpc, id, and result members) from the most
// recent request.
oJson := CreateObject("Chilkat.JsonObject")
oMcp:GetLastJsonData(oJson)
oJson:EmitCompact := 0
? oJson:Emit()
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse
oMcp:destroy()
oToolsResult:destroy()
oJson:destroy()