8000 GitHub - Klavis-AI/klavis: Klavis AI (YC X25): Open Source MCP integration for AI applications
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Klavis-AI/klavis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Klavis AI - open source MCP integrations for AI Applications

Documentation Website Discord License: MIT PyPI npm

What is Klavis AI?

Klavis AI is open source MCP integrations for AI Applications. Our API provides hosted, secure MCP servers, eliminating auth management and client-side code.

✨ Key Features

  • πŸš€ Instant Integration: Get started in minutes with our Python and TypeScript SDKs, or simply REST API
  • πŸ” Built-in Authentication: Secure OAuth flows and API key management
  • ⚑ Production-Ready: Hosted infrastructure that scales to millions of users
  • πŸ› οΈ 100+ Tools: Access to CRM, GSuite, Github, Slack, databases, and many more
  • 🌐 Multi-Platform: Works with any LLM provider (OpenAI, Anthropic, Gemini, etc.) and any AI agent framework (LangChain, Llamaindex, CrewAI, AutoGen, etc.)
  • πŸ”§ Self-Hostable: Open-source MCP servers you can run yourself

πŸš€ Quick Start

Installation

Python

pip install klavis

TypeScript/JavaScript

npm install klavis

Get Your API Key

Sign up at klavis.ai and create your API key.

With MCP Client

If you already have an MCP client implementation in your codebase:

Python Example

from klavis import Klavis
from klavis.types import McpServerName, ConnectionType

klavis_client = Klavis(api_key="your-klavis-key")

# Create a YouTube MCP server instance
youtube_server = klavis_client.mcp_server.create_server_instance(
    server_name=McpServerName.YOUTUBE,
    user_id="user123", # Change to user id in your platform
    platform_name="MyApp", # change to your platform
    connection_type=ConnectionType.STREAMABLE_HTTP,
)

print(f"Server created: {youtube_server.server_url}")

TypeScript Example

import { KlavisClient, Klavis } from 'klavis';

const klavisClient = new KlavisClient({ apiKey: 'your-klavis-key' });

// Create Gmail MCP server with OAuth
const gmailServer = await klavisClient.mcpServer.createServerInstance({
    serverName: Klavis.McpServerName.Gmail,
    userId: "user123",
    platformName: "MyApp",
    connectionType: Klavis.ConnectionType.StreamableHttp
});

// Gmail needs OAuth flow
await window.open(gmailServer.oauthUrl);

Without MCP Client (Function Calling)

Integrate directly with your LLM provider or AI agent framework using function calling:

Python + OpenAI Example

import json
from openai import OpenAI
from klavis import Klavis
from klavis.types import McpServerName, ConnectionType, ToolFormat

OPENAI_MODEL = "gpt-4o-mini"

openai_client = OpenAI(api_key="YOUR_OPENAI_API_KEY")
klavis_client = Klavis(api_key="YOUR_KLAVIS_API_KEY")

# Create server instance
youtube_server = klavis_client.mcp_server.create_server_instance(
    server_name=McpServerName.YOUTUBE,
    user_id="user123",
    platform_name="MyApp",
    connection_type=ConnectionType.STREAMABLE_HTTP,
)

# Get available tools in OpenAI format
tools = klavis_client.mcp_server.list_tools(
    server_url=youtube_server.server_url,
    connection_type=ConnectionType.STREAMABLE_HTTP,
    format=ToolFormat.OPENAI,
)

# Initial conversation
messages = [{"role": "user", "content": "Summarize this video: https://youtube.com/watch?v=..."}]

# First OpenAI call with function calling
response = openai_client.chat.completions.create(
    model=OPENAI_MODEL,
    messages=messages,
    tools=tools.tools
)

messages.append(response.choices[0].message)

# Handle tool calls
if response.choices[0].message.tool_calls:
    for tool_call in response.choices[0].message.tool_calls:
        result = klavis_client.mcp_server.call_tools(
            server_url=youtube_server.server_url,
            tool_name=tool_call.function.name,
            tool_args=json.loads(tool_call.function.arguments),
            connection_type=ConnectionType.STREAMABLE_HTTP
        )
        
        # Add tool result to conversation
        messages.append({
            "role": "tool",
            "tool_call_id": tool_call.id,
            "content": str(result)
        })

# Second OpenAI call to process tool results and generate final response
final_response = openai_client.chat.completions.create(
    model=OPENAI_MODEL,
    messages=messages
)

print(final_response.choices[0].message.content)

TypeScript + OpenAI Example

import OpenAI from 'openai';
import { KlavisClient, Klavis } from 'klavis';

// Constants
const OPENAI_MODEL = "gpt-4o-mini";

const EMAIL_RECIPIENT = "john@example.com";
const EMAIL_SUBJECT = "Hello from Klavis";
const EMAIL_BODY = "This email was sent using Klavis MCP Server!";

const openaiClient = new OpenAI({ apiKey: 'your-openai-key' });
const klavisClient = new KlavisClient({ apiKey: 'your-klavis-key' });

// Create server and get tools
const gmailServer = await klavisClient.mcpServer.createServerInstance({
    serverName: Klavis.McpServerName.Gmail,
    userId: "user123",
    platformName: "MyApp"
});

// Handle OAuth authentication for Gmail
if (gmailServer.oauthUrl) {
    console.log("Please complete OAuth authorization:", gmailServer.oauthUrl);
    await window.open(gmailServer.oauthUrl);
}

