academy_extensions.mcp
MCP Server interface to Academy Exchange.
AppContext
¶
AppContext(
exchange_client: ExchangeClient[Any],
agents: set[AgentId[Any]] | None = None,
)
Application context with typed dependencies.
Parameters:
-
exchange_client(ExchangeClient[Any]) –The client used to communicate on the exchange.
Source code in academy_extensions/mcp.py
format_name
¶
wrap_agent
async
¶
Wrap tool from agent for use by server.
Source code in academy_extensions/mcp.py
update_tools
async
¶
update_tools(
server: FastMCP,
existing: set[AgentId[Any]],
client: ExchangeClient[Any],
base_class: type[Agent] = Agent,
allow_subclasses: bool = True,
) -> dict[AgentId[Any], Task[Any]]
Update tools by discovering agents on the exchange.
Source code in academy_extensions/mcp.py
refresh_loop
async
¶
refresh_loop(
server: FastMCP,
context: AppContext,
interval_s: int = 300,
) -> None
Regularly update the discovered tools.
Source code in academy_extensions/mcp.py
app_lifespan
async
¶
app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]
Initialize exchange client for lifespan of server.
Source code in academy_extensions/mcp.py
add_agent
async
¶
add_agent(
ctx: Context[ServerSession, AppContext], agent_uid: UUID
) -> dict[str, str]
Add agent to MCP server based on ID.
Parameters:
-
ctx(Context[ServerSession, AppContext]) –FastMCP context (provided)
-
agent_uid(UUID) –uuid of the agent to add to MCP server.
Returns:
Source code in academy_extensions/mcp.py
discover
async
¶
discover(
ctx: Context[ServerSession, AppContext],
agent: str,
module: str,
allow_subclasses: bool = True,
) -> tuple[UUID, ...]
Search for agents of type Agent on the exchange.
To search for all agents, use agent_type="Agent", module="academy.Agent".
Parameters:
-
ctx(Context[ServerSession, AppContext]) –FastMCP context (provided)
-
agent(str) –The type of the agent to return.
-
module(str) –The module where the agent was implemented.
-
allow_subclasses(bool, default:True) –Return agents implementing subclasses of the agent.
Returns: