var client = new ToolProviderClient("192.168.1.100", 8090); client.OnRequestExecuted += (method, success) => Debug.Log($"Request: {method}"); await client.ConnectAsync(); // ... later ... client.Disconnect(); ToolProviderClient
(
serverAddress
, serverPort
)
|
Create a new Tool Provider client.
Signature
ToolProviderClient(string serverAddress, int serverPort=8090) Parameters serverAddress: string
IP address or hostname of the MCP server (e.g., "192.168.1.100").
serverPort: int
Port number for the MCP HTTP server (default: 8090).
|
AccessToken
: string
[Get][Set] |
The access token for authenticating with the MCP Bridge server.
Must be set before calling ConnectAsync.
Signature
string AccessToken |
IsConnected
: bool
[Get] |
Whether the client is currently connected to the MCP server.
Signature
bool IsConnected |
ServerAddress
: string
[Get][Set] |
The server address this client connects to.
Signature
string ServerAddress |
ServerPort
: int
[Get][Set] |
The server port this client connects to.
Signature
int ServerPort |
ServerUrl
: string
[Get] |
The full server URL.
Signature
string ServerUrl |
OnCapabilitiesRegistered
: Action |
Fired when capabilities have been successfully registered with the server.
Signature
Action OnCapabilitiesRegistered |
OnConnectionStateChanged
: Action< bool > |
Fired when the connection state changes.
Signature
Action<bool> OnConnectionStateChanged |
OnError
: Action< string > |
Fired when an error occurs during execution or connection.
Signature
Action<string> OnError |
OnRequestExecuted
: Action< string, bool > |
Fired when a request has been executed (success or failure).
Parameters: method, success
Signature
Action<string, bool> OnRequestExecuted |
RaiseCapabilitiesRegistered
()
|
Raise the OnCapabilitiesRegistered event.
For use by derived classes in testing.
Signature
void RaiseCapabilitiesRegistered() Returns void |
RaiseError
(
error
)
|
Raise the OnError event.
For use by derived classes in testing.
Signature
void RaiseError(string error) Parameters error: stringReturns void |
RaiseRequestExecuted
(
method
, success
)
|
Raise the OnRequestExecuted event.
For use by derived classes in testing.
Signature
void RaiseRequestExecuted(string method, bool success) Parameters method: stringsuccess: boolReturns void |
SetConnected
(
connected
)
|
Signature
void SetConnected(bool connected) Parameters connected: boolReturns void |
ConnectAsync
(
cancellationToken
)
|
Connect to the MCP server and start listening for requests.
Signature
virtual async Task< bool > ConnectAsync(CancellationToken cancellationToken=default) Parameters cancellationToken: CancellationToken
Optional cancellation token.
Returns async Task< bool >
True if connection was successful, false otherwise.
|
Disconnect
()
|
Disconnect from the MCP server.
Signature
virtual void Disconnect() Returns void |
Dispose
()
|
Dispose the client and release all resources.
Signature
virtual void Dispose() Returns void |