llm-mcp

sandraschi/llm-mcp

3.2

If you are the rightful owner of llm-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The LLM MCP Server is a FastMCP 2.10-compliant server designed to manage local and cloud-based large language models (LLMs) with advanced features such as video generation and interactive chat capabilities.

Tools
5
Resources
0
Prompts
0

LLM MCP Server

License: MIT Python 3.8+ Code style: black DXT Compatible

A FastMCP 2.10-compliant server for managing local and cloud LLMs with support for video generation and advanced chat features. This server implements the Model Control Protocol (MCP) and is compatible with Anthropic's Desktop Extensions (DXT) standard.

🌟 Features

  • Unified API for multiple LLM providers (Ollama, LM Studio, vLLM, OpenAI, Anthropic, Gemini, etc.)
  • Model Management: List, load, unload, and download models
  • Provider Management: Check provider status and initialize providers programmatically
  • Ollama Auto-Start: Automatic startup of Ollama server when needed
  • Inference API: Standardized interface for text generation
  • Video Generation: Integration with Gemini Veo 3 for text/image to video
  • Failover & Fallback: Automatic fallback to alternative models
  • Chat Terminal: Interactive terminal with personas and rulebooks
  • FastMCP 2.10 Compliance: Full compatibility with the MCP protocol
  • DXT Compatible: Ready for packaging with Anthropic's Desktop Extensions

šŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Git
  • (Optional) Ollama or LM Studio for local models
  • (Optional) DXT CLI for packaging as a DXT extension

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/llm-mcp.git
    cd llm-mcp
    
  2. Create and activate a virtual environment:

    # On Windows
    python -m venv venv
    .\venv\Scripts\activate
    
    # On Unix/macOS
    python3 -m venv venv
    source venv/bin/activate
    
  3. Install the package in development mode:

    pip install -e ".[dev]"
    
  4. Configure your environment:

    cp .env.example .env
    # Edit .env with your configuration
    

Configuration

Edit the .env file with your settings:

# Server configuration
HOST=0.0.0.0
PORT=8000
LOG_LEVEL=info

# Authentication (comma-separated list of API keys)
API_KEYS=your-api-key-here

# Ollama configuration
OLLAMA_BASE_URL=http://localhost:11434

# LM Studio configuration
LMSTUDIO_BASE_URL=http://localhost:1234

# OpenAI configuration
OPENAI_API_KEY=your-openai-key

# Anthropic configuration
ANTHROPIC_API_KEY=your-anthropic-key

šŸ› ļø Usage

Start the server

python -m llm_mcp.server

Using the Chat Terminal

# Start the chat terminal
python tools/chat_terminal.py

# With specific provider and model
python tools/chat_terminal.py --provider anthropic --model claude-3-opus-20240229

# With persona and rulebook
python tools/chat_terminal.py --persona code_expert --rulebook coding_rules

Provider Management

Check the status of a provider:

curl -X 'GET' \
  'http://localhost:8000/api/v1/providers/ollama/status' \
  -H 'accept: application/json'

Load a provider (with optional auto-start for Ollama):

curl -X 'POST' \
  'http://localhost:8000/api/v1/providers/ollama/load' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "auto_start": true,
    "wait_until_ready": true,
    "timeout": 30
  }'

DXT Packaging

Package the server as a DXT extension:

# Install DXT CLI (if not already installed)
npm install -g @anthropic/dxt

# Create the package
dxt pack -o llm-mcp.dxt

šŸ› ļø Available Tools

The server exposes the following MCP tools:

ToolDescription
list_modelsList all available models from all providers
get_modelGet details about a specific model
load_modelLoad a model into memory
unload_modelUnload a model from memory
get_loaded_modelsList all currently loaded models
generate_textGenerate text using a loaded model
chatGenerate a chat completion
get_provider_statusCheck the status of a provider
load_providerLoad and initialize a provider

API Documentation

Once the server is running, visit:

šŸ¤– Supported Providers

  • Ollama
  • LM Studio
  • vLLM
  • OpenAI
  • Anthropic
  • Google Gemini
  • More coming soon...

