Railway OpenWebUI MCP Server

Railway OpenWebUI MCP Server

Enables deploying, managing, and monitoring OpenWebUI instances on the Railway platform via natural language commands.

Category
访问服务器

README

🚂 Railway OpenWebUI MCP Tool

A comprehensive Model Context Protocol (MCP) tool for deploying, managing, and monitoring OpenWebUI instances on the Railway platform.

Railway OpenWebUI Python MCP

📋 Table of Contents

🌟 Overview

This MCP tool provides a seamless interface for deploying and managing OpenWebUI on Railway's cloud platform. It enables AI assistants and automation systems to:

  • Deploy new OpenWebUI instances with a single command
  • Manage existing deployments (scale, restart, update)
  • Monitor resource usage and logs
  • Configure environment variables and domains
  • Handle database provisioning (PostgreSQL/Redis)

What is OpenWebUI?

OpenWebUI is a self-hosted web interface for running and interacting with Large Language Models (LLMs). It supports multiple backends including Ollama and OpenAI-compatible APIs.

What is Railway?

Railway is a modern cloud platform that makes it easy to deploy, manage, and scale applications. It offers automatic SSL, custom domains, and seamless database provisioning.

What is MCP?

The Model Context Protocol (MCP) is a standard for connecting AI assistants to external tools and data sources. This tool implements MCP to allow AI assistants like Claude to deploy and manage OpenWebUI instances.

✨ Features

Core Deployment

  • 🚀 One-Click Deploy: Deploy OpenWebUI with sensible defaults
  • 🔧 Custom Configuration: Full control over environment variables
  • 🗄️ Database Integration: Automatic PostgreSQL/Redis provisioning
  • 🌐 Custom Domains: Easy domain configuration and SSL
  • 📦 Volume Persistence: Persistent storage for data

Management

  • 📊 Resource Monitoring: CPU, memory, and bandwidth metrics
  • 📝 Log Streaming: Real-time deployment logs
  • 🔄 Rolling Updates: Zero-downtime deployments
  • ⚡ Auto-Scaling: Configure scaling policies
  • 🔁 Version Management: Easy version updates

Integration

  • 🤖 MCP Compatible: Works with Claude and other MCP clients
  • 🔗 Webhook Support: Integration with CI/CD pipelines
  • 🔐 Secure: API key management and secrets handling
  • 🐳 Docker Ready: Full containerization support

📦 Prerequisites

  • Python 3.10+
  • Railway Account with API Token
  • MCP-compatible client (e.g., Claude Desktop, or use as library)

🛠️ Installation

Option 1: pip install (Recommended)

pip install railway-openwebui-mcp

Option 2: From source

git clone https://github.com/chad-atexpedient/Railway-OpenwebUI-Tool.git
cd Railway-OpenwebUI-Tool
pip install -e .

Option 3: Docker

docker build -t railway-openwebui-mcp .
docker run -e RAILWAY_API_TOKEN=your_token railway-openwebui-mcp

Option 4: Using uvx (no installation)

uvx railway-openwebui-mcp

⚙️ Configuration

1. Get Railway API Token

  1. Go to Railway Dashboard
  2. Click "Create Token"
  3. Give it a descriptive name (e.g., "MCP Tool")
  4. Copy the generated token

2. Environment Variables

Create a .env file in your project directory:

# Required
RAILWAY_API_TOKEN=your_railway_api_token

# Optional
DEFAULT_REGION=us-west1
LOG_LEVEL=INFO
MCP_SERVER_PORT=8080

3. MCP Client Configuration

For Claude Desktop

Add to your claude_desktop_config.json:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "railway-openwebui": {
      "command": "python",
      "args": ["-m", "railway_openwebui_mcp"],
      "env": {
        "RAILWAY_API_TOKEN": "your_token_here"
      }
    }
  }
}

Using uvx (recommended for Claude Desktop)

{
  "mcpServers": {
    "railway-openwebui": {
      "command": "uvx",
      "args": ["railway-openwebui-mcp"],
      "env": {
        "RAILWAY_API_TOKEN": "your_token_here"
      }
    }
  }
}

🚀 Usage

Quick Start (Python Library)

from railway_openwebui_mcp import RailwayOpenWebUI

# Initialize the client
client = RailwayOpenWebUI(api_token="your_token")

# Deploy OpenWebUI
deployment = client.deploy_openwebui(
    project_name="my-openwebui",
    region="us-west1",
    enable_signup=True,
    database_type="postgresql",
    redis_enabled=True
)

print(f"🚀 Deployed at: {deployment.url}")
print(f"📋 Project ID: {deployment.project_id}")
print(f"🔧 Service ID: {deployment.service_id}")

