Create powerful AI workflows by connecting multiple MCP servers including Postgres, Zendesk for enhanced automation capabilities in Klavis AI.
PostgreSQL is a powerful, open source object-relational database system
Zendesk is a customer service software company
Follow these steps to connect your AI agents to these MCP servers
Sign up for KlavisAI to access our MCP server management platform.
Add your desired MCP servers to your AI client and configure authentication settings.
Verify your connections work correctly and start using your enhanced AI capabilities.
import os
from google import genai
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType, ToolFormat
# Initialize clients
klavis_client = Klavis(api_key=os.getenv("KLAVIS_API_KEY"))
client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
user_message = "Your query here"
postgres_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.POSTGRES,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
# Get tools from all MCP servers
postgres_tools = klavis_client.mcp_server.list_tools(
server_url=postgres_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.GEMINI,
)
zendesk_tools = klavis_client.mcp_server.list_tools(
server_url=zendesk_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.GEMINI,
)
# Combine all tools
all_tools = []
all_tools.extend(postgres_tools.tools)
all_tools.extend(zendesk_tools.tools)
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=user_message,
config=genai.types.GenerateContentConfig(
tools=all_tools,
),
)import os
import json
from anthropic import Anthropic
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType, ToolFormat
# Initialize clients
anthropic_client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
klavis_client = Klavis(api_key=os.getenv("KLAVIS_API_KEY"))
# Constants
CLAUDE_MODEL = "claude-3-5-sonnet-20241022"
user_message = "Your message here"
postgres_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.POSTGRES,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
# Get tools from all MCP servers
postgres_tools = klavis_client.mcp_server.list_tools(
server_url=postgres_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.ANTHROPIC,
)
zendesk_tools = klavis_client.mcp_server.list_tools(
server_url=zendesk_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.ANTHROPIC,
)
# Combine all tools
all_tools = []
all_tools.extend(postgres_tools.tools)
all_tools.extend(zendesk_tools.tools)
messages = [
{"role": "user", "content": user_message}
]
response = anthropic_client.messages.create(
model=CLAUDE_MODEL,
max_tokens=4000,
messages=messages,
tools=all_tools
)import Anthropic from '@anthropic-ai/sdk';
import { KlavisClient, Klavis } from 'klavis';
// Initialize clients
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const klavisClient = new KlavisClient({ apiKey: process.env.KLAVIS_API_KEY });
const CLAUDE_MODEL = "claude-3-5-sonnet-20241022";
const userMessage = "Your message here";
const postgresMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Postgres,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
const zendeskMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Zendesk,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
// Get tools from all MCP servers
const postgresTools = await klavisClient.mcpServer.listTools({
serverUrl: postgresMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Anthropic,
});
const zendeskTools = await klavisClient.mcpServer.listTools({
serverUrl: zendeskMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Anthropic,
});
// Combine all tools
const allTools = [
...postgresTools.tools,
...zendeskTools.tools
];
const response = await anthropic.messages.create({
model: CLAUDE_MODEL,
max_tokens: 4000,
messages: [{ role: 'user', content: userMessage }],
tools: allTools,
});import json
import os
from openai import OpenAI
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType, ToolFormat
# Initialize clients
openai_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
klavis_client = Klavis(api_key=os.getenv("KLAVIS_API_KEY"))
# Constants
OPENAI_MODEL = "gpt-4o-mini"
postgres_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.POSTGRES,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
# Get tools from all MCP servers
postgres_tools = klavis_client.mcp_server.list_tools(
server_url=postgres_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.OPENAI,
)
zendesk_tools = klavis_client.mcp_server.list_tools(
server_url=zendesk_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.OPENAI,
)
# Combine all tools
all_tools = []
all_tools.extend(postgres_tools)
all_tools.extend(zendesk_tools)
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": user_message}
]
response = openai_client.chat.completions.create(
model=OPENAI_MODEL,
messages=messages,
tools=all_tools if all_tools else None
)import OpenAI from 'openai';
import { KlavisClient, Klavis } from 'klavis';
// Initialize clients
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const klavisClient = new KlavisClient({ apiKey: process.env.KLAVIS_API_KEY });
const OPENAI_MODEL = "gpt-4o-mini";
const userMessage = "Your query here";
const postgresMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Postgres,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
const zendeskMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Zendesk,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
// Get tools from all MCP servers
const postgresTools = await klavisClient.mcpServer.listTools({
serverUrl: postgresMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Openai,
});
const zendeskTools = await klavisClient.mcpServer.listTools({
serverUrl: zendeskMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Openai,
});
// Combine all tools
const allTools = [
...postgresTools,
...zendeskTools
];
const response = await openai.chat.completions.create({
model: OPENAI_MODEL,
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: userMessage }
],
tools: allTools,
});import os
import asyncio
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
# Initialize clients
klavis_client = Klavis(api_key=os.getenv("KLAVIS_API_KEY"))
llm = ChatOpenAI(model="gpt-4o-mini", api_key=os.getenv("OPENAI_API_KEY"))
postgres_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.POSTGRES,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
mcp_client = MultiServerMCPClient({
"postgres": {
"transport": "streamable_http",
"url": postgres_mcp_instance.server_url
},
"zendesk": {
"transport": "streamable_http",
"url": zendesk_mcp_instance.server_url
}
})
tools = asyncio.run(mcp_client.get_tools())
agent = create_react_agent(
model=llm,
tools=tools,
)
response = asyncio.run(agent.ainvoke({
"messages": [{"role": "user", "content": "Your query here"}]
}))import { KlavisClient, Klavis } from 'klavis';
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
// Initialize clients
const klavisClient = new KlavisClient({ apiKey: process.env.KLAVIS_API_KEY });
const llm = new ChatOpenAI({ model: "gpt-4o-mini", apiKey: process.env.OPENAI_API_KEY });
const postgresMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Postgres,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
const zendeskMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Zendesk,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
const mcpClient = new MultiServerMCPClient({
"postgres": {
transport: "streamable_http",
url: postgresMcpInstance.serverUrl
},
"zendesk": {
transport: "streamable_http",
url: zendeskMcpInstance.serverUrl
}
});
const tools = await mcpClient.getTools();
const agent = createReactAgent({
llm: llm,
tools: tools,
});
const response = await agent.invoke({
messages: [{ role: "user", content: "Your query here" }]
});import os
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType
from llama_index.tools.mcp import (
BasicMCPClient,
get_tools_from_mcp_url,
aget_tools_from_mcp_url,
)
from llama_index.core.agent.workflow import FunctionAgent, AgentWorkflow
# 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",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
postgres_tools = await aget_tools_from_mcp_url(
postgres_mcp_instance.server_url,
client=BasicMCPClient(postgres_mcp_instance.server_url)
)
zendesk_tools = await aget_tools_from_mcp_url(
zendesk_mcp_instance.server_url,
client=BasicMCPClient(zendesk_mcp_instance.server_url)
)
postgres_agent = FunctionAgent(
name="postgres_agent",
tools=postgres_tools,
llm=llm,
)
zendesk_agent = FunctionAgent(
name="zendesk_agent",
tools=zendesk_tools,
llm=llm,
)
workflow = AgentWorkflow(
agents=[postgres_agent, zendesk_agent],
root_agent="postgres_agent",
)import { KlavisClient, Klavis } from 'klavis';
import { mcp } from "@llamaindex/tools";
import { agent, multiAgent } from "@llamaindex/workflow";
import { openai } from "@llamaindex/llm";
// Initialize clients
const klavisClient = new KlavisClient({ apiKey: process.env.KLAVIS_API_KEY });
const postgresMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Postgres,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
const zendeskMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Zendesk,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
// Create MCP server connections
const postgresServer = mcp({
url: postgresMcpInstance.serverUrl,
verbose: true,
});
const zendeskServer = mcp({
url: zendeskMcpInstance.serverUrl,
verbose: true,
});
// Get tools from MCP servers
const postgresTools = await postgresServer.tools();
const zendeskTools = await zendeskServer.tools();
// Create specialized agents
const postgresAgent = agent({
name: "postgres_agent",
llm: openai({ model: "gpt-4o" }),
tools: postgresTools,
});
const zendeskAgent = agent({
name: "zendesk_agent",
llm: openai({ model: "gpt-4o" }),
tools: zendeskTools,
});
// Create multi-agent workflow
const agents = multiAgent({
agents: [postgresAgent, zendeskAgent],
rootAgent: postgresAgent,
});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",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
# Initialize MCP tools for each server
postgres_tools = MCPServerAdapter(postgres_mcp_instance.server_params)
zendesk_tools = MCPServerAdapter(zendesk_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
)
zendesk_agent = Agent(
role="Zendesk Specialist",
goal="Handle all Zendesk related tasks and data processing",
backstory="You are an expert in Zendesk operations and data analysis",
tools=zendesk_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
)
# Create multi-agent crew
crew = Crew(
agents=[postgres_agent, zendesk_agent],
tasks=[research_task],
verbose=False,
process=Process.sequential
)
result = crew.kickoff()// CrewAI currently only supports Python. Please use the Python example.import os
import json
from fireworks.client import Fireworks
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType, ToolFormat
# Initialize clients
fireworks_client = Fireworks(api_key=os.getenv("FIREWORKS_API_KEY"))
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,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
platform_name="Klavis",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
# Get all MCP tools
postgres_tools = klavis_client.mcp_server.list_tools(
server_url=postgres_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.OPENAI,
)
zendesk_tools = klavis_client.mcp_server.list_tools(
server_url=zendesk_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.OPENAI,
)
# Combine all tools
all_tools = []
all_tools.extend(postgres_tools.tools)
all_tools.extend(zendesk_tools.tools)
messages = [
{"role": "system", "content": "You are a helpful assistant with access to multiple data sources."},
{"role": "user", "content": user_message}
]
response = fireworks_client.chat.completions.create(
model="accounts/fireworks/models/llama-v3p1-70b-instruct",
messages=messages,
tools=all_tools
)import Fireworks from 'fireworks-ai';
import { KlavisClient, Klavis } from 'klavis';
// Initialize clients
const fireworks = new Fireworks({ apiKey: process.env.FIREWORKS_API_KEY });
const klavisClient = new KlavisClient({ apiKey: process.env.KLAVIS_API_KEY });
const postgresMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Postgres,
userId: "1234",
platformName: "Klavis",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
const zendeskMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Zendesk,
userId: "1234",
platformName: "Klavis",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
// Get all MCP tools
const postgresTools = await klavisClient.mcpServer.listTools({
serverUrl: postgresMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Openai,
});
const zendeskTools = await klavisClient.mcpServer.listTools({
serverUrl: zendeskMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Openai,
});
// Combine all tools
const allTools = [
...postgresTools.tools,
...zendeskTools.tools
];
const response = await fireworks.chat.completions.create({
model: "accounts/fireworks/models/llama-v3p1-70b-instruct",
messages: [
{ role: "system", content: "You are a helpful assistant with access to multiple data sources." },
{ role: "user", content: userMessage }
],
tools: allTools,
});import os
import json
from together import Together
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType, ToolFormat
# Initialize clients
together_client = Together(api_key=os.getenv("TOGETHER_API_KEY"))
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",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
zendesk_mcp_instance = klavis_client.mcp_server.create_server_instance(
server_name=McpServerName.ZENDESK,
user_id="1234",
connection_type=ConnectionType.STREAMABLE_HTTP,
)
# Get all MCP tools
postgres_tools = klavis_client.mcp_server.list_tools(
server_url=postgres_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.OPENAI,
)
zendesk_tools = klavis_client.mcp_server.list_tools(
server_url=zendesk_mcp_instance.server_url,
connection_type=ConnectionType.STREAMABLE_HTTP,
format=ToolFormat.OPENAI,
)
# Combine all tools
all_tools = []
all_tools.extend(postgres_tools.tools)
all_tools.extend(zendesk_tools.tools)
messages = [
{"role": "system", "content": "You are a helpful AI assistant with access to multiple data sources."},
{"role": "user", "content": user_message}
]
response = together_client.chat.completions.create(
model="meta-llama/Llama-2-70b-chat-hf",
messages=messages,
tools=all_tools
)import Together from 'together-ai';
import { KlavisClient, Klavis } from 'klavis';
// Initialize clients
const togetherClient = new Together({ apiKey: process.env.TOGETHER_API_KEY });
const klavisClient = new KlavisClient({ apiKey: process.env.KLAVIS_API_KEY });
const postgresMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Postgres,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
const zendeskMcpInstance = await klavisClient.mcpServer.createServerInstance({
serverName: Klavis.McpServerName.Zendesk,
userId: "1234",
connectionType: Klavis.ConnectionType.StreamableHttp,
});
// Get all MCP tools
const postgresTools = await klavisClient.mcpServer.listTools({
serverUrl: postgresMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Openai,
});
const zendeskTools = await klavisClient.mcpServer.listTools({
serverUrl: zendeskMcpInstance.serverUrl,
connectionType: Klavis.ConnectionType.StreamableHttp,
format: Klavis.ToolFormat.Openai,
});
// Combine all tools
const allTools = [
...postgresTools.tools,
...zendeskTools.tools
];
const response = await togetherClient.chat.completions.create({
model: "meta-llama/Llama-2-70b-chat-hf",
messages: [
{ role: "system", content: "You are a helpful AI assistant with access to multiple data sources." },
{ role: "user", content: userMessage }
],
tools: allTools,
});Everything you need to know about connecting to these MCP servers
Join developers who are already using KlavisAI to power their AI agents and AI applications with these MCP servers.
Start For Free