KoboldCPP MCP Server

Local 2025-08-31 23:48:29 0

A server enabling integration between KoboldAI's text generation capabilities and MCP-compatible applications, with features like chat completion, Stable Diffusion, and OpenAI-compatible API endpoints.


A Model Context Protocol (MCP) server implementation for interfacing with KoboldAI. This server enables integration between KoboldAI's text generation capabilities and MCP-compatible applications.

Features

  • Text generation with KoboldAI
  • Chat completion with persistent memory
  • OpenAI-compatible API endpoints
  • Stable Diffusion integration
  • Built on the official MCP SDK
  • TypeScript implementation

Kobold Server MCP server

Installation

npm install kobold-mcp-server

Prerequisites

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

Usage

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

// Initialize the server
const server = new KoboldMCPServer();

// Start the server
server.start();

Configuration

The server can be configured through environment variables or a configuration object:

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

Supported APIs

  • Core KoboldAI API (text generation, model info)
  • Chat completion with conversation memory
  • Text completion (OpenAI-compatible)
  • Stable Diffusion integration (txt2img, img2img)
  • Audio transcription and text-to-speech
  • Web search capabilities

Development

  1. Clone the repository:

    git clone https://github.com/yourusername/kobold-mcp-server.git
    cd kobold-mcp-server

  2. Install dependencies:

    npm install

  3. Build the project:

    npm run build

Dependencies

  • @modelcontextprotocol/sdk: ^1.0.1
  • node-fetch: ^2.6.1
  • zod: ^3.20.0
  • zod-to-json-schema: ^3.23.5

Contributing

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

License

MIT License - see LICENSE file for details.

Support

For issues and feature requests, please use the GitHub issue tracker.

[
  {
    "description": "Get current max context length setting",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_max_context_length"
  },
  {
    "description": "Get current max length setting",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_max_length"
  },
  {
    "description": "Generate text with KoboldAI",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "max_context_length": {
          "type": "number"
        },
        "max_length": {
          "type": "number"
        },
        "prompt": {
          "type": "string"
        },
        "repetition_penalty": {
          "type": "number"
        },
        "seed": {
          "type": "number"
        },
        "stop_sequence": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "temperature": {
          "type": "number"
        },
        "top_k": {
          "type": "number"
        },
        "top_p": {
          "type": "number"
        }
      },
      "required": [
        "prompt"
      ],
      "type": "object"
    },
    "name": "kobold_generate"
  },
  {
    "description": "Get current model information",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_model_info"
  },
  {
    "description": "Get KoboldAI version information",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_version"
  },
  {
    "description": "Get performance information",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_perf_info"
  },
  {
    "description": "Count tokens in text",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "text": {
          "type": "string"
        }
      },
      "required": [
        "text"
      ],
      "type": "object"
    },
    "name": "kobold_token_count"
  },
  {
    "description": "Convert token IDs to text",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "tokens": {
          "items": {
            "type": "number"
          },
          "type": "array"
        }
      },
      "required": [
        "tokens"
      ],
      "type": "object"
    },
    "name": "kobold_detokenize"
  },
  {
    "description": "Transcribe audio using Whisper",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "audio": {
          "type": "string"
        },
        "language": {
          "type": "string"
        }
      },
      "required": [
        "audio"
      ],
      "type": "object"
    },
    "name": "kobold_transcribe"
  },
  {
    "description": "Search the web via DuckDuckGo",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "query": {
          "type": "string"
        }
      },
      "required": [
        "query"
      ],
      "type": "object"
    },
    "name": "kobold_web_search"
  },
  {
    "description": "Generate text-to-speech audio",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "speed": {
          "type": "number"
        },
        "text": {
          "type": "string"
        },
        "voice": {
          "type": "string"
        }
      },
      "required": [
        "text"
      ],
      "type": "object"
    },
    "name": "kobold_tts"
  },
  {
    "description": "Abort the currently ongoing generation",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_abort"
  },
  {
    "description": "Get token logprobs from the last request",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_last_logprobs"
  },
  {
    "description": "List available Stable Diffusion models",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_sd_models"
  },
  {
    "description": "List available Stable Diffusion samplers",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        }
      },
      "type": "object"
    },
    "name": "kobold_sd_samplers"
  },
  {
    "description": "Generate image from text prompt",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "cfg_scale": {
          "type": "number"
        },
        "height": {
          "type": "number"
        },
        "negative_prompt": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "sampler_name": {
          "type": "string"
        },
        "seed": {
          "type": "number"
        },
        "steps": {
          "type": "number"
        },
        "width": {
          "type": "number"
        }
      },
      "required": [
        "prompt"
      ],
      "type": "object"
    },
    "name": "kobold_txt2img"
  },
  {
    "description": "Transform existing image using prompt",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "cfg_scale": {
          "type": "number"
        },
        "denoising_strength": {
          "type": "number"
        },
        "height": {
          "type": "number"
        },
        "init_images": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "negative_prompt": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "sampler_name": {
          "type": "string"
        },
        "seed": {
          "type": "number"
        },
        "steps": {
          "type": "number"
        },
        "width": {
          "type": "number"
        }
      },
      "required": [
        "prompt",
        "init_images"
      ],
      "type": "object"
    },
    "name": "kobold_img2img"
  },
  {
    "description": "Generate caption for image",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "image": {
          "type": "string"
        }
      },
      "required": [
        "image"
      ],
      "type": "object"
    },
    "name": "kobold_interrogate"
  },
  {
    "description": "Chat completion (OpenAI-compatible)",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "max_tokens": {
          "type": "number"
        },
        "messages": {
          "items": {
            "additionalProperties": false,
            "properties": {
              "content": {
                "type": "string"
              },
              "role": {
                "enum": [
                  "system",
                  "user",
                  "assistant"
                ],
                "type": "string"
              }
            },
            "required": [
              "role",
              "content"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "stop": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "temperature": {
          "type": "number"
        },
        "top_p": {
          "type": "number"
        }
      },
      "required": [
        "messages"
      ],
      "type": "object"
    },
    "name": "kobold_chat"
  },
  {
    "description": "Text completion (OpenAI-compatible)",
    "inputSchema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "additionalProperties": false,
      "properties": {
        "apiUrl": {
          "default": "http://localhost:5001",
          "type": "string"
        },
        "max_tokens": {
          "type": "number"
        },
        "prompt": {
          "type": "string"
        },
        "stop": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "temperature": {
          "type": "number"
        },
        "top_p": {
          "type": "number"
        }
      },
      "required": [
        "prompt"
      ],
      "type": "object"
    },
    "name": "kobold_complete"
  }
]