mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 05:54:19 +02:00
run api ref gen
This commit is contained in:
parent
9bbca08862
commit
034fa72b9c
50 changed files with 685 additions and 469 deletions
|
|
@ -7,48 +7,48 @@ sidebarTitle: client
|
|||
|
||||
## Classes
|
||||
|
||||
### `Client`
|
||||
### `Client` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L60" target="_blank">↗</a></sup>
|
||||
|
||||
|
||||
MCP client that delegates connection management to a Transport instance.
|
||||
|
||||
MCP client that delegates connection management to a Transport instance.
|
||||
The Client class is responsible for MCP protocol logic, while the Transport
|
||||
handles connection establishment and management. Client provides methods for
|
||||
working with resources, prompts, tools and other MCP capabilities.
|
||||
|
||||
The Client class is responsible for MCP protocol logic, while the Transport
|
||||
handles connection establishment and management. Client provides methods for
|
||||
working with resources, prompts, tools and other MCP capabilities.
|
||||
**Args:**
|
||||
- `transport`: Connection source specification, which can be\:
|
||||
- ClientTransport\: Direct transport instance
|
||||
- FastMCP\: In-process FastMCP server
|
||||
- AnyUrl | str\: URL to connect to
|
||||
- Path\: File path for local socket
|
||||
- MCPConfig\: MCP server configuration
|
||||
- dict\: Transport configuration
|
||||
- `roots`: Optional RootsList or RootsHandler for filesystem access
|
||||
- `sampling_handler`: Optional handler for sampling requests
|
||||
- `log_handler`: Optional handler for log messages
|
||||
- `message_handler`: Optional handler for protocol messages
|
||||
- `progress_handler`: Optional handler for progress notifications
|
||||
- `timeout`: Optional timeout for requests (seconds or timedelta)
|
||||
- `init_timeout`: Optional timeout for initial connection (seconds or timedelta).
|
||||
Set to 0 to disable. If None, uses the value in the FastMCP global settings.
|
||||
|
||||
Args:
|
||||
transport: Connection source specification, which can be:
|
||||
- ClientTransport: Direct transport instance
|
||||
- FastMCP: In-process FastMCP server
|
||||
- AnyUrl | str: URL to connect to
|
||||
- Path: File path for local socket
|
||||
- MCPConfig: MCP server configuration
|
||||
- dict: Transport configuration
|
||||
roots: Optional RootsList or RootsHandler for filesystem access
|
||||
sampling_handler: Optional handler for sampling requests
|
||||
log_handler: Optional handler for log messages
|
||||
message_handler: Optional handler for protocol messages
|
||||
progress_handler: Optional handler for progress notifications
|
||||
timeout: Optional timeout for requests (seconds or timedelta)
|
||||
init_timeout: Optional timeout for initial connection (seconds or timedelta).
|
||||
Set to 0 to disable. If None, uses the value in the FastMCP global settings.
|
||||
**Examples:**
|
||||
|
||||
Examples:
|
||||
```python # Connect to FastMCP server client =
|
||||
Client("http://localhost:8080")
|
||||
```python # Connect to FastMCP server client =
|
||||
Client("http://localhost:8080")
|
||||
|
||||
async with client:
|
||||
# List available resources resources = await client.list_resources()
|
||||
async with client:
|
||||
# List available resources resources = await client.list_resources()
|
||||
|
||||
# Call a tool result = await client.call_tool("my_tool", {"param":
|
||||
"value"})
|
||||
```
|
||||
|
||||
# Call a tool result = await client.call_tool("my_tool", {"param":
|
||||
"value"})
|
||||
```
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `session`
|
||||
#### `session` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L207" target="_blank">↗</a></sup>
|
||||
|
||||
```python
|
||||
session(self) -> ClientSession
|
||||
|
|
@ -57,7 +57,7 @@ session(self) -> ClientSession
|
|||
Get the current active session. Raises RuntimeError if not connected.
|
||||
|
||||
|
||||
#### `initialize_result`
|
||||
#### `initialize_result` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L217" target="_blank">↗</a></sup>
|
||||
|
||||
```python
|
||||
initialize_result(self) -> mcp.types.InitializeResult
|
||||
|
|
@ -66,7 +66,7 @@ initialize_result(self) -> mcp.types.InitializeResult
|
|||
Get the result of the initialization request.
|
||||
|
||||
|
||||
#### `set_roots`
|
||||
#### `set_roots` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L225" target="_blank">↗</a></sup>
|
||||
|
||||
```python
|
||||
set_roots(self, roots: RootsList | RootsHandler) -> None
|
||||
|
|
@ -75,7 +75,7 @@ set_roots(self, roots: RootsList | RootsHandler) -> None
|
|||
Set the roots for the client. This does not automatically call `send_roots_list_changed`.
|
||||
|
||||
|
||||
#### `set_sampling_callback`
|
||||
#### `set_sampling_callback` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L229" target="_blank">↗</a></sup>
|
||||
|
||||
```python
|
||||
set_sampling_callback(self, sampling_callback: SamplingHandler) -> None
|
||||
|
|
@ -84,7 +84,7 @@ set_sampling_callback(self, sampling_callback: SamplingHandler) -> None
|
|||
Set the sampling callback for the client.
|
||||
|
||||
|
||||
#### `is_connected`
|
||||
#### `is_connected` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/client/client.py#L235" target="_blank">↗</a></sup>
|
||||
|
||||
```python
|
||||
is_connected(self) -> bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue