Skip to content

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

a_list_prompts()

List the prompts available on the MCP server.

Returns:

Name Type Description
A ListPromptsResult

class:types.ListPromptsResult object.

a_list_tools async

a_list_tools()

List the tools available on the MCP server.

Returns:

Type Description
list[Tool]

A list of :class:Tool objects.

call_tool async

call_tool(
    tool_name, arguments=None, progress_callback=None
)

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.

get_prompt async

get_prompt(prompt_name, arguments=None)

Get a prompt from the MCP server.

list_prompts

list_prompts()

List the prompts available on the MCP server.

Returns:

Name Type Description
A ListPromptsResult

class:types.ListPromptsResult object.

list_resources async

list_resources()

List the resources available on the MCP server.

Returns:

Name Type Description
A ListResourcesResult

class:types.ListResourcesResult object.

list_tools

list_tools()

List the tools available on the MCP server.

Returns:

Type Description
list[Tool]

A list of :class:Tool objects.