mcp_client
Module Contents
Classes
Standard Lagent Action that wraps a SINGLE tool from an MCP Server. |
Attributes
- lagent.actions.mcp_client.ServerType: TypeAlias = Literal['stdio', 'sse', 'http']
- class lagent.actions.mcp_client.TokenBucket(rate_limit)
- 参数:
rate_limit (float) –
- rate_limit
- tokens
- last_update
- lock
- acquire()
- 返回类型:
bool
- class lagent.actions.mcp_client.AsyncTokenBucket(rate_limit)
- 参数:
rate_limit (float) –
- rate_limit
- capacity
- tokens
- last_update
- async acquire()
- class lagent.actions.mcp_client.FairAsyncTokenBucket(rate_limit, capacity=None)
- 参数:
rate_limit (float) –
capacity (Optional[float]) –
- rate_limit
- capacity
- tokens
- last_update
- async acquire()
获取一个 token(公平:排队 FIFO)
- 返回类型:
None
- class lagent.actions.mcp_client.AsyncMCPClient(server_type, rate_limit=None, max_concurrency=None, name=None, extra_args=None, **server_params)
Bases:
lagent.actions.base_action.AsyncActionMixin,lagent.actions.base_action.BaseActionStandard Lagent Action that wraps a SINGLE tool from an MCP Server.
Robustness Fix: Creates a new connection for every request and closes it immediately after. This prevents connection leaks and ‘ConnectTimeout’ in high-concurrency RL environments.
- 参数:
server_type (ServerType) –
rate_limit (float) –
max_concurrency (int) –
name (Optional[str]) –
extra_args (Optional[dict]) –
- is_stateful = False
- server_type
- server_params
- extra_args
- rate_limiter
- tool_info
- async run(**kwargs)
Standard Lagent Action Entrypoint.