---
title: "MCP servers with OpenAI-compatible models - how it works"
description: "MCP works with any LLM: the client turns MCP tools into function calls. How to use MCP with open models in Cline, Continue, opencode, n8n or your own Python code."
url: https://broadrouter.com/blog/mcp-with-openai-compatible-models/
lang: en
updated: 2026-11-14
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# Use MCP servers with OpenAI-compatible models (any provider)

By the BroadNet Inference team · 4 min read · Published 2026-11-14 · Updated 2026-11-16

MCP is model-independent. The MCP client in your app lists each server's tools, passes them to the model as ordinary function-calling tools, and runs tools/call when the model asks. Any OpenAI-compatible model with reliable tool calling can use MCP servers. Configure them in Cline, Continue, opencode or n8n, or bridge them in about 40 lines of Python.

## Key takeaways

-   MCP's docs say it "does not dictate how AI applications use LLMs". The host app translates MCP tools into the model's tool format.
-   The model needs tool calling. On BroadNet Inference, GLM 5.3 and Qwen3.8 27B list it.
-   Cline, Continue (Agent mode only), opencode, n8n and the OpenAI Agents SDK all act as MCP clients with a custom model.
-   Every MCP tool schema is sent on every model call. opencode's docs warn MCP tools consume model context; add only the servers you need.
-   Hosted MCP tools that run inside OpenAI's Responses API do not work with other providers; local MCP clients do.

**On this page**

1.  Why does MCP work with any model?
2.  Which model should you use for MCP?
3.  How do you set up MCP in common clients?
4.  How do you bridge MCP to an open model in Python?
5.  What goes wrong with MCP on open models?
6.  Where BroadNet Inference fits