const tools = await klavisClient.mcpServer.listTools({
    serverUrl: gmailServer.serverUrl,
    connectionType: Klavis.ConnectionType.StreamableHttp,
    format: Klavis.ToolFormat.Openai
});

// Initial conversation
const messages = [{ 
    role: "user", 
    content: `Please send an email to ${EMAIL_RECIPIENT} with subject "${EMAIL_SUBJECT}" and body "${EMAIL_BODY}"` 
}];

// First OpenAI call with function calling
const response = await openaiClient.chat.completions.create({
    model: OPENAI_MODEL,
    messages: messages,
    tools: tools.tools
});

messages.push(response.choices[0].message);

// Handle tool calls
if (response.choices[0].message.tool_calls) {
    for (const toolCall of response.choices[0].message.tool_calls) {
        const result = await klavisClient.mcpServer.callTools({
            serverUrl: gmailServer.serverUrl,
            toolName: toolCall.function.name,
            toolArgs: JSON.parse(toolCall.function.arguments),
            connectionType: Klavis.ConnectionType.StreamableHttp
        });
        
        // Add tool result to conversation
        messages.push({
            role: "tool",
            tool_call_id: toolCall.id,
            content: JSON.stringify(result)
        });
    }
}

// Second OpenAI call to process tool results and generate final response
const finalResponse = await openaiClient.chat.completions.create({
    model: OPENAI_MODEL,
    messages: messages
});

console.log(finalResponse.choices[0].message.content);

πŸ“š AI Platform Integration Tutorials

πŸ› οΈ Available MCP Servers

CRM & Sales

  • Salesforce - CRM and sales automation
  • Close - Sales CRM platform
  • Asana - Team collaboration and project management
  • Attio - Modern CRM platform
  • ClickUp - All-in-one workspace
  • Motion - AI-powered task management

Google Workspace

Development & Productivity

  • GitHub - Repository operations and automation
  • Jira - Project management and sprint tracking
  • Linear - Issue tracking and project management
  • Notion - Workspace and documentation management
  • Confluence - Team documentation and knowledge base
  • Figma - Design collaboration platform

Communication & Collaboration

  • Discord - Discord API integration
  • Slack - Slack workspace automation
  • Resend - Transactional email service

Data & Analytics

  • Postgres - Database operations and queries
  • Supabase - Backend-as-a-Service platform
  • Gong - Revenue intelligence platform

Content & Media

Payments & Infrastructure

View All Servers β†’

πŸ”§ Authentication & Multi-Tool Workflows

Authentication

Many MCP servers require authentication. Klavis handles this seamlessly:

# For OAuth services (Gmail, Google Drive, etc.)
server = klavis_client.mcp_server.create_server_instance(
    server_name=McpServerName.GMAIL,
    user_id="user123",
    platform_name="MyApp"
)
# Option 1 - OAuth URL is provided in server.oauth_url, redirect user to OAuth URL for authentication
import webbrowser
webbrowser.open(server.oauth_url)

# Option 2 - or for API key services
klavis_client.mcp_server.set_auth_token(
    instance_id=server.instance_id,
    auth_token="your-service-api-key"
)

Multi-Tool Workflows

Combine multiple MCP servers for complex workflows:

# Create multiple servers
github_server = klavis_client.mcp_server.create_server_instance(...)
slack_server = klavis_client.mcp_server.create_server_instance(...)

# Use tools from both servers in a single AI conversation
all_tools = []
all_tools.extend(klavis_client.mcp_server.list_tools(github_server.server_url).tools)
all_tools.extend(klavis_client.mcp_server.list_tools(slack_server.server_url).tools)

# Initialize conversation
messages = [{"role": "user", "content": "Create a GitHub issue and notify the team on Slack"}]

# Loop to let LLM work with multiple tools
max_iterations = 5
for iteration in range(max_iterations):
    response = openai_client.chat.completions.create(
        model="gpt-4",
        messages=messages,
        tools=all_tools
    )
    
    messages.append(response.choices[0].message)
    
    # Check if LLM wants to use tools
    if response.choices[0].message.tool_calls:
        for tool_call in response.choices[0].message.tool_calls:
            # Determine which server to use based on tool name
            server_url = github_server.server_url if "github" in tool_call.function.name else slack_server.server_url
            
            # Execute tool
            result = klavis_client.mcp_server.call_tools(
                server_url=server_url,
                tool_name=tool_call.function.name,
                tool_args=json.loads(tool_call.function.arguments),
                connection_type=ConnectionType.STREAMABLE_HTTP
            )
            
            # Add tool result to conversation
            messages.append({
                "role": "tool",
                "tool_call_id": tool_call.id,
                "content": str(result)
            })
    else:
        # LLM finished the task
        print(f"Task completed in {iteration + 1} iterations")
        print(response.choices[0].message.content)
        break

🏠 Self-Hosting

Want to run MCP servers yourself? All our servers are open-source:

# Clone the repository
git clone https://github.com/klavis-ai/klavis.git
cd klavis

# Run a specific MCP server
cd mcp_servers/github
docker build -t klavis-github .
docker run -p 8000:8000 klavis-github

MCP Clients

Build custom integrations with our MCP clients:

πŸ“– Documentation

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. Report Issues: Found a bug? Open an issue
  2. Request Features: Have an idea? Start a discussion
  3. Contribute Code: Check our Contributing Guidelines
  4. Join Community: Connect with us on Discord

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


Ready to supercharge your AI applications?

Get Started β€’ Documentation β€’ Discord β€’ Examples

0