Create powerful collaborative AI workflows by connecting multiple MCP servers including Postgres, Doc2markdown, Perplexity for enhanced multi-agent automation capabilities in Klavis AI.
PostgreSQL is a powerful, open source object-relational database system
Convert any file to markdown using markitdown
Perplexity is an AI research assistant that provides accurate answers and cites sources
Follow these steps to connect CrewAI to these MCP servers
Sign up for KlavisAI to access our MCP server management platform.
Set up your CrewAI agents with your desired MCP servers tools and configure authentication settings for collaborative workflows.
Test your multi-agent workflows and start using your enhanced collaborative AI capabilities.
import os
from crewai import Agent, Task, Crew, Process
from crewai_tools import MCPServerAdapter
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType
# Initialize clients
klavis_client = Klavis(api_key=os.getenv("KLAVIS_API_KEY"))
postgres_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.POSTGRES,
user_id="1234",
platform_name="Klavis",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
doc2markdown_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.DOC2MARKDOWN,
user_id="1234",
platform_name="Klavis",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
perplexity_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.PERPLEXITY,
user_id="1234",
platform_name="Klavis",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
# Initialize MCP tools for each server
postgres_tools = MCPServerAdapter(postgres_mcp_instance.server_params)
doc2markdown_tools = MCPServerAdapter(doc2markdown_mcp_instance.server_params)
perplexity_tools = MCPServerAdapter(perplexity_mcp_instance.server_params)
# Create specialized agents for each service
postgres_agent = Agent(
role="Postgres Specialist",
goal="Handle all Postgres related tasks and data processing",
backstory="You are an expert in Postgres operations and data analysis",
tools=postgres_tools,
reasoning=True,
verbose=False
)
doc2markdown_agent = Agent(
role="Doc2markdown Specialist",
goal="Handle all Doc2markdown related tasks and data processing",
backstory="You are an expert in Doc2markdown operations and data analysis",
tools=doc2markdown_tools,
reasoning=True,
verbose=False
)
perplexity_agent = Agent(
role="Perplexity Specialist",
goal="Handle all Perplexity related tasks and data processing",
backstory="You are an expert in Perplexity operations and data analysis",
tools=perplexity_tools,
reasoning=True,
verbose=False
)
# Define collaborative tasks
research_task = Task(
description="Gather comprehensive data from all available sources",
expected_output="Raw data and initial findings from all services",
agent=postgres_agent,
markdown=True
)
analysis_task = Task(
description="Analyze and synthesize the gathered data",
expected_output="Comprehensive analysis with insights and recommendations",
agent=doc2markdown_agent,
markdown=True
)
# Create multi-agent crew
multi_agent_crew = Crew(
agents=[postgres_agent, doc2markdown_agent, perplexity_agent],
tasks=[research_task, analysis_task],
verbose=False,
process=Process.sequential
)
result = multi_agent_crew.kickoff()
Everything you need to know about connecting CrewAI to these MCP servers
Join developers who are already using KlavisAI to power their CrewAI multi-agent systems with these MCP servers.
Start For Free