MCP Tool Commands (Natural Language)

Once configured with an MCP client, you can use natural language:

Command Description
"Deploy a new OpenWebUI instance called 'my-ai-chat'" Creates new deployment
"Show me the status of my OpenWebUI deployment" Gets deployment status
"Show me the logs for my OpenWebUI" Retrieves recent logs
"Scale my OpenWebUI to 2 replicas" Adjusts scaling
"Add custom domain chat.example.com to my deployment" Configures domain
"Update my OpenWebUI to the latest version" Triggers update
"What's the resource usage of my OpenWebUI?" Gets metrics
"List all my Railway projects" Lists projects
"Delete my OpenWebUI deployment" Removes deployment

Advanced Usage

Deploy with OAuth

deployment = client.deploy_openwebui(
    project_name="secure-openwebui",
    enable_signup=False,
    enable_oauth=True,
    oauth_providers=[
        {
            "provider": "google",
            "client_id": "your-google-client-id",
            "client_secret": "your-google-client-secret"
        },
        {
            "provider": "github",
            "client_id": "your-github-client-id",
            "client_secret": "your-github-client-secret"
        }
    ]
)

Deploy with Custom Environment

deployment = client.deploy_openwebui(
    project_name="custom-openwebui",
    custom_env={
        "OLLAMA_BASE_URL": "https://your-ollama-instance.com",
        "OPENAI_API_KEY": "sk-your-openai-key",
        "WEBUI_NAME": "My Custom AI Chat",
        "DEFAULT_MODELS": "gpt-4,gpt-3.5-turbo",
        "ENABLE_RAG_WEB_SEARCH": "true"
    }
)

Monitor and Manage

# Get status
status = client.get_deployment_status(project_id="your-project-id")
print(f"Status: {status.status}")
print(f"Health: {status.health}")
print(f"Uptime: {status.uptime}")

# Get logs
logs = client.get_logs(
    project_id="your-project-id",
    service_id="your-service-id",
    lines=50
)
for log in logs:
    print(log)

# Scale deployment
result = client.scale_deployment(
    project_id="your-project-id",
    service_id="your-service-id",
    replicas=2,
    memory_limit_mb=1024
)

# Update deployment
client.update_deployment(
    project_id="your-project-id",
    service_id="your-service-id",
    new_version="latest",
    env_updates={"WEBUI_NAME": "Updated Name"}
)

📚 API Reference

Core Functions

deploy_openwebui()

Deploy a new OpenWebUI instance.

def deploy_openwebui(
    project_name: str,
    region: str = "us-west1",
    environment: str = "production",
    openwebui_version: str = "latest",
    enable_signup: bool = True,
    enable_oauth: bool = False,
    oauth_providers: list = None,
    database_type: str = "postgresql",
    redis_enabled: bool = True,
    custom_env: dict = None,
    volume_size_gb: int = 10
) -> Deployment

Parameters:

Parameter Type Default Description
project_name str required Name for the Railway project
region str "us-west1" Deployment region (us-west1, us-east4, europe-west4)
environment str "production" Environment name
openwebui_version str "main" OpenWebUI Docker tag
enable_signup bool True Allow new user registration
enable_oauth bool False Enable OAuth authentication
oauth_providers list None List of OAuth provider configs
database_type str "postgresql" Database type (postgresql, sqlite)
redis_enabled bool True Enable Redis for caching
custom_env dict None Additional environment variables
volume_size_gb int 10 Persistent volume size

Returns: Deployment object


get_deployment_status()

Get the current status of a deployment.

def get_deployment_status(
    project_id: str,
    service_id: str = None
) -> DeploymentStatus

update_deployment()

Update an existing deployment.

def update_deployment(
    project_id: str,
    service_id: str,
    env_updates: dict = None,
    new_version: str = None,
    restart: bool = False
) -> Deployment

scale_deployment()

Scale deployment resources.

def scale_deployment(
    project_id: str,
    service_id: str,
    replicas: int = None,
    cpu_limit: float = None,
    memory_limit_mb: int = None
) -> ScaleResult

get_logs()

Retrieve deployment logs.

def get_logs(
    project_id: str,
    service_id: str,
    lines: int = 100,
    follow: bool = False,
    since: datetime = None
) -> List[str]

configure_domain()

Add or configure a custom domain.

def configure_domain(
    project_id: str,
    service_id: str,
    domain: str,
    enable_ssl: bool = True
) -> DomainConfig

delete_deployment()

Delete a deployment (requires confirmation).

def delete_deployment(
    project_id: str,
    confirm: bool = False
) -> bool

