类class
agentscope.app.hubMCPHubBase
class MCPHubBase(HubBase, ABC)
源码Source
agentscope/app/hub/_mcp/_base.py:9–69MCP 中心基类,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.hub 包,继承自 HubBase, ABC。核心成员包括 list_mcps、get_mcp。
A hub exposes a browsable catalog of :class:MCPCard templates.
Turning a card into a connectable MCPClient is the installer's
job, not the hub's — see :func:agentscope.app._service.render_mcp.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def list_mcps(user_id: str, q: str | None = None, cursor: str | None = None, limit: int = 20) -> MCPHubPageasyncabstractabstractmethod | 列出 `list_mcps`。 Browse the hub catalog. |
async def get_mcp(user_id: str, card_id: str) -> MCPCardasyncabstractabstractmethod | 获取MCP。 Fetch a single card by its hub-local id. |
方法详情Method Detail
list_mcps
async def list_mcps(user_id: str, q: str | None = None, cursor: str | None = None, limit: int = 20) -> MCPHubPage
asyncabstractabstractmethod
列出 list_mcps。
Pagination is cursor-based rather than page-numbered: registries commonly expose only a forward cursor and no total count, and an offset-based hub can always encode its offset into the cursor.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
user_id | str | 用户标识(类型 `str`)。The user identifier to query MCP cards for. |
q默认default None | str | None | q(类型 `str | None`)。A keyword filtering the cards. When `None` the whole catalog is browsed. |
cursor默认default None | str | None | 游标(类型 `str | None`)。The opaque cursor from a previous page. When `None` the first page is returned. |
limit默认default 20 | int | 数量上限(类型 `int`)。The maximum number of cards per page. |
MCPHubPage
返回MCPHubPage。`MCPHubPage`:
源码Source
agentscope/app/hub/_mcp/_base.py:18–46get_mcp
async def get_mcp(user_id: str, card_id: str) -> MCPCard
asyncabstractabstractmethod
获取MCP。
Fetch a single card by its hub-local id.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
user_id | str | 用户标识(类型 `str`)。The user identifier to query the card for. |
card_id | str | 卡片标识(类型 `str`)。The :attr:`MCPCard.id` addressing the card on this hub. |
MCPCard
返回MCPCard。`MCPCard`:
- 可能抛出 `Exception`。`KeyError`:
- 可能抛出 `Exception`。When this hub has no card under `card_id`.
源码Source
agentscope/app/hub/_mcp/_base.py:49–69