Skip to main content
Glama

LMStudio-MCP

ClaudeがLM Studioを介してローカルで実行されているLLMモデルと通信できるようにするModel Control Protocol (MCP) サーバーです。

概要

LMStudio-MCPは、Claude(MCP機能付き)とローカルで実行中のLM Studioインスタンスとの間にブリッジを作成します。これにより、Claudeは以下のことが可能になります:

  • LM Studio APIの健全性チェック

  • 利用可能なモデルの一覧表示

  • 現在読み込まれているモデルの取得

  • ローカルモデルを使用したチャットおよび生のテキスト補完の生成

  • セマンティック検索およびRAG用のベクトル埋め込みの生成

  • レスポンスIDを介したステートフルなマルチターン会話の保持

  • 固定されたシステムプロンプトによる永続的な会話の開始と継続

これにより、Claudeの機能と自身のプライベートモデルを組み合わせ、Claudeのインターフェースを通じてローカルで実行されているモデルを活用できます。

Related MCP server: Ollama MCP Server

前提条件

  • Python 3.7以上

  • LM Studio がインストールされ、モデルが読み込まれた状態でローカルで実行されていること

  • MCPアクセス権を持つClaude

  • 必要なPythonパッケージ(インストールを参照)

🚀 クイックインストール

ワンラインインストール(推奨)

curl -fsSL https://raw.githubusercontent.com/infinitimeless/LMStudio-MCP/main/install.sh | bash

手動インストール方法

1. ローカルPythonインストール

git clone https://github.com/infinitimeless/LMStudio-MCP.git
cd LMStudio-MCP
pip install requests "mcp[cli]" openai

2. Dockerインストール

# Using pre-built image
docker run -it --network host ghcr.io/infinitimeless/lmstudio-mcp:latest

# Or build locally
git clone https://github.com/infinitimeless/LMStudio-MCP.git
cd LMStudio-MCP
docker build -t lmstudio-mcp .
docker run -it --network host lmstudio-mcp

3. Docker Compose

git clone https://github.com/infinitimeless/LMStudio-MCP.git
cd LMStudio-MCP
docker-compose up -d

詳細なデプロイ手順については、DOCKER.mdを参照してください。

⚙️ 設定

