Skip to main content
POST
Add Mcp

Headers

x-user-id
string
required

Caller's user ID. Temporary header-based identity; will be replaced by JWT auth.

Query Parameters

agent_id
string
required
session_id
string
required

Body

application/json

The unified MCP client in AgentScope.

This class provides a unified interface for MCP connections, handling both stateful (persistent) and stateless (ephemeral) connections.

  • Stateful: Requires explicit connect() and close(), maintains session
  • Stateless: No connect() needed, creates temporary session per call

Private attributes:

  • _client: The underlying MCP client context manager
  • _session: The MCP ClientSession (for stateful connections only)
  • _stack: AsyncExitStack for managing connection lifecycle
  • _is_connected: Connection state flag
  • _cached_tools: Cached list of tools

Example:

.. code-block:: python

name
string
required

The MCP name.

is_stateful
boolean
required

Whether this is a stateful connection that requires explicit connect() and close(). STDIO MCP must be stateful. HTTP MCP can be either stateful or stateless.

mcp_config
StdioMCPConfig · object
required

The STDIO MCP server configuration.

enable_tools
string[] | null
disable_tools
string[] | null
execution_timeout
number | null

Response

Successful Response