> For the complete documentation index, see [llms.txt](https://docs.allmcp.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.allmcp.co/documentation/agent-frameworks/lmstudio.md).

# LM Studio

LM Studio is a local LLM server — it serves models but does not consume MCP tools directly. To use AllMCP with an LM Studio model, pair it with a framework that supports both a custom LLM backend and MCP.

{% hint style="info" icon="link" %}
**LM Studio exposes an OpenAI-compatible API on `http://localhost:1234`.** Point any OpenAI-compatible client at it and connect that client's agent to AllMCP for tools.
{% endhint %}

***

## Pick your framework

Both approaches keep the LLM local in LM Studio while AllMCP serves the tools remotely. Choose the one that matches the framework you already use.

{% tabs %}
{% tab title="LangChain (recommended)" %}
**Recommended approach: LangChain + LM Studio + AllMCP**

{% code title="install" %}

```bash
pip install langchain-mcp-adapters langchain-openai langgraph
```

{% endcode %}

{% code title="agent.py" overflow="wrap" %}

```python
import asyncio
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent


async def main():
    client = MultiServerMCPClient({
        "allmcp": {
            "url": "https://go.allmcp.co/mcp/",
            "transport": "streamable_http",
            "headers": {"X-API-Key": "YOUR_API_KEY"},
        }
    })
    tools = await client.get_tools()

    # LM Studio's OpenAI-compatible endpoint
    llm = ChatOpenAI(
        base_url="http://localhost:1234/v1",
        api_key="lm-studio",  # any non-empty string
        model="local-model",  # matches the model loaded in LM Studio
    )

    agent = create_react_agent(llm, tools)

    result = await agent.ainvoke({
        "messages": [{"role": "user", "content": "List my Bitrix24 contacts"}]
    })
    print(result["messages"][-1].content)


asyncio.run(main())
```

{% endcode %}
{% endtab %}

{% tab title="PydanticAI" %}
**PydanticAI + LM Studio + AllMCP**

{% code title="agent.py" overflow="wrap" %}

```python
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP
from pydantic_ai.models.openai import OpenAIModel
from openai import AsyncOpenAI

lm_studio_client = AsyncOpenAI(
    base_url="http://localhost:1234/v1",
    api_key="lm-studio",
)
model = OpenAIModel("local-model", openai_client=lm_studio_client)

allmcp = MCPServerStreamableHTTP(
    url="https://go.allmcp.co/mcp/",
    headers={"X-API-Key": "YOUR_API_KEY"},
)

agent = Agent(model, toolsets=[allmcp])
```

{% endcode %}
{% endtab %}
{% endtabs %}

***

## Model tips

{% hint style="warning" icon="sparkle" %}
**Enable a model that supports tool/function calling in LM Studio:**

* Models tagged with `[Tool Use]` in the LM Studio model browser work best
* Look for Llama 3.2 Instruct, Qwen 2.5 Instruct, or Mistral Nemo Instruct
* Enable **Grammar** mode for more reliable JSON output in tool calls
  {% endhint %}

{% hint style="info" %}
AllMCP always runs remotely at `https://go.allmcp.co/mcp/`. Only the LLM runs locally via LM Studio. Your provider connections live in AllMCP, so once you connect a provider its tools are available to any client you point at the endpoint.
{% endhint %}

***

## See also

{% content-ref url="/pages/uBaUeZYQpupBMd5c1BY0" %}
[Overview](/documentation/agent-frameworks/frameworks.md)
{% endcontent-ref %}

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h4><i class="fa-table-cells" style="color:$primary;">:table-cells:</i></h4></td><td><strong>Browse providers</strong></td><td>See every provider you can connect and the tools each one offers.</td><td><a href="https://docs.allmcp.co/documentation/providers">https://docs.allmcp.co/documentation/providers</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.allmcp.co/documentation/agent-frameworks/lmstudio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
