Skip to main content
MCP (Model Context Protocol) connects your agent to external tools and services with zero code.

Quick Start

1

Create MCP Client

use praisonai::{MCP, MCPBuilder};

// Create MCP client for memory server
let mcp = MCP::new()
    .name("memory")
    .server("npx", &["-y", "@anthropic/mcp-server-memory"])
    .build()?;

// Connect to the server
mcp.connect().await?;

// List available tools
let tools = mcp.list_tools().await?;
2

HTTP Transport

use praisonai::{MCP, MCPBuilder};

// Connect to remote MCP server
let mcp = MCP::new()
    .name("remote")
    .http("https://api.example.com/mcp")
    .build()?;

mcp.connect().await?;
3

WebSocket Transport

use praisonai::{MCP, MCPBuilder};

// Real-time MCP connection
let mcp = MCP::new()
    .name("realtime")
    .websocket("wss://live.example.com/mcp")
    .build()?;

mcp.connect().await?;

How It Works


Transport Types

Choose how to connect to MCP servers:
TransportUse CaseExample
StdioLocal subprocessnpx @anthropic/mcp-server-*
HTTPRemote APIhttps://api.example.com/mcp
WebSocketRealtime connectionwss://live.example.com/mcp

Configuration Options

MCPBuilder Methods

MethodSignatureDescription
name(n)fn name(impl Into<String>) -> SelfSet server name
server(cmd, args)fn server(impl Into<String>, &[&str]) -> SelfStdio transport
http(url)fn http(impl Into<String>) -> SelfHTTP transport
websocket(url)fn websocket(impl Into<String>) -> SelfWebSocket transport
config(cfg)fn config(MCPConfig) -> SelfSet full config
security(sec)fn security(SecurityConfig) -> SelfSet security
build()fn build(self) -> Result<MCP>Build client

MCP Methods

MethodSignatureDescription
connect()async fn connect(&mut self) -> Result<()>Connect to server
disconnect()async fn disconnect(&mut self) -> Result<()>Disconnect
is_connected()fn is_connected(&self) -> boolCheck connection
list_tools()async fn list_tools(&self) -> Result<Vec<MCPTool>>List available tools
list_resources()async fn list_resources(&self) -> Result<Vec<MCPResource>>List resources
list_prompts()async fn list_prompts(&self) -> Result<Vec<MCPPrompt>>List prompts
call_tool(call)async fn call_tool(&self, MCPCall) -> Result<MCPCallResult>Execute tool
read_resource(uri)async fn read_resource(&self, &str) -> Result<MCPContent>Read resource

ServerPurposeCommand
MemoryPersistent memory@anthropic/mcp-server-memory
FilesystemFile operations@anthropic/mcp-server-filesystem
FetchHTTP requests@anthropic/mcp-server-fetch
GitHubGitHub API@anthropic/mcp-server-github

Best Practices

Stdio transport is simplest and most reliable for local MCP servers.
Increase timeout for slow-starting servers or remote connections.
Chain servers for rich capabilities - memory + filesystem + web.