MCP ExplorerExplorer

Lmstudio Mcp

@keyboardsmokeon a year ago
1 MIT
FreeCommunity
AI Systems
#ai#claude#lmstudio#mcp
Allow Claude to access your local lmstudio instance for additional problem solving ability :))

Overview

What is Lmstudio Mcp

lmstudio-mcp is a FastMCP server that provides an interface to interact with LMStudio’s local language models, allowing users to query and interact with models through a simple API.

Use cases

Use cases for lmstudio-mcp include querying language models for information, generating text based on prompts, and enhancing problem-solving capabilities in applications that utilize LMStudio’s models.

How to use

To use lmstudio-mcp, ensure that Python 3.x, LMStudio, and the required packages are installed. Start the server by running ‘python lmstudio_api.py’. You can then use the provided API endpoints to get available models and query specific models with prompts.

Key features

Key features of lmstudio-mcp include the ability to list all loaded models in LMStudio, send prompts to specific models with custom system prompts, and a simple API interface for model interactions.

Where to use

lmstudio-mcp can be used in various fields that require natural language processing, such as chatbots, virtual assistants, and any application that benefits from language model interactions.

Content

LMStudio API MCP Server

This is a FastMCP server that provides an interface to interact with LMStudio’s local language models. It allows you to query and interact with models loaded in LMStudio through a simple API.

Features

  • List all loaded models in LMStudio
  • Send prompts to specific models with custom system prompts
  • Simple API interface for model interactions

Prerequisites

  • Python 3.x
  • LMStudio installed and running
  • FastMCP package installed
  • LMStudio Python package installed

Usage

The server provides two main endpoints:

1. Get Available Models

get_lmstudio_models() -> list[str]

Returns a list of all models currently loaded in LMStudio. Each model entry contains information about the model including its display name, which is used to identify the model in subsequent API calls.

2. Query a Model

ask_lmstudio_model(model: str, system_prompt: str, prompt: str) -> str

Sends a prompt to a specific model with a custom system prompt.

Parameters:

  • model: The display name of the model to use
  • system_prompt: The system prompt to set the context
  • prompt: The actual prompt to send to the model

Example

# Get list of available models
models = get_lmstudio_models()

# Ask a question to a specific model
response = ask_lmstudio_model(
    model="Your Model Name",
    system_prompt="You are a helpful assistant.",
    prompt="What is the capital of France?"
)

Running the Server

To start the MCP server, simply run:

python lmstudio_api.py

Error Handling

The server includes basic error handling:

  • Returns “Model not found” if the specified model doesn’t exist
  • Returns “No response from model” if the model fails to generate a response

Note

Make sure LMStudio is running and the desired models are loaded before using this API.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers