MCPClient
datapizza.tools.mcp_client.MCPClient
Helper for interacting with Model Context Protocol servers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the MCP server. |
required |
command
|
str | None
|
The command to run the MCP server. |
None
|
headers
|
dict[str, str] | None
|
The headers to pass to the MCP server. |
None
|
args
|
list[str] | None
|
The arguments to pass to the MCP server. |
None
|
env
|
dict[str, str] | None
|
The environment variables to pass to the MCP server. |
None
|
timeout
|
int
|
The timeout for the MCP server. |
30
|
sampling_callback
|
SamplingFnT | None
|
The sampling callback to pass to the MCP server. |
None
|
a_list_prompts
async
List the prompts available on the MCP server.
Returns:
| Name | Type | Description |
|---|---|---|
A |
ListPromptsResult
|
class: |
a_list_tools
async
List the tools available on the MCP server.
Returns:
| Type | Description |
|---|---|
list[Tool]
|
A list of :class: |
call_tool
async
Call a tool on the MCP server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
The name of the tool to call. |
required |
arguments
|
dict[str, Any] | None
|
The arguments to pass to the tool. |
None
|
progress_callback
|
ProgressFnT | None
|
The progress callback to pass to the tool. |
None
|
Returns:
| Type | Description |
|---|---|
CallToolResult
|
The result of the tool call. |
list_prompts
List the prompts available on the MCP server.
Returns:
| Name | Type | Description |
|---|---|---|
A |
ListPromptsResult
|
class: |
list_resources
async
List the resources available on the MCP server.
Returns:
| Name | Type | Description |
|---|---|---|
A |
ListResourcesResult
|
class: |
list_tools
List the tools available on the MCP server.
Returns:
| Type | Description |
|---|---|
list[Tool]
|
A list of :class: |