🧩 Extending with Custom Providers

  1. Create a new provider in src/llm_mcp/services/providers/
  2. Implement the required methods from BaseProvider
  3. Add your provider to the ProviderFactory
  4. Update configuration as needed

Provider Interface

All providers must implement the following methods:

class BaseProvider(ABC):
    @abstractmethod
    async def list_models(self) -> List[Dict[str, Any]]:
        """List all available models."""
        pass

    @abstractmethod
    async def generate_text(self, model_id: str, prompt: str, **kwargs) -> str:
        """Generate text using the specified model."""
        pass

    @property
    @abstractmethod
    def name(self) -> str:
        """Return the name of the provider."""
        pass

    @property
    def is_ready(self) -> bool:
        """Check if the provider is ready to handle requests."""
        return True

šŸ“¦ Project Structure

llm-mcp/
ā”œā”€ā”€ src/
│   └── llm_mcp/
│       ā”œā”€ā”€ api/              # API endpoints
│       │   └── v1/           # API version 1
│       │       ā”œā”€ā”€ endpoints/ # Endpoint implementations
│       │       ā”œā”€ā”€ models.py  # Request/response models
│       │       └── router.py  # API router
│       │
│       ā”œā”€ā”€ core/             # Core application logic
│       │   ā”œā”€ā”€ config.py     # Configuration management
│       │   └── startup.py    # Application startup and tool registration
│       │
│       ā”œā”€ā”€ models/           # Data models
│       │   └── base.py       # Base model classes
│       │
│       ā”œā”€ā”€ services/         # Business logic
│       │   ā”œā”€ā”€ providers/    # LLM provider implementations
│       │   │   ā”œā”€ā”€ base.py   # Base provider interface
│       │   │   ā”œā”€ā”€ ollama/   # Ollama provider
│       │   │   └── ...       # Other providers
│       │   └── model_manager.py # Model management service
│       │
│       ā”œā”€ā”€ utils/            # Utility functions
│       ā”œā”€ā”€ __init__.py
│       └── main.py           # Application entry point
│
ā”œā”€ā”€ tests/                    # Test suite
│   └── ...
│
ā”œā”€ā”€ tools/                    # Utility scripts
│   ā”œā”€ā”€ chat_terminal.py      # Interactive chat terminal
│   ā”œā”€ā”€ dxt_generator.py      # DXT manifest generator
│   └── ...
│
ā”œā”€ā”€ .env.example             # Example environment variables
ā”œā”€ā”€ pyproject.toml           # Project metadata and dependencies
ā”œā”€ā”€ manifest.json            # DXT manifest
└── README.md                # This file

šŸ“ License

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

šŸ¤ Contributing

Contributions are welcome! Please read our for details on our code of conduct and the process for submitting pull requests.

šŸ“š Resources

šŸ“¬ Contact

For issues and feature requests, please use the GitHub Issues page.

šŸ¤ Contributing

Contributions are welcome! Please read our for details on our code of conduct and the process for submitting pull requests.

Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Testing

Run the test suite:

pytest tests/

Code Style

This project uses black for code formatting and flake8 for linting.

# Format code
black .

# Check code style
flake8

šŸ“ License

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


Project Link: https://github.com/yourusername/llm-mcp

Usage

Starting the server

uvicorn llm_mcp.main:app --reload

API Documentation

Once the server is running, you can access the interactive API documentation at:

Project Structure

llm-mcp/
ā”œā”€ā”€ src/
│   └── llm_mcp/
│       ā”œā”€ā”€ api/
│       │   └── v1/              # API version 1 endpoints
│       ā”œā”€ā”€ core/                # Core application logic
│       ā”œā”€ā”€ models/              # Pydantic models
│       ā”œā”€ā”€ services/
│       │   └── providers/       # LLM provider implementations
│       ā”œā”€ā”€ utils/               # Utility functions
│       ā”œā”€ā”€ __init__.py
│       └── main.py              # Application entry point
ā”œā”€ā”€ tests/                      # Test files
ā”œā”€ā”€ .env.example               # Example environment variables
ā”œā”€ā”€ pyproject.toml             # Project metadata and dependencies
└── README.md                  # This file

Development

Running Tests

pytest

Code Formatting

black .
isort .

Type Checking

mypy .

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.