aidputils.agents.tools.mcp_tool¶
- class aidputils.agents.tools.mcp_tool.MCPTool[source]¶
Bases:
BaseToolTool for interacting with an MCP server.
- Supported operations via runtime_params[“operation”]:
“list_tools”: Return available tools (normalized, JSON-serializable).
“list_resources”: Return available resources (normalized).
“get_prompt”: Return a list of messages for a named prompt (messages are normalized).
“test_connection”: Establish a simple MCP session to verify connectivity/auth; optional timeout_secs.
“test_tool”: Invoke a specific tool; requires ‘tool_name’ and optional ‘arguments’.
- Configuration (conf):
endpoint (str): Base URL for the MCP server.
auth (optional): Auth configuration passed through to the client.
transport (str): Transport name. Defaults to “streamable_http”.
- Runtime params (runtime_params):
server_name (str): The MCP server identifier.
timeout_secs (float|int, optional): Per-call timeout.
tool_name (str, for test_tool): Tool to execute.
arguments (dict|any, for test_tool): Arguments; if wrapped as {“values”: {…}} it is unwrapped.
custom_headers (dict[str, str], optional): Additional HTTP headers merged on top of auth-derived headers when constructing the client.
All return values are shaped to be JSON-serializable for logging/metrics/clients. Metrics counters (success/failure) are declared but incrementing is handled by BaseTool hooks if configured.
- metricsUtil = <aidputils.agents.toolkit.metrics_util.MetricUtility object>¶
- success_counter = 'MCP_TOOL_SUCCESS_COUNTER'¶
- failure_counter = 'MCP_TOOL_FAILURE_COUNTER'¶
- DEFAULT_TIMEOUT = 30¶