Client Python Library
The Rhea client Python library allows you to interact with the Rhea MCP server similar to the FastMCP client library.
The client library utilizes both MCP and REST protocols of the Rhea server to allow for MCP tool calling and REST API file handling.
See examples on how to use the Client library.
RheaClient(hostname: str, port: int, secure: bool = False)
Bases: RheaMCPClientBase, RheaRESTClientBase
A client class to interact with both the Rhea Model Context Protocol (MCP) server and REST backend.
The client class provides similar high-level interface to the one found within the Python MCP SDK.
The class also provides additional utilities to interact with the REST backend such as file upload and downloads.
Example:
async with RheaClient('localhost', 3001) as client:
# MCP call
tools = await client.find_tools('I need a tool to convert FASTA to FASTQ')
# REST call
key = await client.upload_file('test.txt')
Source code in rhea/client/__init__.py
list_tools() -> list[Tool]
async
find_tools(query: str) -> list[dict]
async
Find available tools on the MCP server that match the query.
This method searches for tools matching the provided query string and returns their descriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query to find relevant tools. |
required |
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of tool descriptions matching the query. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the client session fails to initialize or used outside of a context manager. |
call_tool(name: str, arguments: dict[str, Any]) -> dict | None
async
Call a specific tool on the MCP server with the given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the tool to call. |
required |
arguments
|
dict[str, Any]
|
The arguments to pass to the tool. |
required |
Returns:
| Type | Description |
|---|---|
dict | None
|
dict | None: The structured content of the tool's response, or None if there is no structured content. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the client session fails to initialize or used outside of a context manager. |
list_resources() -> list[Resource]
async
List all available resources from the Rhea MCP server.
This asynchronous method retrieves a list of all resources accessible through the initialized Rhea client. The client must have an active session before calling this method.
Returns:
| Name | Type | Description |
|---|---|---|
ListResourcesResult |
list[Resource]
|
A result object containing the list of available resources. |
Raises: RuntimeError: If the client session fails to initialize or used outside of a context manager.
read_resource(uri: AnyUrl) -> list[TextResourceContents | BlobResourceContents]
async
Read a specific resource from the Rhea MCP server by its URI.
This method retrieves the contents of a resource identified by the provided URI. The resource contents can be either text or binary data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
AnyUrl
|
The URI of the resource to read. |
required |
Returns:
| Type | Description |
|---|---|
list[TextResourceContents | BlobResourceContents]
|
list[TextResourceContents | BlobResourceContents]: A list of resource contents, which can be either text or binary data. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the client session fails to initialize or used outside of a context manager. |
upload_file(path: str, name: str | None = None, timeout: int = 300, chunk_size: int = 1 << 20) -> dict
async
Upload a file from local directory to Rhea MCP server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path of local file to upload. |
required |
name
|
str
|
Optional filename to use on the server side. Defaults to source filename. |
None
|
timeout
|
int
|
Request timeout in seconds. Defaults to |
300
|
chunk_size
|
int
|
Chunk size to read and upload file. Defaults to 1MB. |
1 << 20
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Server response |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the client session fails to initialize or used outside of a context manager. |
Source code in rhea/client/__init__.py
download_file(key: str, output_directory: Path = Path.cwd(), timeout: int = 300, chunk_size: int = 1 << 20) -> int
async
Download a file to local directory from Rhea MCP server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
File key of desired file to download. |
required |
output_directory
|
Path
|
Output directory to write to. Defaults to current working directory. |
cwd()
|
timeout
|
int
|
Request timeout in seconds. Defaults to |
300
|
chunk_size
|
int
|
Chunk size for download stream. Defaults to 1MB. |
1 << 20
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Size of downloaded file in bytes. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the client session fails to initialize or used outside of a context manager. |
Source code in rhea/client/__init__.py
metrics() -> dict[str, list[dict]]
async
Get Prometheus metrics from Rhea MCP server.
Returns:
| Type | Description |
|---|---|
dict[str, list[dict]]
|
dict[str, list[dict]]: Server metrics |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the client session fails to initialize or used outside of a context manager. |