Skip to main content
Connect agents to Model Context Protocol (MCP) servers to give them access to external tools, data, and services.

Quick Start

1

Simple Usage

2

With Configuration


Transport Selection

The MCP class picks the right transport automatically — no config objects needed.
Auto-detection is suffix-based: only URLs that end exactly with /sse select SSE. A URL like https://api.example.com/sse/v2 will not auto-select SSE — pass 'sse' explicitly.

Examples


Configuration Options


Instance API


New Exports


Parity MCP Class (multi-server)

The MCP class exported from praisonai manages multiple named MCP servers and delegates to the real MCPClient (stdio / HTTP / SSE). It mirrors Python’s praisonaiagents.mcp and uses a connect / callTool API keyed by server name.
Before v1.7.4, this parity MCP.callTool() returned null and silently no-op’d every call. As of v1.7.4 it delegates to a live MCPClient connection.
Call connect(name, config) before callTool(name, ...). Calling a tool on an unconnected server throws MCP server '<name>' is not connected.

AI SDK-style: createMCP()

createMCP() from 'praisonai/ai' is the AI SDK-style client with full transport support.

Transport types

MCPTransportConfig is a discriminated union on type.

MCPConfig

MCPClient methods

createMCP() no longer returns an empty client when the underlying transport fails. Connection errors, unknown transport types, and missing binaries now throw — an agent that used to silently get zero tools now fails loudly with the real error.

Best Practices

MCP connections stay open until explicitly closed. Always call await mcp.close() to release resources, especially in long-running applications or when switching servers.
Enable debug mode when first wiring up a new MCP server. It logs the selected transport and number of tools loaded, making misconfiguration easy to spot.
Auto-detection relies on the URL ending in /sse. If your server URL doesn’t follow this convention, pass the transport explicitly to avoid surprises.
Use the unified MCP class for all new integrations. MCPHttpStreaming is a standalone client without auto-detection. Only use it if you specifically need direct HTTP-Streaming without the unified interface.

MCP Security

Secure MCP connections with authentication and rate limiting

Python MCP Transports

Python equivalent — stdio, Streamable HTTP, WebSocket, SSE

Tools

Tool system overview for TypeScript agents

Agent

Agent configuration and capabilities