Skip to main content
Glama

MCP Platform

by jck411

MCP Backend OpenRouter

A high-performance chatbot platform connecting MCP servers with LLM APIs for intelligent tool execution.

🚀 Quick Start

# Install dependencies uv install # Start the platform uv run python src/main.py # Reset configuration to defaults uv run mcp-reset-config

Connect: ws://localhost:8000/ws/chat

📡 WebSocket API

Send Messages

{ "type": "user_message", "message": "Hello, how can you help me today?" }

Receive Responses

{ "type": "assistant_message", "message": "I'm here to help! What would you like to know?", "thinking": "The user is greeting me...", "usage": { "prompt_tokens": 15, "completion_tokens": 12, "total_tokens": 27 } }

Message Types

TypePurposePayload
user_messageSend user input{"type": "user_message", "message": "text"}
clear_historyStart new session{"type": "clear_history"}
assistant_messageAI response{"type": "assistant_message", "message": "text", "thinking": "reasoning"}
tool_executionTool status{"type": "tool_execution", "tool_name": "name", "status": "executing"}

⚙️ Configuration

Essential Settings (src/runtime_config.yaml)

chat: websocket: port: 8000 # WebSocket server port service: max_tool_hops: 8 # Maximum tool call iterations streaming: enabled: true # Enable streaming responses storage: persistence: db_path: "chat_history.db" retention: max_age_hours: 24 max_messages: 1000 llm: active: "openrouter" # Active LLM provider providers: openrouter: base_url: "https://openrouter.ai/api/v1" model: "openai/gpt-4o-mini" temperature: 0.7 max_tokens: 4096

MCP Servers (servers_config.json)

{ "mcpServers": { "demo": { "enabled": true, "command": "uv", "args": ["run", "python", "Servers/config_server.py"], "cwd": "/path/to/your/project" } } }

🔧 Performance Tuning

Streaming Optimization

chat: service: streaming: persistence: persist_deltas: false # Maximum speed (no DB writes during streaming) interval_ms: 200 # Flush every 200ms min_chars: 1024 # Or when buffer reaches 1024 chars

HTTP/2 Support

uv add h2 # Required for HTTP/2 optimization

🛠️ Development

Code Standards

  • Use uv for package management
  • Pydantic for data validation
  • Type hints required
  • Fail-fast error handling

Available Scripts

uv run python src/main.py # Start platform uv run python scripts/format.py # Format code uv run mcp-reset-config # Reset configuration

Code Formatting

# Quick format (ignores line length issues) ./format.sh # Full check including line length uv run ruff check src/ # Format specific files uv run ruff format src/chat/ src/clients/

📁 Project Structure

MCP_BACKEND_OPENROUTER/ ├── src/ # Main source code │ ├── main.py # Application entry point │ ├── config.py # Configuration management │ ├── websocket_server.py # WebSocket communication │ ├── chat/ # Chat system modules │ ├── clients/ # LLM and MCP clients │ └── history/ # Storage and persistence ├── Servers/ # MCP server implementations ├── config.yaml # Default configuration ├── runtime_config.yaml # Runtime overrides ├── servers_config.json # MCP server config └── uv.lock # Dependency lock file

🔑 Environment Variables

# Required for LLM APIs export OPENAI_API_KEY="your-key" export OPENROUTER_API_KEY="your-key" export GROQ_API_KEY="your-key"

🚨 Troubleshooting

Common Issues

ProblemSolution
Configuration not updatingCheck file permissions on runtime_config.yaml
WebSocket connection failsVerify server is running and port is correct
MCP server errorsCheck servers_config.json and server availability
LLM API issuesVerify API keys and model configuration

Debug Mode

# In runtime_config.yaml logging: level: "DEBUG"

Component Testing

# Test configuration from src.config import Configuration config = Configuration() print(config.get_config_dict()) # Test LLM client from src.clients.llm_client import LLMClient llm = LLMClient(config.get_llm_config())

✅ Features

  • Full MCP Protocol - Tools, prompts, resources
  • High Performance - SQLite with WAL mode, optimized indexes
  • Real-time Streaming - WebSocket with delta persistence
  • Multi-Provider - OpenRouter (100+ models), OpenAI, Groq
  • Type Safe - Pydantic validation throughout
  • Dynamic Configuration - Runtime changes without restart
  • Auto-Persistence - Automatic conversation storage

📚 Quick Reference

CommandPurpose
uv run python src/main.pyStart the platform
uv run mcp-reset-configReset to default config
Edit runtime_config.yamlChange settings (auto-reload)
Edit servers_config.jsonConfigure MCP servers

🆘 Support

  • Check logs for detailed error messages
  • Verify configuration syntax with YAML validator
  • Test individual components for isolation
  • Monitor WebSocket connections and database size

Requirements: Python 3.13+, uv package manager

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

High-performance Model Context Protocol server supporting multiple LLM providers (OpenRouter, OpenAI, Groq) with WebSocket API and conversation history persistence.

  1. 🚀 Quick Start
    1. 📡 WebSocket API
      1. Send Messages
      2. Receive Responses
      3. Message Types
    2. ⚙️ Configuration
      1. Essential Settings (src/runtime_config.yaml)
      2. MCP Servers (servers_config.json)
    3. 🔧 Performance Tuning
      1. Streaming Optimization
      2. HTTP/2 Support
    4. 🛠️ Development
      1. Code Standards
      2. Available Scripts
      3. Code Formatting
    5. 📁 Project Structure
      1. 🔑 Environment Variables
        1. 🚨 Troubleshooting
          1. Common Issues
          2. Debug Mode
          3. Component Testing
        2. ✅ Features
          1. 📚 Quick Reference
            1. 🆘 Support

              Related MCP Servers

              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server that enables LLMs to interact with databases (currently MongoDB) through natural language, supporting operations like querying, inserting, deleting documents, and running aggregation pipelines.
                Last updated -
                MIT License
                • Apple
              • A
                security
                F
                license
                A
                quality
                A Model Context Protocol server that enables LLMs to explore and interact with API specifications by providing tools for loading, browsing, and getting detailed information about API endpoints.
                Last updated -
                4
                12
                13
              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server that provides knowledge graph-based persistent memory for LLMs, allowing them to store, retrieve, and reason about information across multiple conversations and sessions.
                Last updated -
                9
                94,266
                2
                MIT License
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol server that allows saving, retrieving, adding, and clearing memories from LLM conversations with MongoDB persistence.
                Last updated -
                11
                2
                MIT License

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/jck411/MCP_BACKEND_OPENROUTER'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server