get_metrics()

Get resource usage metrics.

def get_metrics(
    project_id: str,
    service_id: str
) -> ResourceMetrics

list_projects()

List all Railway projects.

def list_projects() -> List[Dict[str, Any]]

🔧 MCP Tools Reference

The following tools are available when using this package as an MCP server:

Tool Name Description Required Parameters
deploy_openwebui Deploy a new OpenWebUI instance project_name
get_deployment_status Get deployment status project_id
update_deployment Update existing deployment project_id, service_id
scale_deployment Scale resources project_id, service_id
get_logs Retrieve logs project_id, service_id
configure_domain Add custom domain project_id, service_id, domain
delete_deployment Delete deployment project_id, confirm
list_projects List all projects None
get_metrics Get resource metrics project_id, service_id

Data Classes

@dataclass
class Deployment:
    id: str
    project_id: str
    service_id: str
    url: str
    status: str
    created_at: datetime
    region: str
    environment: str

@dataclass
class DeploymentStatus:
    status: str  # "running", "deploying", "failed", "stopped"
    health: str  # "healthy", "unhealthy", "unknown"
    uptime: timedelta
    last_deployed: datetime
    current_version: str

@dataclass
class ResourceMetrics:
    cpu_usage_percent: float
    memory_usage_mb: int
    memory_limit_mb: int
    bandwidth_in_mb: float
    bandwidth_out_mb: float
    request_count: int

@dataclass
class DomainConfig:
    domain: str
    ssl_enabled: bool
    dns_configured: bool
    dns_records: List[Dict[str, str]]

@dataclass
class ScaleResult:
    success: bool
    replicas: int
    cpu_limit: float
    memory_limit_mb: int

📋 Deployment Templates

Basic OpenWebUI (SQLite)

client.deploy_openwebui(
    project_name="simple-openwebui",
    database_type="sqlite",
    redis_enabled=False
)

Production Setup (PostgreSQL + Redis)

client.deploy_openwebui(
    project_name="production-openwebui",
    database_type="postgresql",
    redis_enabled=True,
    enable_signup=False,
    custom_env={
        "WEBUI_AUTH": "true",
        "ENABLE_COMMUNITY_SHARING": "false"
    }
)

OpenWebUI with Ollama Connection

client.deploy_openwebui(
    project_name="ollama-openwebui",
    custom_env={
        "OLLAMA_BASE_URL": "https://your-ollama.railway.app",
        "ENABLE_OLLAMA_API": "true"
    }
)

OpenWebUI with OpenAI

client.deploy_openwebui(
    project_name="openai-webui",
    custom_env={
        "OPENAI_API_KEY": "sk-your-api-key",
        "OPENAI_API_BASE_URL": "https://api.openai.com/v1",
        "DEFAULT_MODELS": "gpt-4,gpt-3.5-turbo"
    }
)

Multi-Provider Setup

client.deploy_openwebui(
    project_name="multi-provider-webui",
    custom_env={
        "OLLAMA_BASE_URL": "https://ollama.example.com",
        "OPENAI_API_KEY": "sk-your-key",
        "ANTHROPIC_API_KEY": "sk-ant-your-key",
        "ENABLE_RAG_WEB_SEARCH": "true",
        "RAG_WEB_SEARCH_ENGINE": "duckduckgo"
    }
)

🐛 Troubleshooting

Common Issues

Authentication Error

AuthenticationError: Invalid Railway API token

Solution: Verify your Railway API token is correct and has not expired. Generate a new token at Railway Dashboard.

Deployment Failed

DeploymentError: Deployment failed to start

Solutions:

  1. Check logs: client.get_logs(project_id, service_id)
  2. Verify environment variables
  3. Ensure you have sufficient Railway credits

Rate Limit Exceeded

RateLimitError: API rate limit exceeded

Solution: Wait for the rate limit window to reset (usually 1 minute).

Debug Mode

Enable debug logging:

import logging
logging.basicConfig(level=logging.DEBUG)

client = RailwayOpenWebUI(api_token="your_token", debug=True)

Getting Help

  1. Check the Railway Documentation
  2. Check the OpenWebUI Documentation
  3. Open an issue on this repository

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone the repository
git clone https://github.com/chad-atexpedient/Railway-OpenwebUI-Tool.git
cd Railway-OpenwebUI-Tool

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
ruff check .
black --check .

📄 License

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

🙏 Acknowledgments


<p align="center"> Made with ❤️ for the AI community <br> <a href="https://github.com/chad-atexpedient/Railway-OpenwebUI-Tool">⭐ Star this repo</a> if you find it useful! </p>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选