Skip to main content

Radius AI Agent Toolkit - JSON-RPC Plugin

This plugin enables AI agents to make remote procedure calls using the JSON-RPC protocol through a standardized interface, allowing them to interact with any JSON-RPC endpoint.

This package is part of the Radius AI Agent Toolkit, which provides tools for integrating AI agents with the Radius platform.

Installation

# Install this specific package
pip install radius-ai-agent-sdk-plugin-jsonrpc

# Required dependencies
pip install radius-ai-agent-sdk
pip install aiohttp

Prerequisites

  • Python >=3.10
  • radius-ai-agent-sdk >=0.1.0
  • aiohttp >=3.8.6

Usage

from radius_plugins.jsonrpc import jsonrpc, JSONRpcPluginOptions
from radius_wallets.web3 import create_radius_wallet
from radius_adapters.langchain import get_on_chain_tools

# Create a Radius wallet
wallet = create_radius_wallet(
    rpc_url=os.environ.get("RPC_PROVIDER_URL"),
    private_key=os.environ.get("WALLET_PRIVATE_KEY")
)

# Initialize the JSON-RPC plugin
jsonrpc_plugin = jsonrpc(JSONRpcPluginOptions(
    endpoint="https://your-json-rpc-endpoint.com"
))

# Create AI agent tools with the JSON-RPC plugin
tools = get_on_chain_tools(
    wallet=wallet,
    plugins=[jsonrpc_plugin]
)

Example: Making a JSON-RPC Call

# Example of using the JSON-RPC plugin through an AI agent
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o")
agent = model.bind_tools(tools)

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant that can make JSON-RPC calls."),
    ("user", "{input}")
])

chain = prompt | RunnablePassthrough.assign(
    agent_response=lambda x: agent.invoke(x)
) | (lambda x: x["agent_response"])

result = chain.invoke({
    "input": """Make a JSON-RPC call to get the latest block number using:
                method: 'eth_blockNumber',
                params: [],
                id: 1,
                jsonrpc: '2.0'"""
})

# The AI will use the json_rpc_func tool to execute this request

API Reference

jsonrpc(options: JSONRpcPluginOptions)

Creates a new JSON-RPC plugin instance.

Parameters:

  • options (JSONRpcPluginOptions): Configuration options for the JSON-RPC plugin
    • endpoint (str): The URL of the JSON-RPC endpoint

Returns:

  • A JSONRpcPlugin instance that can be used with AI agent frameworks

Provided Tools

The JSON-RPC plugin provides the following AI agent tool:

json_rpc_func

Makes a remote procedure call to a JSON-RPC endpoint.

Parameters:

  • method (str): A string containing the name of the method to be invoked
  • params (list): A structured value that holds the parameter values to be used during the invocation of the method
  • id (int): An identifier established by the client that must contain a string, number, or null
  • jsonrpc (str): A string that specifies the version of the JSON-RPC protocol must be exactly '2.0'

Example:

try:
    result = await json_rpc_tool.execute({
        "method": "eth_getBalance",
        "params": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "latest"],
        "id": 1,
        "jsonrpc": "2.0"
    })
    print(f"JSON-RPC call result: {result}")
except Exception as e:
    print(f"JSON-RPC call failed: {str(e)}")

Note on Tool Naming: The tool name in this documentation (json_rpc_func) matches the actual name used at runtime. The @Tool decorator in the implementation automatically converts camelCase method names to snake_case for the final tool names.

Features

  • Asynchronous JSON-RPC calls
  • HTTP/HTTPS transport support
  • Error handling and response parsing
  • Type-safe implementations with Pydantic
  • Built on aiohttp for high performance

Development Setup

1. Clone the Repository

git clone git@github.com:radiustechsystems/ai-agent-toolkit.git
cd ai-agent-toolkit/python/src/plugins/jsonrpc

2. Install Development Dependencies

pip install -e ".[dev]"

3. Run Tests

pytest

Resources

Contributing

Please see the Contributing Guide for detailed information about contributing to this toolkit.

License

This project is licensed under the MIT License.

Metadata

Release files for radius-ai-agent-sdk-plugin-jsonrpc 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for radius-ai-agent-sdk-plugin-jsonrpc 1.0.0
File Size Uploaded Provenance Actions
radius_ai_agent_sdk_plugin_jsonrpc-1.0.0.tar.gz 7.3 kB Without provenance Details for radius_ai_agent_sdk_plugin_jsonrpc-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for radius-ai-agent-sdk-plugin-jsonrpc 1.0.0
File Interpreter ABI Platform Actions
radius_ai_agent_sdk_plugin_jsonrpc-1.0.0-py3-none-any.whl Python 3 none any Details for radius_ai_agent_sdk_plugin_jsonrpc-1.0.0-py3-none-any.whl

Total release size: 12.6 kB

Release files / radius_ai_agent_sdk_plugin_jsonrpc-1.0.0.tar.gz

Download URL radius_ai_agent_sdk_plugin_jsonrpc-1.0.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fde384fc54da7987d13f1dc5ad804d8ccd3bd5cd0114477e5250b76de22b3a7c
BLAKE2b-256 checksum
How to use checksums
01395127a19c9f241413b4af25bbb74dd2b7c723db76ad83e291b53c6c186695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release files / radius_ai_agent_sdk_plugin_jsonrpc-1.0.0-py3-none-any.whl

Download URL radius_ai_agent_sdk_plugin_jsonrpc-1.0.0-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
368f88ae0663a4fab7796cf2e53f1cc4ca8b1850271c395a3a45d7318563acf9
BLAKE2b-256 checksum
How to use checksums
da8887954ac37e9728e177a8d4693d9c0350c24f2d92ed4340c069a86f8737ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Security for radius-ai-agent-sdk-plugin-jsonrpc 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page