Remove MCP Server • AI Agent SDK

remove_mcp_server: Disconnect and deregister a previously attached MCP server.

remove_mcp_server

Method

</div>

This is a method of the Agent class in the agent module.

Disconnect and deregister a previously attached MCP server.

Removes the server’s tools from `self.tools` and shuts the connection down cleanly (no leaked background loops). Tools disappear on the next turn.

Signature

python
def remove_mcp_server(name: str) -> bool

Parameters

ParamField str

The name used in `add_mcp_server`.

Returns

ResponseField bool

True if a server was removed, False if no server by that name existed.

Uses

  • mcp.shutdown
  • logging.warning
  • refresh_tools
  • logging.debug

Source

View on GitHub

praisonaiagents/agent/agent.py at line 6106


Related Documentation