Skip to main content

add_mcp_server

Method
This is a method of the Agent class in the agent module.
Attach an MCP server to a live agent at runtime. Connects the MCP server (discovering its tools), tracks it by name, and appends it to self.tools so its tools become available on the next turn of the same run — no agent rebuild required. New MCP tools flow through the existing tool-execution and approval paths automatically.

Signature

Parameters

str
required
Unique name for this MCP server (used by remove_mcp_server).
Any
required
An MCP instance (e.g. MCP("npx -y @notionhq/notion-mcp-server")).

Returns

Any
The attached MCP instance.

Usage

Uses

  • ValueError
  • refresh_tools
  • logging.debug

Source

View on GitHub

praisonaiagents/agent/agent.py at line 4865

MCP Concept

MCP Lifecycle