pub struct HttpClient { /* private fields */ }Expand description
Blocking HTTP client used by MCP tool calls.
It shells out to curl, matching the repository’s outbound-HTTP
convention. Credentials, when configured, are read from a named file
and sent to curl over stdin rather than placed in its argument vector.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(
api: &str,
auth_file: Option<&Path>,
auth_user: Option<&str>,
) -> Result<Self, String>
pub fn new( api: &str, auth_file: Option<&Path>, auth_user: Option<&str>, ) -> Result<Self, String>
Builds a client for api.
auth_file uses the node’s user:token-per-line format. When it
contains more than one credential, auth_user must select one.
§Errors
Returns a description for an invalid URL, unreadable or malformed auth file, or an ambiguous credential selection.
Sourcepub fn with_credential(
api: &str,
user: &str,
token: &str,
) -> Result<Self, String>
pub fn with_credential( api: &str, user: &str, token: &str, ) -> Result<Self, String>
Builds a client for api from a credential already in hand.
The invite in a join link is the one credential this crate never
reads from a file: it arrives inside a URL somebody was sent in a
chat window. Writing it to a temporary file first so that
HttpClient::new could read it back would put a live secret on
disk for the length of one request, which is exactly the shape
this constructor exists to avoid. It still reaches curl over
stdin, never on an argv.
§Errors
Returns a description when api is not an http(s) URL.
Sourcepub fn request(
&self,
endpoint: &Endpoint,
arguments: &Value,
) -> Result<(u16, String), String>
pub fn request( &self, endpoint: &Endpoint, arguments: &Value, ) -> Result<(u16, String), String>
Sends one request described by the shared endpoint table.
This is also used by the ordinary CLI so its authenticated HTTP path and the MCP adapter cannot diverge on credential handling.
§Errors
Returns a transport or argument-validation description without reflecting credentials or the node address.
Sourcepub fn get(&self, path: &str) -> Result<(u16, String), String>
pub fn get(&self, path: &str) -> Result<(u16, String), String>
Sends a bare authenticated GET to one path on the node.
For the operational endpoints that are not part of the tool
table: /healthz and its neighbours are authenticated like
everything else, but they carry no arguments and no MCP schema,
so they cannot be reached through request. Going through this
client rather than a fresh curl keeps one credential path in
the crate — the config-on-stdin that keeps a token off argv,
where ps would show it.
§Errors
Returns a transport description, without reflecting the credential or the node address.
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Source§fn clone(&self) -> HttpClient
fn clone(&self) -> HttpClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more