Constructor McpClient
McpClient(string, TimeSpan?)
Initializes a new instance of McpClient with an internally owned HttpClient.
public McpClient(string baseUrl, TimeSpan? timeout = null)
Parameters
baseUrl
stringMCP server base URL (e.g.,
https://example.com/mcp
).timeout
TimeSpan?Optional HTTP timeout; if
null
, defaults to 60 seconds.
Exceptions
- ArgumentException
Thrown when
baseUrl
is null or whitespace.
McpClient(string, HttpClient)
Initializes a new instance of McpClient using a caller-provided HttpClient. The caller retains ownership and is responsible for the lifecycle of the provided client.
public McpClient(string baseUrl, HttpClient externalHttpClient)
Parameters
baseUrl
stringMCP server base URL (e.g.,
https://example.com/mcp
).externalHttpClient
HttpClientAn existing HttpClient instance to use.
Exceptions
- ArgumentException
Thrown when
baseUrl
is null or whitespace.- ArgumentNullException
Thrown when
externalHttpClient
is null.