The Model Context Protocol (MCP) gives agents a standard way to reach tools: GitHub, databases, file systems, browsers. Many MCP tutorials assume Claude or GPT. You don’t need either. This post explains why MCP works with any [OpenAI-compatible](https://broadrouter.com/glossary/openai-compatible-api/) model that supports tool calling, how to set it up in the clients developers actually use, and how to bridge MCP to an open model in your own code.

## Why does MCP work with any model?

MCP sits between your application and tool servers, not between your application and the model. MCP’s architecture docs describe three roles:

-   **Host:** the AI application, such as an editor extension or your script.
-   **Client:** one connection the host keeps to each MCP server.
-   **Server:** a program that exposes tools, resources and prompts, locally over stdio or remotely over Streamable HTTP.

The docs are explicit: MCP “does not dictate how AI applications use LLMs or manage the provided context.” The host lists each server’s tools with `tools/list`, merges them into one registry the model can see, and when the model asks for a tool, the host sends `tools/call` to the right server.

On an OpenAI-compatible API, “the model can see” means the tools go into the ordinary `tools` array. An MCP tool already has a name, a description and an `inputSchema`, which maps one-to-one onto a function definition. The model never knows MCP is involved. All it needs is reliable [tool calling](https://broadrouter.com/glossary/tool-calling/).

## Which model should you use for MCP?

| Model on BroadNet | Tool calling listed | Context | MCP fit |
| --- | --- | --- | --- |
| [GLM 5.3](https://broadrouter.com/models/glm-5.3/) | Yes | 1,048,576 | Good default for many servers |
| [Qwen3.8 27B](https://broadrouter.com/models/qwen3.8-27b/) | Yes | 262,144 | Good, plus image input |
| [DeepSeek V4.1 Flash](https://broadrouter.com/models/deepseek-v4.1-flash/) | Not listed | 1,048,576 | Test first; image input |
| [Gemma 4 VL 26B](https://broadrouter.com/models/gemma-4-vl-26b/) | Not listed | 32,768 | Not recommended |

For the two tool-capable models side by side, see [GLM 5.3 vs Qwen3.8 27B](https://broadrouter.com/compare/glm-5.3-vs-qwen3.8-27b/). Context matters more than people expect. Every MCP tool schema rides on every call. opencode’s docs say “MCP tools consume model context, so add only the servers you need.” The [agent token budget](https://broadrouter.com/blog/agent-token-budget/) post shows how to measure it.

## How do you set up MCP in common clients?

| Client | Where MCP servers go | Transports | Note |
| --- | --- | --- | --- |
| Cline | MCP Servers panel, `mcpServers` JSON | stdio, Streamable HTTP, legacy SSE | Remote type `"streamableHttp"` |
| Continue | `mcpServers` in `config.yaml` or `.continue/mcpServers/` | stdio, sse, streamable-http | Agent mode only |
| opencode | `mcp.servers` in `opencode.jsonc` | `local`, `remote` | Use `{env:NAME}` for secrets |
| n8n | MCP Client Tool node on an AI Agent | Remote server endpoint (its docs describe an SSE endpoint) | Pick All, Selected or All Except tools |
| OpenAI Agents SDK | `mcp_servers=[...]` on the Agent | stdio, Streamable HTTP, SSE | Not `HostedMCPTool` |

Then point the client’s model at your provider: the [Cline](https://broadrouter.com/guides/cline-openai-compatible/), [Continue](https://broadrouter.com/guides/continue-dev-openai-compatible/) and [opencode](https://broadrouter.com/guides/opencode-custom-provider/) guides cover the model side for BroadNet. In Continue, remember the `tool_use` capability, or Agent mode won’t be available.

A Continue example, from its docs:

```yaml
mcpServers:
  - name: SQLite MCP
    type: stdio
    command: npx
    args: ["-y", "mcp-sqlite", "/path/to/your/database.db"]
```

## How do you bridge MCP to an open model in Python?

If you’re building your own agent, the bridge is short. This uses the MCP Python SDK’s `Client` (version 2.0 or later; `pip install "mcp>=2"`), which launches a stdio server when given `StdioServerParameters`, and the OpenAI SDK pointed at BroadNet:

```python
import asyncio, json, os
from mcp import Client, StdioServerParameters
from mcp.types import TextContent
from openai import OpenAI

llm = OpenAI(base_url="https://inference.broadnet.ai/v1", api_key=os.environ["BROADNET_API_KEY"])
server = StdioServerParameters(command="npx",
    args=["-y", "@modelcontextprotocol/server-filesystem", "."])

async def main(question):
    async with Client(server) as mcp:
        listed = await mcp.list_tools()
        tools = [{"type": "function", "function": {
                    "name": t.name, "description": t.description or "",
                    "parameters": t.input_schema}} for t in listed.tools]
        messages = [{"role": "user", "content": question}]
        for _ in range(8):
            r = llm.chat.completions.create(model="broadnet/glm-5.3",
                    messages=messages, tools=tools, max_tokens=4000)
            msg = r.choices[0].message
            messages.append(msg.model_dump(exclude_none=True))
            if not msg.tool_calls:
                return msg.content
            for call in msg.tool_calls:
                try:
                    res = await mcp.call_tool(call.function.name,
                                              json.loads(call.function.arguments or "{}"))
                    text = "\n".join(b.text for b in res.content if isinstance(b, TextContent))
                    out = f"Error: {text}" if res.is_error else text
                except Exception as e:
                    out = f"Error: {e}"
                messages.append({"role": "tool", "tool_call_id": call.id, "content": out})

print(asyncio.run(main("List the Markdown files here and summarize the README.")))
```

On `mcp` 1.x there is no `Client` class: open the server with `stdio_client(...)`, wrap it in a `ClientSession`, call `initialize()`, and read the camelCase fields `inputSchema` and `isError`. Three details matter:

1.  **Errors become tool results.** The MCP SDK reports tool failures with `is_error` instead of raising. Pass them back so the model can adjust. Our [tool calling guide](https://broadrouter.com/blog/tool-calling-open-models/) covers validation and retries.
2.  **Bound the loop.** Eight steps here. MCP servers that return large results fill the context fast.
3.  **Filter tools.** Expose only the tools the task needs. The OpenAI Agents SDK offers `tool_filter` for this, and n8n has Selected and All Except.

Using the OpenAI Agents SDK instead? Its `MCPServerStdio` and `MCPServerStreamableHttp` classes run in your process. Combine them with a custom provider as in our [Agents SDK guide](https://broadrouter.com/guides/openai-agents-sdk-custom-provider/). Its `HostedMCPTool` runs inside OpenAI’s Responses API and only works with OpenAI models.

## What goes wrong with MCP on open models?

-   **Too many tools.** The model picks the wrong one or ignores tools. Keep the active set small. For your own tools, the [JSON schema generator](https://broadrouter.com/tools/json-schema-generator/) produces a clean, flat `parameters` schema.
-   **Large tool results.** A server that returns a whole database table can blow past the [context window](https://broadrouter.com/glossary/context-window/). Cap or paginate.
-   **Empty or cut-off replies.** GLM 5.3 and Qwen3.8 27B reason first, and reasoning counts toward `max_tokens`. [Raise it](https://broadrouter.com/guides/reasoning-tokens-empty-response/).
-   **Trust.** MCP servers run code on your machine or call services with your credentials. Install servers you trust, and confirm actions that write or spend.

## Where BroadNet Inference fits

BroadNet Inference supplies the model side: GLM 5.3 and Qwen3.8 27B with tool calling listed, through the standard chat-completions format every MCP client above can use, with zero data retention on prompts and outputs. It doesn’t run MCP servers or hosted tools for you; your client does that. Per-token prices for both models are on the [pricing page](https://broadrouter.com/pricing/), and keys are at [inference.broadnet.ai](https://inference.broadnet.ai/?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-mcp-with-openai-compatible-models&utm_content=body).

Free tools for this

-   [Agent run cost estimator](https://broadrouter.com/tools/agent-run-cost-estimator/) Context growth per step, total tokens and cost of one agent run, with a DeepSeek session comparison.
-   [LLM batch job planner](https://broadrouter.com/tools/llm-batch-job-planner/) Run time, binding limit, cost per model and the flat sessions needed to finish a big job by a deadline.
-   [Flat-rate vs per-token LLM cost calculator](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/) Break-even between an unlimited plan and paying per token, per agent.
-   [LLM rate limit and concurrency calculator](https://broadrouter.com/tools/llm-rate-limit-calculator/) Which limit binds first: RPM, TPM or concurrency, with Little's law.

[All free tools](https://broadrouter.com/tools/)

## Terms in this article

[Tool calling](https://broadrouter.com/glossary/tool-calling/)

Tool calling, also called function calling, is an LLM API feature in which the model returns a structured request to run a function the developer has defined, with JSON arguments. The application runs the function and sends the result back; the model never runs code itself.

[MCP (Model Context Protocol)](https://broadrouter.com/glossary/mcp/)

MCP (Model Context Protocol) is an open protocol, built on JSON-RPC 2.0, that standardises how LLM applications connect to external tools and data. An MCP server exposes tools, resources and prompts; an MCP client inside the host application discovers them and passes tool calls from the model to the server.

[Server-sent events (SSE)](https://broadrouter.com/glossary/sse/)

Server-sent events (SSE) is a web standard for a server to push a stream of text events to a client over one long-lived HTTP response with the content type text/event-stream. Each event is one or more field lines, such as data:, ended by a blank line.

[Open-weight model](https://broadrouter.com/glossary/open-weight-model/)

An open-weight model is a machine learning model whose trained weights are published for anyone to download and run, usually under a licence with conditions. It differs from fully open-source AI, which also releases the training code and detailed information about the training data, so others can study and reproduce the model.

[AI agent](https://broadrouter.com/glossary/agent/)

An AI agent is a system in which a language model directs its own steps toward a goal: it decides which tools to call, reads the results and repeats until it produces a final answer or hits a limit. A fixed script that calls a model at set points is usually called a workflow instead.

[Context window](https://broadrouter.com/glossary/context-window/)

A context window is the maximum number of tokens a language model can work with in a single request. It covers the prompt, conversation history, tool definitions, images and the generated output, including any reasoning tokens. Anything that does not fit must be cut, summarised or split across several requests.

[JSON Schema](https://broadrouter.com/glossary/json-schema/)

JSON Schema is a vocabulary, written in JSON, for describing and validating the structure of JSON data: types, required fields, allowed values and nesting. The current version is 2020-12. LLM APIs use it to define tool parameters and the exact shape a structured output must follow.

[OpenAI-compatible API](https://broadrouter.com/glossary/openai-compatible-api/)

An OpenAI-compatible API is an HTTP API that accepts the same request and response formats as the OpenAI API, such as POST /v1/chat/completions, so OpenAI SDKs and tools can use it by changing only the base URL, the API key and the model name.

## Questions

### Can I use MCP with a model that is not Claude or GPT?

Yes. MCP is a protocol between your app and tool servers. The app passes the tools to whatever model it uses through that model's tool-calling format. Any OpenAI-compatible model with working tool calls can use MCP tools.

### Does the model need to support MCP?

No. The model only needs function calling. The MCP client in your app does the protocol work, listing tools and calling them.

### Which coding agents support MCP with a custom OpenAI-compatible model?

Cline, Continue in Agent mode and opencode all let you configure MCP servers and a custom OpenAI-compatible model. Zoo Code, the continuation of Roo Code, also lists MCP support.

### Why does adding MCP servers make my agent slower and more expensive?

Each server's tool definitions are added to the prompt on every model call. Ten servers with a dozen tools each can add thousands of input tokens per step. Enable only the servers a task needs, or filter tools.

### Do hosted MCP tools work with other providers?

Not the OpenAI-hosted kind. The OpenAI Agents SDK docs say HostedMCPTool works with OpenAI models that support the Responses API's hosted MCP integration. Use the SDK's local MCP server classes with other providers.

## Keep reading

-   [Tool calling with open models: schemas, parallel calls, retries](https://broadrouter.com/blog/tool-calling-open-models/)
-   [Use open models in coding agents: Aider, Cline, opencode, Codex](https://broadrouter.com/blog/use-open-models-in-coding-agents/)
-   [Agent token budget: where an agent loop's tokens go](https://broadrouter.com/blog/agent-token-budget/)
-   [n8n AI Agent on a cheap LLM: setup, model choice and cost per run](https://broadrouter.com/blog/n8n-ai-agent-cheap-llm/)
-   [Claude Code with open models: proxies, native endpoints and limits](https://broadrouter.com/blog/claude-code-with-openai-compatible-models/)
-   [OpenClaw and Hermes Agent on a cheap model: setup and token math](https://broadrouter.com/blog/openclaw-hermes-agent-cheap-model/)
-   [Guide: Use Cline with BroadNet Inference (OpenAI Compatible provider)](https://broadrouter.com/guides/cline-openai-compatible/)
-   [Guide: Use Continue with BroadNet Inference (config.yaml and apiBase)](https://broadrouter.com/guides/continue-dev-openai-compatible/)
-   [Guide: Add BroadNet Inference to opencode as a custom provider](https://broadrouter.com/guides/opencode-custom-provider/)
-   [Guide: Run the OpenAI Agents SDK on BroadNet Inference](https://broadrouter.com/guides/openai-agents-sdk-custom-provider/)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-mcp-with-openai-compatible-models&utm_content=page-cta) ·

**Sources**

-   [Model Context Protocol, architecture overview (checked 2026-11-14)](https://modelcontextprotocol.io/docs/learn/architecture)
-   [MCP Python SDK, clients and transports (checked 2026-11-14)](https://py.sdk.modelcontextprotocol.io/client/transports/)
-   [Cline docs, MCP overview (checked 2026-11-14)](https://docs.cline.bot/mcp/mcp-overview)
-   [Continue docs, MCP (checked 2026-11-14)](https://docs.continue.dev/customize/deep-dives/mcp)
-   [opencode docs, MCP servers (checked 2026-11-14)](https://opencode.ai/docs/mcp-servers/)
-   [n8n docs, MCP Client Tool node (checked 2026-11-14)](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/)
-   [OpenAI Agents SDK docs, MCP (checked 2026-11-14)](https://openai.github.io/openai-agents-python/mcp/)
