KoboldAI MCP server

Integrates KoboldAI's text generation, enabling local language model interactions for creative writing, chatbots, and content generation.
Back to servers
Provider
PhialsBasement
Release date
Jan 25, 2025
Language
TypeScript
Package
Stats
111 downloads
4 stars

This MCP (Model Context Protocol) server implementation enables integration between KoboldAI's text generation capabilities and MCP-compatible applications, featuring chat completion with memory persistence, OpenAI-compatible API endpoints, and Stable Diffusion integration.

Installation

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn package manager
  • Running KoboldAI instance

Setup

Install the package using npm:

npm install kobold-mcp-server

Configuration

The server can be configured using environment variables or by passing a configuration object when initializing:

import { KoboldMCPServer } from 'kobold-mcp-server';

// Basic initialization with defaults
const server = new KoboldMCPServer();

// Or with custom configuration
const config = {
  apiUrl: 'http://localhost:5001' // KoboldAI API endpoint
};
const server = new KoboldMCPServer(config);

Starting the Server

After configuring, start the server:

// Initialize and start the server
server.start();

Supported Features

Core Functionality

  • Text generation via KoboldAI
  • Chat completion with persistent conversation memory
  • OpenAI-compatible API endpoints

Additional Capabilities

  • Stable Diffusion integration (txt2img, img2img)
  • Audio transcription and text-to-speech
  • Web search functionality

API Usage Examples

Basic Text Generation

import { KoboldMCPServer } from 'kobold-mcp-server';

const server = new KoboldMCPServer({
  apiUrl: 'http://localhost:5001'
});

server.start();

Chat Completion

The server supports chat completion with memory persistence, allowing for contextual conversations:

// Client-side example of using the chat completion API
const response = await fetch('http://your-server-address/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    messages: [
      { role: 'user', content: 'Hello, how are you?' }
    ],
    model: 'your-kobold-model'
  })
});

const result = await response.json();

Stable Diffusion Integration

The server also provides endpoints for image generation capabilities:

// Example of text-to-image request
const response = await fetch('http://your-server-address/v1/images/generations', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    prompt: 'A beautiful sunset over mountains',
    n: 1,
    size: '512x512'
  })
});

const images = await response.json();

Advanced Configuration

For production deployments, you may want to configure additional parameters:

const config = {
  apiUrl: 'http://your-kobold-instance:5001',
  port: 3000,              // Port to run the MCP server on
  host: '0.0.0.0',         // Host to bind to
  enableLogging: true,     // Enable detailed logging
  maxContextLength: 2048   // Maximum context length for generation
};

const server = new KoboldMCPServer(config);
server.start();

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later