Skip to main content

HttpClient

Struct HttpClient 

Source
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

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> HttpClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.