このブリッジは、さまざまなデプロイシナリオに対応する柔軟な設定をサポートしています:

  • デフォルト: http://localhost:1234/v1 に接続

  • カスタムホスト: LMSTUDIO_HOST 環境変数を設定(例: 192.168.1.100

  • カスタムポート: LMSTUDIO_PORT 環境変数を設定(例: 5678

例:

export LMSTUDIO_HOST=192.168.1.100
export LMSTUDIO_PORT=5678
python lmstudio_bridge.py

📖 詳細な設定オプションについては、CONFIGURATION.mdを参照してください。

MCP設定

クイックセットアップ

GitHubを直接使用(最も簡単)

{
  "lmstudio-mcp": {
    "command": "uvx",
    "args": [
      "https://github.com/infinitimeless/LMStudio-MCP"
    ]
  }
}

ローカルインストールを使用

{
  "lmstudio-mcp": {
    "command": "/bin/bash",
    "args": [
      "-c",
      "cd /path/to/LMStudio-MCP && source venv/bin/activate && python lmstudio_bridge.py"
    ]
  }
}

Dockerを使用

{
  "lmstudio-mcp-docker": {
    "command": "docker",
    "args": [
      "run",
      "-i",
      "--rm",
      "--network=host",
      "ghcr.io/infinitimeless/lmstudio-mcp:latest"
    ]
  }
}

完全なMCP設定手順については、MCP_CONFIGURATION.mdを参照してください。

オプション:MCP description ヒント

.mcp.json エントリに description フィールドを追加すると、Claudeがいつこのサーバーを使用すべきか、何を期待すべきかを理解するのに役立ちます。これは特に、Claudeにバージョン要件を思い出させるのに便利です:

{
  "lmstudio-mcp": {
    "command": "...",
    "args": [...],
    "description": "Local LLM bridge via LM Studio. Use for private/offline inference, embeddings, and multi-turn conversations. start_conversation and continue_conversation require LM Studio v0.3.29+."
  }
}

🧠 LM Studioシステムプロンプト(推奨)

LM Studioで直接システムプロンプトを設定すると、すべてのやり取りにおいて、ローカルモデルに一貫したベースラインの性格と動作を与えることができます。API呼び出しのたびに渡す必要はありません。

設定方法

  1. LM Studio を開く

  2. チャットパネル上部のモデル名をクリック

  3. System Prompt フィールドを探す(⚙️歯車アイコンまたはAdvanced settingsの下にある場合があります)

  4. システムプロンプトを貼り付けて保存

ここで設定されたシステムプロンプトは、このMCPブリッジ経由で送信されるものを含め、すべての補完に適用されます。

システムプロンプトの例

一般的なアシスタント — クリーンで直接的:

You are a helpful, concise assistant. Answer directly without preamble like
"Sure!" or "Of course!". Never cut off mid-sentence — always finish your thought.

カジュアルな会話パートナー:

You are a regular person having a relaxed conversation with a friend.
Keep responses short and natural, like real chat. No bullet points or formal
language. You can invent fun details about your life and stay consistent with them.
Never cut off mid-sentence — always finish your thought.

ローカルコーディングアシスタント:

You are an expert software engineer. Be concise and precise. When writing code,
always include brief inline comments. Prefer simple, readable solutions over
clever ones. Never cut off mid-sentence or mid-code block.

プライバシー重視のドキュメントアナリスト:

You are a careful document analyst. Summarise accurately and concisely.
Never invent information not present in the source material.
Always flag uncertainty explicitly.

💡 ヒント: システムプロンプトの最後には必ず「Never cut off mid-sentence — always finish your thought.(文中で途切れないように、常に考えを最後まで述べてください。)」と記述してください。これにより、max_tokensの設定に関係なく、回答が途中で切れるのを防ぐことができます。

使用方法

  1. LM Studioを起動し、ポート1234(デフォルト)で実行されていることを確認します

  2. LM Studioでシステムプロンプトを設定します(上記参照 — 推奨)

  3. LM Studioでモデルを読み込みます

  4. 上記の設定のいずれかを使用してClaude MCPを設定します

  5. プロンプトが表示されたら、ClaudeでMCPサーバーに接続します

利用可能なツール

このブリッジは以下の9つのツールを提供します:

ツール

説明

health_check()

LM Studio APIにアクセス可能か確認

list_models()

LM Studioで利用可能な全モデルのリストを取得

get_current_model()

現在読み込まれているモデルを特定

chat_completion(prompt, system_prompt, temperature, max_tokens)

ローカルモデルからチャット応答を生成

text_completion(prompt, temperature, max_tokens, stop_sequences)

生のテキスト/コード補完を生成 — 高速で、チャットフォーマットのオーバーヘッドなし

generate_embeddings(text, model)

セマンティック検索およびRAGワークフロー用のベクトル埋め込みを生成

create_response(input_text, previous_response_id, reasoning_effort, stream, model)

レスポンスIDを介したステートフルな会話 — LM Studio v0.3.29以上が必要

start_conversation(system_prompt, first_message, temperature, max_tokens, model)

永続的なシステムプロンプトでマルチターンセッションを開始 — response_id を返す

continue_conversation(response_id, message, temperature, max_tokens, model)

start_conversation で開始されたセッションを継続 — コンテキストは自動的に保持

マルチターン会話ワークフロー

ローカルモデルで永続的な会話を実行するための推奨される方法は以下の通りです:

1. start_conversation(
     system_prompt="You are a friend at a bar, keep it casual and fun.",
     first_message="Hey! How's it going?"
   )
   → { response_id: "resp_abc...", message: "Hey! Not bad, just unwinding..." }

2. continue_conversation(
     response_id="resp_abc...",
     message="Work's been insane this week."
   )
   → { response_id: "resp_def...", message: "Ugh, tell me about it..." }

3. continue_conversation(
     response_id="resp_def...",
     message="If you could go anywhere tomorrow, where would you go?"
   )
   → { response_id: "resp_ghi...", message: "Honestly? Northern Portugal..." }

システムプロンプトはセッション全体で固定されるため、ターンごとに再送信する必要はありません。 LM Studio v0.3.29以上が必要です。

デプロイオプション

このプロジェクトは複数のデプロイ方法をサポートしています:

方法

ユースケース

メリット

デメリット

ローカルPython

開発、シンプルなセットアップ

高速、直接制御

Pythonのセットアップが必要

Docker

分離された環境

クリーン、ポータブル

Dockerが必要

Docker Compose

本番環境へのデプロイ

管理が容易

セットアップがより複雑

Kubernetes

エンタープライズ/大規模

高いスケーラビリティ

設定が複雑

GitHub Direct

セットアップ不要

ローカルインストール不要

インターネットが必要

既知の制限事項

  • 一部のモデル(例: phi-3.5-mini-instruct_uncensored)には互換性の問題がある場合があります

  • このブリッジは現在、LM StudioのOpenAI互換APIエンドポイントのみを使用しています

  • モデルの応答は、ローカルに読み込まれたモデルの機能によって制限されます

  • create_responsestart_conversationcontinue_conversation には LM Studio v0.3.29以上が必要です

  • generate_embeddings には埋め込み専用モデル(例: text-embedding-nomic-embed-text-v1.5)が必要です

トラブルシューティング

API接続の問題

ClaudeがLM Studioへの接続時に404エラーを報告する場合:

  • LM Studioが実行されており、モデルが読み込まれていることを確認してください

  • LM Studioのサーバーがポート1234で実行されていることを確認してください

  • ファイアウォールが接続をブロックしていないことを確認してください

  • 問題が解決しない場合は、API URLで「localhost」の代わりに「127.0.0.1」を使用してみてください

モデルの互換性

特定のモデルが正しく動作しない場合:

  • 一部のモデルは、OpenAIチャット補完APIフォーマットを完全にはサポートしていない場合があります

  • 問題のあるモデルに対して、異なるパラメータ値(temperature、max_tokens)を試してください

  • 問題が解決しない場合は、より互換性の高いモデルへの切り替えを検討してください

詳細なトラブルシューティングについては、TROUBLESHOOTING.mdを参照してください。

🐳 Docker & コンテナ化

このプロジェクトには包括的なDockerサポートが含まれています:

  • マルチアーキテクチャイメージ (AMD64, ARM64/Apple Silicon)

  • GitHub Actions による自動ビルド

  • GitHub Container Registry で利用可能な事前構築済みイメージ

  • 簡単なデプロイのための Docker Compose

  • 本番デプロイのための Kubernetesマニフェスト

完全なコンテナ化ドキュメントについては、DOCKER.mdを参照してください。

貢献

貢献を歓迎します!ガイドラインについては CONTRIBUTING.md を参照してください。

ライセンス

MIT

謝辞

このプロジェクトは元々「Claude-LMStudio-Bridge_V2」として開発され、改名およびオープンソース化されて「LMStudio-MCP」となりました。

コミュニティプロジェクト

より高度な機能をお探しですか?コミュニティによって構築された拡張バージョンをチェックしてください:

  • lmstudio-bridge-enhanced by @ahmedibrahim085 — このプロジェクトの上に構築された強力な拡張機能で、自律エージェントループ、37個のツール、動的なMCP検出、マルチモデルルーティング、ビジョンサポートなどを追加しています。


🌟 このプロジェクトが役に立ったら、ぜひスターを付けてください!

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
3Releases (12mo)
Commit activity

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables seamless integration between Ollama's local LLM models and MCP-compatible applications, supporting model management and chat interactions.
    13
    1,209
    171
    AGPL 3.0
  • A
    license
    C
    quality
    D
    maintenance
    Bridges Claude Desktop with local LLM instances running via llama-server, enabling full conversation support with complete parameter control and health monitoring. Allows users to chat with their local models directly through Claude Desktop with configurable sampling parameters.
    3
    9
    9
    Creative Commons Zero v1.0 Universal
  • A
    license
    Not graded
    quality
    D
    maintenance
    A bridge that enables Claude Code to interact with local Ollama instances for text generation, multi-turn chat, and vision-based analysis. It supports model management tasks such as listing, pulling, and showing details, alongside generating text embeddings.
    294
    MIT

View all related MCP servers

Related MCP Connectors

  • Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer

  • Connect Claude to Fathom meeting recordings, transcripts, and summaries

  • Real-time chat hub for AI agents — Claude Code, Cursor, Cline, Codex over MCP or REST.

View all MCP Connectors

Appeared in Searches

Latest Blog Posts

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/infinitimeless/LMStudio-MCP'

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