openwebui-mcp 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openwebui_mcp-0.1.1/PKG-INFO +285 -0
- openwebui_mcp-0.1.1/README.md +273 -0
- openwebui_mcp-0.1.1/pyproject.toml +47 -0
- openwebui_mcp-0.1.1/setup.cfg +4 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp/__init__.py +15 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp/__main__.py +70 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp/config.py +158 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp/py.typed +0 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp/server.py +308 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp.egg-info/PKG-INFO +285 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp.egg-info/SOURCES.txt +16 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp.egg-info/dependency_links.txt +1 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp.egg-info/entry_points.txt +2 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp.egg-info/requires.txt +3 -0
- openwebui_mcp-0.1.1/src/openwebui_mcp.egg-info/top_level.txt +1 -0
- openwebui_mcp-0.1.1/tests/test_config.py +181 -0
- openwebui_mcp-0.1.1/tests/test_server.py +384 -0
- openwebui_mcp-0.1.1/tests/test_tls.py +121 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openwebui-mcp
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Open WebUI MCP server (FastMCP) - ask models with tool support, list models
|
|
5
|
+
Author: Alexey @vedmaka
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: mcp<2,>=1.20
|
|
10
|
+
Requires-Dist: openwebui-sdk>=0.1.1
|
|
11
|
+
Requires-Dist: python-dotenv>=1.0
|
|
12
|
+
|
|
13
|
+
# openwebui-mcp
|
|
14
|
+
|
|
15
|
+
Open WebUI MCP server built on [FastMCP](https://github.com/modelcontextprotocol/python-sdk)
|
|
16
|
+
and the [openwebui-sdk](https://github.com/vedmaka/openwebui-sdk) library
|
|
17
|
+
|
|
18
|
+
Lets any MCP client (Claude Desktop, Cursor, agents) ask Open WebUI models
|
|
19
|
+
through the full tool-calling loop, not just plain chat
|
|
20
|
+
|
|
21
|
+
<img width="3680" height="2592" alt="ray-so-export (1)" src="https://github.com/user-attachments/assets/01e7ed7f-35a5-413e-9b26-27ac823d7c74" />
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
OPENWEBUI_BASE_URL=http://localhost:8080 OPENWEBUI_API_KEY=sk-... \
|
|
27
|
+
uvx openwebui-mcp # stdio (default) - installs and runs from PyPI
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Connect an MCP client
|
|
31
|
+
|
|
32
|
+
**Codex CLI** (`~/.codex/config.toml`) - register the server as `owui` and let
|
|
33
|
+
it call tools without approval:
|
|
34
|
+
|
|
35
|
+
```toml
|
|
36
|
+
[mcp_servers.owui]
|
|
37
|
+
command = "uvx"
|
|
38
|
+
args = ["openwebui-mcp"]
|
|
39
|
+
env = {
|
|
40
|
+
OPENWEBUI_BASE_URL = "http://localhost:8080",
|
|
41
|
+
OPENWEBUI_API_KEY = "sk-..."
|
|
42
|
+
}
|
|
43
|
+
default_tools_approval_mode = "auto"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"openwebui": {
|
|
52
|
+
"command": "uvx",
|
|
53
|
+
"args": ["openwebui-mcp"],
|
|
54
|
+
"env": {
|
|
55
|
+
"OPENWEBUI_BASE_URL": "http://localhost:8080",
|
|
56
|
+
"OPENWEBUI_API_KEY": "sk-..."
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The quick start uses stdio, so each client spawns the server locally. For
|
|
64
|
+
remote HTTP transports, open the collapsible options below (or see Run)
|
|
65
|
+
|
|
66
|
+
<details>
|
|
67
|
+
<summary>SSE setup (Claude Desktop and other SSE-capable clients)</summary>
|
|
68
|
+
|
|
69
|
+
Run the server:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
uvx openwebui-mcp --transport sse --host 0.0.0.0 --port 8000
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Claude Desktop** (`claude_desktop_config.json`) - SSE endpoint is `http://<host>:8000/sse`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"openwebui": {
|
|
81
|
+
"type": "sse",
|
|
82
|
+
"url": "http://<host>:8000/sse"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
</details>
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary>Streamable HTTP setup (Codex CLI, rmcp, agents over HTTP)</summary>
|
|
92
|
+
|
|
93
|
+
Run the server:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
uvx openwebui-mcp --transport streamable-http --host 0.0.0.0 --port 8000
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Codex CLI** (`~/.codex/config.toml`) - streamable-http endpoint is `http://<host>:8000/mcp`:
|
|
100
|
+
|
|
101
|
+
```toml
|
|
102
|
+
[mcp_servers.owui]
|
|
103
|
+
url = "http://<host>:8000/mcp"
|
|
104
|
+
default_tools_approval_mode = "auto"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
A bare `http://<host>:8000` returns 404 on initialize; point the client URL at
|
|
108
|
+
the full `/mcp` path. rmcp and other streamable-http clients use the same URL
|
|
109
|
+
|
|
110
|
+
</details>
|
|
111
|
+
|
|
112
|
+
## Proactive ask skill
|
|
113
|
+
|
|
114
|
+
The repo ships a skill that makes an agent consult the `ask` tool eagerly
|
|
115
|
+
instead of only when it happens to choose to:
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
skills/owui-proactive-ask/SKILL.md
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
It instructs the agent to call `mcp__owui__ask` before answering **every**
|
|
122
|
+
explicit or implicit question (advice, explanations, recommendations,
|
|
123
|
+
troubleshooting, follow-ups), pass relevant conversation context via
|
|
124
|
+
`history`, keep remote tools enabled (`use_tools: true`), and validate the OWUI
|
|
125
|
+
answer against local evidence before replying. It also covers failure handling
|
|
126
|
+
(retry, fall back, say it failed - never fake an OWUI result).
|
|
127
|
+
|
|
128
|
+
Install it with the agent skills CLI (`npx skills`) or manually:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# global install for Codex
|
|
132
|
+
npx skills add ./skills/owui-proactive-ask -g -a codex -y
|
|
133
|
+
|
|
134
|
+
# global install for Claude Code
|
|
135
|
+
npx skills add ./skills/owui-proactive-ask -g -a claude-code -y
|
|
136
|
+
|
|
137
|
+
# or copy the folder into your agent's skills directory
|
|
138
|
+
cp -r skills/owui-proactive-ask ~/.agents/skills/
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The skill references the tool as `mcp__owui__ask`, so register the MCP server
|
|
142
|
+
under the name `owui` (Codex-style clients name MCP tools
|
|
143
|
+
`mcp__<server>__<tool>`, see `[mcp_servers.owui]` in Quick start above).
|
|
144
|
+
|
|
145
|
+
The skill pairs with `OPENWEBUI_ASK_DESCRIPTION` and `OPENWEBUI_INSTRUCTIONS`
|
|
146
|
+
(see Configure): the skill makes the agent call `ask`, while the description
|
|
147
|
+
and instructions tell the model why and when.
|
|
148
|
+
|
|
149
|
+
## Tools
|
|
150
|
+
|
|
151
|
+
Exactly two tools are exposed
|
|
152
|
+
|
|
153
|
+
### `ask`
|
|
154
|
+
|
|
155
|
+
Send a prompt to a model with Open WebUI tool support
|
|
156
|
+
|
|
157
|
+
- `prompt` (required) - the user message
|
|
158
|
+
- `model` (optional) - the model id to ask, e.g. one returned by `list_models`.
|
|
159
|
+
Omitted, the server uses the configured `OPENWEBUI_DEFAULT_MODEL`; if that
|
|
160
|
+
is also unset the call fails with an error
|
|
161
|
+
- `system` (optional) - a system prompt leading the conversation
|
|
162
|
+
- `temperature` (optional) - sampling temperature override
|
|
163
|
+
- `use_tools` (optional, default true) - enable the tools attached to the model
|
|
164
|
+
- `history` (optional) - prior turns `[{"role": "user"|"assistant", "content": "..."}]`
|
|
165
|
+
sent before `prompt` so the remote model keeps context from earlier questions
|
|
166
|
+
|
|
167
|
+
**Stateless**: each `ask` call is a fresh conversation on the remote model - it
|
|
168
|
+
never remembers previous calls. To carry context across questions, pass the
|
|
169
|
+
relevant earlier exchanges in `history` (e.g. your prior question and its
|
|
170
|
+
answer), or inline the context into `prompt`. Agents that keep their own
|
|
171
|
+
conversation log should replay the needed turns via `history`
|
|
172
|
+
|
|
173
|
+
To lock every call to one model regardless of what the client passes, set
|
|
174
|
+
`OPENWEBUI_ENFORCE_DEFAULT_MODEL=true` (requires `OPENWEBUI_DEFAULT_MODEL`);
|
|
175
|
+
`ask` then ignores the `model` argument entirely
|
|
176
|
+
|
|
177
|
+
To control what agents see about this tool, set `OPENWEBUI_ASK_DESCRIPTION` -
|
|
178
|
+
it replaces only the first summary line of the tool description (the text
|
|
179
|
+
agents read to decide how to call `ask`). The `IMPORTANT - this MCP server is
|
|
180
|
+
stateless` block, the argument docs and the default-model guidance are always
|
|
181
|
+
present. Unset, the built-in summary line is used
|
|
182
|
+
|
|
183
|
+
Tools attached to the model run server-side through Open WebUI's Socket.IO
|
|
184
|
+
tool loop, so answers can be produced with real tool calls. Result is a struct
|
|
185
|
+
with `answer`, `reasoning` and `tool_calls`
|
|
186
|
+
|
|
187
|
+
### `list_models`
|
|
188
|
+
|
|
189
|
+
List the models the connected Open WebUI user can see. Each entry carries the
|
|
190
|
+
model `id`, display `name` and the `tool_ids` attached to it
|
|
191
|
+
|
|
192
|
+
## Authentication
|
|
193
|
+
|
|
194
|
+
Token-based, in two layers
|
|
195
|
+
|
|
196
|
+
1. **Open WebUI access** (required). The server talks to Open WebUI as
|
|
197
|
+
`Authorization: Bearer <token>`. Provide an API key or JWT via env:
|
|
198
|
+
|
|
199
|
+
```env
|
|
200
|
+
OPENWEBUI_BASE_URL=http://localhost:8080
|
|
201
|
+
OPENWEBUI_API_KEY=sk-...
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
2. **MCP endpoint auth** (optional). Set `OPENWEBUI_MCP_TOKEN=<token>` to make
|
|
205
|
+
the MCP server itself require `Authorization: Bearer <token>` on every
|
|
206
|
+
request. Unset, the endpoint is open to its listeners
|
|
207
|
+
|
|
208
|
+
## TLS to Open WebUI
|
|
209
|
+
|
|
210
|
+
If Open WebUI is served over https with a certificate the process does not
|
|
211
|
+
trust (self-signed, private/Traefik CA, or a MITM proxy CA), the SDK raises
|
|
212
|
+
`CERTIFICATE_VERIFY_FAILED`. Fix by trusting the right CA, never by
|
|
213
|
+
silently disabling checks unless you must:
|
|
214
|
+
|
|
215
|
+
```env
|
|
216
|
+
OPENWEBUI_CA_BUNDLE=/path/to/ca.pem # trust a specific PEM CA (covers JSON routes + Socket.IO tool loop)
|
|
217
|
+
OPENWEBUI_SSL_VERIFY=false # skip verification (JSON routes only; not recommended)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The CA bundle path is applied as `SSL_CERT_FILE`, so all Python TLS callers
|
|
221
|
+
(urllib and aiohttp) pick it up. `OPENWEBUI_SSL_VERIFY=false` only relaxes the
|
|
222
|
+
urllib (JSON) routes; the Socket.IO tool loop still verifies, so prefer the CA
|
|
223
|
+
bundle for self-signed servers
|
|
224
|
+
|
|
225
|
+
## Install
|
|
226
|
+
|
|
227
|
+
Run straight from PyPI, no local checkout needed:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
uvx openwebui-mcp --help
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Or install it as a tool so the `openwebui-mcp` command is always available:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
uv tool install openwebui-mcp
|
|
237
|
+
openwebui-mcp --help
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Requires Python 3.11+
|
|
241
|
+
|
|
242
|
+
Cloning the repo is only needed for development: `uv sync` (creates
|
|
243
|
+
`.venv-docker`) then `uv run openwebui-mcp --help`
|
|
244
|
+
|
|
245
|
+
## Configure
|
|
246
|
+
|
|
247
|
+
Copy `.env.example` to `.env` or export the variables. Precedence is the first
|
|
248
|
+
defined env var in each alias list
|
|
249
|
+
|
|
250
|
+
| Setting | Env vars (first wins) | Default |
|
|
251
|
+
| --- | --- | --- |
|
|
252
|
+
| Open WebUI URL | `OPENWEBUI_BASE_URL`, `OPENWEBUI_URL`, `OWUI_URL` | required |
|
|
253
|
+
| Open WebUI token | `OPENWEBUI_API_KEY`, `OPENWEBUI_TOKEN`, `OWUI_API_KEY`, `OWUI_TOKEN` | required |
|
|
254
|
+
| Default model for `ask` | `OPENWEBUI_DEFAULT_MODEL`, `OWUI_DEFAULT_MODEL` | none |
|
|
255
|
+
| Enforce default model | `OPENWEBUI_ENFORCE_DEFAULT_MODEL`, `OWUI_ENFORCE_DEFAULT_MODEL` | `false` |
|
|
256
|
+
| `ask` tool description | `OPENWEBUI_ASK_DESCRIPTION`, `OWUI_ASK_DESCRIPTION` | built-in docstring |
|
|
257
|
+
| Server instructions | `OPENWEBUI_INSTRUCTIONS`, `OWUI_INSTRUCTIONS` | none |
|
|
258
|
+
| MCP bearer token | `OPENWEBUI_MCP_TOKEN`, `OWUI_MCP_TOKEN` | none |
|
|
259
|
+
| Transport | `OPENWEBUI_MCP_TRANSPORT` | `stdio` |
|
|
260
|
+
| Chat timeout ms | `OWUI_TIMEOUT_MS` | `120000` |
|
|
261
|
+
| Open WebUI CA bundle | `OPENWEBUI_CA_BUNDLE`, `OWUI_CA_BUNDLE` | none |
|
|
262
|
+
| Skip TLS verify | `OPENWEBUI_SSL_VERIFY`, `OWUI_SSL_VERIFY` | `true` |
|
|
263
|
+
|
|
264
|
+
## Run
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
uv run openwebui-mcp # stdio (default), for local MCP clients
|
|
268
|
+
uv run openwebui-mcp --transport sse # SSE over HTTP
|
|
269
|
+
uv run openwebui-mcp --transport streamable-http --host 0.0.0.0 --port 8000
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Development
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
uv run pytest
|
|
276
|
+
uv run pyright src tests
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Layout
|
|
280
|
+
|
|
281
|
+
- `src/openwebui_mcp/server.py` - FastMCP server, the two tools, TLS apply, static token verifier
|
|
282
|
+
- `src/openwebui_mcp/config.py` - env-driven settings
|
|
283
|
+
- `src/openwebui_mcp/__main__.py` - CLI entry point
|
|
284
|
+
- `skills/owui-proactive-ask/` - agent skill that forces proactive use of `ask`
|
|
285
|
+
- `tests/` - config + server + TLS unit tests, incl. a protocol-level `call_tool` round trip
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# openwebui-mcp
|
|
2
|
+
|
|
3
|
+
Open WebUI MCP server built on [FastMCP](https://github.com/modelcontextprotocol/python-sdk)
|
|
4
|
+
and the [openwebui-sdk](https://github.com/vedmaka/openwebui-sdk) library
|
|
5
|
+
|
|
6
|
+
Lets any MCP client (Claude Desktop, Cursor, agents) ask Open WebUI models
|
|
7
|
+
through the full tool-calling loop, not just plain chat
|
|
8
|
+
|
|
9
|
+
<img width="3680" height="2592" alt="ray-so-export (1)" src="https://github.com/user-attachments/assets/01e7ed7f-35a5-413e-9b26-27ac823d7c74" />
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
OPENWEBUI_BASE_URL=http://localhost:8080 OPENWEBUI_API_KEY=sk-... \
|
|
15
|
+
uvx openwebui-mcp # stdio (default) - installs and runs from PyPI
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Connect an MCP client
|
|
19
|
+
|
|
20
|
+
**Codex CLI** (`~/.codex/config.toml`) - register the server as `owui` and let
|
|
21
|
+
it call tools without approval:
|
|
22
|
+
|
|
23
|
+
```toml
|
|
24
|
+
[mcp_servers.owui]
|
|
25
|
+
command = "uvx"
|
|
26
|
+
args = ["openwebui-mcp"]
|
|
27
|
+
env = {
|
|
28
|
+
OPENWEBUI_BASE_URL = "http://localhost:8080",
|
|
29
|
+
OPENWEBUI_API_KEY = "sk-..."
|
|
30
|
+
}
|
|
31
|
+
default_tools_approval_mode = "auto"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"openwebui": {
|
|
40
|
+
"command": "uvx",
|
|
41
|
+
"args": ["openwebui-mcp"],
|
|
42
|
+
"env": {
|
|
43
|
+
"OPENWEBUI_BASE_URL": "http://localhost:8080",
|
|
44
|
+
"OPENWEBUI_API_KEY": "sk-..."
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The quick start uses stdio, so each client spawns the server locally. For
|
|
52
|
+
remote HTTP transports, open the collapsible options below (or see Run)
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>SSE setup (Claude Desktop and other SSE-capable clients)</summary>
|
|
56
|
+
|
|
57
|
+
Run the server:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uvx openwebui-mcp --transport sse --host 0.0.0.0 --port 8000
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Claude Desktop** (`claude_desktop_config.json`) - SSE endpoint is `http://<host>:8000/sse`:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"mcpServers": {
|
|
68
|
+
"openwebui": {
|
|
69
|
+
"type": "sse",
|
|
70
|
+
"url": "http://<host>:8000/sse"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
</details>
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary>Streamable HTTP setup (Codex CLI, rmcp, agents over HTTP)</summary>
|
|
80
|
+
|
|
81
|
+
Run the server:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
uvx openwebui-mcp --transport streamable-http --host 0.0.0.0 --port 8000
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Codex CLI** (`~/.codex/config.toml`) - streamable-http endpoint is `http://<host>:8000/mcp`:
|
|
88
|
+
|
|
89
|
+
```toml
|
|
90
|
+
[mcp_servers.owui]
|
|
91
|
+
url = "http://<host>:8000/mcp"
|
|
92
|
+
default_tools_approval_mode = "auto"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
A bare `http://<host>:8000` returns 404 on initialize; point the client URL at
|
|
96
|
+
the full `/mcp` path. rmcp and other streamable-http clients use the same URL
|
|
97
|
+
|
|
98
|
+
</details>
|
|
99
|
+
|
|
100
|
+
## Proactive ask skill
|
|
101
|
+
|
|
102
|
+
The repo ships a skill that makes an agent consult the `ask` tool eagerly
|
|
103
|
+
instead of only when it happens to choose to:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
skills/owui-proactive-ask/SKILL.md
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
It instructs the agent to call `mcp__owui__ask` before answering **every**
|
|
110
|
+
explicit or implicit question (advice, explanations, recommendations,
|
|
111
|
+
troubleshooting, follow-ups), pass relevant conversation context via
|
|
112
|
+
`history`, keep remote tools enabled (`use_tools: true`), and validate the OWUI
|
|
113
|
+
answer against local evidence before replying. It also covers failure handling
|
|
114
|
+
(retry, fall back, say it failed - never fake an OWUI result).
|
|
115
|
+
|
|
116
|
+
Install it with the agent skills CLI (`npx skills`) or manually:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# global install for Codex
|
|
120
|
+
npx skills add ./skills/owui-proactive-ask -g -a codex -y
|
|
121
|
+
|
|
122
|
+
# global install for Claude Code
|
|
123
|
+
npx skills add ./skills/owui-proactive-ask -g -a claude-code -y
|
|
124
|
+
|
|
125
|
+
# or copy the folder into your agent's skills directory
|
|
126
|
+
cp -r skills/owui-proactive-ask ~/.agents/skills/
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The skill references the tool as `mcp__owui__ask`, so register the MCP server
|
|
130
|
+
under the name `owui` (Codex-style clients name MCP tools
|
|
131
|
+
`mcp__<server>__<tool>`, see `[mcp_servers.owui]` in Quick start above).
|
|
132
|
+
|
|
133
|
+
The skill pairs with `OPENWEBUI_ASK_DESCRIPTION` and `OPENWEBUI_INSTRUCTIONS`
|
|
134
|
+
(see Configure): the skill makes the agent call `ask`, while the description
|
|
135
|
+
and instructions tell the model why and when.
|
|
136
|
+
|
|
137
|
+
## Tools
|
|
138
|
+
|
|
139
|
+
Exactly two tools are exposed
|
|
140
|
+
|
|
141
|
+
### `ask`
|
|
142
|
+
|
|
143
|
+
Send a prompt to a model with Open WebUI tool support
|
|
144
|
+
|
|
145
|
+
- `prompt` (required) - the user message
|
|
146
|
+
- `model` (optional) - the model id to ask, e.g. one returned by `list_models`.
|
|
147
|
+
Omitted, the server uses the configured `OPENWEBUI_DEFAULT_MODEL`; if that
|
|
148
|
+
is also unset the call fails with an error
|
|
149
|
+
- `system` (optional) - a system prompt leading the conversation
|
|
150
|
+
- `temperature` (optional) - sampling temperature override
|
|
151
|
+
- `use_tools` (optional, default true) - enable the tools attached to the model
|
|
152
|
+
- `history` (optional) - prior turns `[{"role": "user"|"assistant", "content": "..."}]`
|
|
153
|
+
sent before `prompt` so the remote model keeps context from earlier questions
|
|
154
|
+
|
|
155
|
+
**Stateless**: each `ask` call is a fresh conversation on the remote model - it
|
|
156
|
+
never remembers previous calls. To carry context across questions, pass the
|
|
157
|
+
relevant earlier exchanges in `history` (e.g. your prior question and its
|
|
158
|
+
answer), or inline the context into `prompt`. Agents that keep their own
|
|
159
|
+
conversation log should replay the needed turns via `history`
|
|
160
|
+
|
|
161
|
+
To lock every call to one model regardless of what the client passes, set
|
|
162
|
+
`OPENWEBUI_ENFORCE_DEFAULT_MODEL=true` (requires `OPENWEBUI_DEFAULT_MODEL`);
|
|
163
|
+
`ask` then ignores the `model` argument entirely
|
|
164
|
+
|
|
165
|
+
To control what agents see about this tool, set `OPENWEBUI_ASK_DESCRIPTION` -
|
|
166
|
+
it replaces only the first summary line of the tool description (the text
|
|
167
|
+
agents read to decide how to call `ask`). The `IMPORTANT - this MCP server is
|
|
168
|
+
stateless` block, the argument docs and the default-model guidance are always
|
|
169
|
+
present. Unset, the built-in summary line is used
|
|
170
|
+
|
|
171
|
+
Tools attached to the model run server-side through Open WebUI's Socket.IO
|
|
172
|
+
tool loop, so answers can be produced with real tool calls. Result is a struct
|
|
173
|
+
with `answer`, `reasoning` and `tool_calls`
|
|
174
|
+
|
|
175
|
+
### `list_models`
|
|
176
|
+
|
|
177
|
+
List the models the connected Open WebUI user can see. Each entry carries the
|
|
178
|
+
model `id`, display `name` and the `tool_ids` attached to it
|
|
179
|
+
|
|
180
|
+
## Authentication
|
|
181
|
+
|
|
182
|
+
Token-based, in two layers
|
|
183
|
+
|
|
184
|
+
1. **Open WebUI access** (required). The server talks to Open WebUI as
|
|
185
|
+
`Authorization: Bearer <token>`. Provide an API key or JWT via env:
|
|
186
|
+
|
|
187
|
+
```env
|
|
188
|
+
OPENWEBUI_BASE_URL=http://localhost:8080
|
|
189
|
+
OPENWEBUI_API_KEY=sk-...
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
2. **MCP endpoint auth** (optional). Set `OPENWEBUI_MCP_TOKEN=<token>` to make
|
|
193
|
+
the MCP server itself require `Authorization: Bearer <token>` on every
|
|
194
|
+
request. Unset, the endpoint is open to its listeners
|
|
195
|
+
|
|
196
|
+
## TLS to Open WebUI
|
|
197
|
+
|
|
198
|
+
If Open WebUI is served over https with a certificate the process does not
|
|
199
|
+
trust (self-signed, private/Traefik CA, or a MITM proxy CA), the SDK raises
|
|
200
|
+
`CERTIFICATE_VERIFY_FAILED`. Fix by trusting the right CA, never by
|
|
201
|
+
silently disabling checks unless you must:
|
|
202
|
+
|
|
203
|
+
```env
|
|
204
|
+
OPENWEBUI_CA_BUNDLE=/path/to/ca.pem # trust a specific PEM CA (covers JSON routes + Socket.IO tool loop)
|
|
205
|
+
OPENWEBUI_SSL_VERIFY=false # skip verification (JSON routes only; not recommended)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The CA bundle path is applied as `SSL_CERT_FILE`, so all Python TLS callers
|
|
209
|
+
(urllib and aiohttp) pick it up. `OPENWEBUI_SSL_VERIFY=false` only relaxes the
|
|
210
|
+
urllib (JSON) routes; the Socket.IO tool loop still verifies, so prefer the CA
|
|
211
|
+
bundle for self-signed servers
|
|
212
|
+
|
|
213
|
+
## Install
|
|
214
|
+
|
|
215
|
+
Run straight from PyPI, no local checkout needed:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
uvx openwebui-mcp --help
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Or install it as a tool so the `openwebui-mcp` command is always available:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
uv tool install openwebui-mcp
|
|
225
|
+
openwebui-mcp --help
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Requires Python 3.11+
|
|
229
|
+
|
|
230
|
+
Cloning the repo is only needed for development: `uv sync` (creates
|
|
231
|
+
`.venv-docker`) then `uv run openwebui-mcp --help`
|
|
232
|
+
|
|
233
|
+
## Configure
|
|
234
|
+
|
|
235
|
+
Copy `.env.example` to `.env` or export the variables. Precedence is the first
|
|
236
|
+
defined env var in each alias list
|
|
237
|
+
|
|
238
|
+
| Setting | Env vars (first wins) | Default |
|
|
239
|
+
| --- | --- | --- |
|
|
240
|
+
| Open WebUI URL | `OPENWEBUI_BASE_URL`, `OPENWEBUI_URL`, `OWUI_URL` | required |
|
|
241
|
+
| Open WebUI token | `OPENWEBUI_API_KEY`, `OPENWEBUI_TOKEN`, `OWUI_API_KEY`, `OWUI_TOKEN` | required |
|
|
242
|
+
| Default model for `ask` | `OPENWEBUI_DEFAULT_MODEL`, `OWUI_DEFAULT_MODEL` | none |
|
|
243
|
+
| Enforce default model | `OPENWEBUI_ENFORCE_DEFAULT_MODEL`, `OWUI_ENFORCE_DEFAULT_MODEL` | `false` |
|
|
244
|
+
| `ask` tool description | `OPENWEBUI_ASK_DESCRIPTION`, `OWUI_ASK_DESCRIPTION` | built-in docstring |
|
|
245
|
+
| Server instructions | `OPENWEBUI_INSTRUCTIONS`, `OWUI_INSTRUCTIONS` | none |
|
|
246
|
+
| MCP bearer token | `OPENWEBUI_MCP_TOKEN`, `OWUI_MCP_TOKEN` | none |
|
|
247
|
+
| Transport | `OPENWEBUI_MCP_TRANSPORT` | `stdio` |
|
|
248
|
+
| Chat timeout ms | `OWUI_TIMEOUT_MS` | `120000` |
|
|
249
|
+
| Open WebUI CA bundle | `OPENWEBUI_CA_BUNDLE`, `OWUI_CA_BUNDLE` | none |
|
|
250
|
+
| Skip TLS verify | `OPENWEBUI_SSL_VERIFY`, `OWUI_SSL_VERIFY` | `true` |
|
|
251
|
+
|
|
252
|
+
## Run
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
uv run openwebui-mcp # stdio (default), for local MCP clients
|
|
256
|
+
uv run openwebui-mcp --transport sse # SSE over HTTP
|
|
257
|
+
uv run openwebui-mcp --transport streamable-http --host 0.0.0.0 --port 8000
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Development
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
uv run pytest
|
|
264
|
+
uv run pyright src tests
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Layout
|
|
268
|
+
|
|
269
|
+
- `src/openwebui_mcp/server.py` - FastMCP server, the two tools, TLS apply, static token verifier
|
|
270
|
+
- `src/openwebui_mcp/config.py` - env-driven settings
|
|
271
|
+
- `src/openwebui_mcp/__main__.py` - CLI entry point
|
|
272
|
+
- `skills/owui-proactive-ask/` - agent skill that forces proactive use of `ask`
|
|
273
|
+
- `tests/` - config + server + TLS unit tests, incl. a protocol-level `call_tool` round trip
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "openwebui-mcp"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Open WebUI MCP server (FastMCP) - ask models with tool support, list models"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Alexey @vedmaka" }]
|
|
13
|
+
dependencies = [
|
|
14
|
+
# mcp 2.x moved `mcp.server.fastmcp` away; keep the 1.x line that has it
|
|
15
|
+
"mcp>=1.20,<2",
|
|
16
|
+
"openwebui-sdk>=0.1.1",
|
|
17
|
+
"python-dotenv>=1.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
openwebui-mcp = "openwebui_mcp.__main__:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["src"]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.package-data]
|
|
27
|
+
openwebui_mcp = ["py.typed"]
|
|
28
|
+
|
|
29
|
+
[dependency-groups]
|
|
30
|
+
dev = ["pytest>=8.0", "pyright>=1.1.400", "ruff==0.16.1"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
testpaths = ["tests"]
|
|
34
|
+
|
|
35
|
+
[tool.uv]
|
|
36
|
+
exclude-newer = "7 days"
|
|
37
|
+
|
|
38
|
+
[tool.uv.exclude-newer-package]
|
|
39
|
+
openwebui-sdk = false
|
|
40
|
+
ruff = false
|
|
41
|
+
|
|
42
|
+
# Tell static analyzers (pyright/pylance) this is a src-layout package so the
|
|
43
|
+
# intra-package relative imports in __main__.py / cli.py resolve.
|
|
44
|
+
[tool.pyright]
|
|
45
|
+
include = ["src"]
|
|
46
|
+
extraPaths = ["src"]
|
|
47
|
+
reportMissingImports = "none"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Open WebUI MCP server - ask models with tool support over MCP.
|
|
2
|
+
|
|
3
|
+
Public surface:
|
|
4
|
+
|
|
5
|
+
* ``config.Settings`` - server/connection configuration (env driven)
|
|
6
|
+
* ``server.create_server`` - build a ``FastMCP`` instance exposing the tools
|
|
7
|
+
* ``__main__.main`` - CLI entry point (``openwebui-mcp``)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from openwebui_mcp.config import Settings
|
|
11
|
+
from openwebui_mcp.server import create_server
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0"
|
|
14
|
+
|
|
15
|
+
__all__ = ["Settings", "__version__", "create_server"]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""CLI entry point for the Open WebUI MCP server.
|
|
2
|
+
|
|
3
|
+
Run ``openwebui-mcp`` (stdio by default) or ``python -m openwebui_mcp``.
|
|
4
|
+
Configure via env vars or a ``.env`` file in the working directory.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import logging
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
from openwebui_mcp.config import Settings, load_dotenv
|
|
14
|
+
from openwebui_mcp.server import create_server
|
|
15
|
+
|
|
16
|
+
VALID_TRANSPORTS = ("stdio", "sse", "streamable-http")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
20
|
+
parser = argparse.ArgumentParser(
|
|
21
|
+
prog="openwebui-mcp",
|
|
22
|
+
description="Open WebUI MCP server: ask models with tool support over MCP",
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"--transport",
|
|
26
|
+
choices=VALID_TRANSPORTS,
|
|
27
|
+
help="MCP transport (default: stdio). Overrides OPENWEBUI_MCP_TRANSPORT.",
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--name",
|
|
31
|
+
help="Server name shown to clients (default: %(default)r)",
|
|
32
|
+
default="openwebui",
|
|
33
|
+
)
|
|
34
|
+
parser.add_argument("--host", help="HTTP bind host for sse/streamable-http")
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"--port", type=int, help="HTTP bind port for sse/streamable-http"
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument(
|
|
39
|
+
"--log-level",
|
|
40
|
+
choices=("DEBUG", "INFO", "WARNING", "ERROR"),
|
|
41
|
+
default="INFO",
|
|
42
|
+
help="Logging verbosity (default: INFO)",
|
|
43
|
+
)
|
|
44
|
+
return parser
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main(argv: list[str] | None = None) -> int:
|
|
48
|
+
load_dotenv()
|
|
49
|
+
args = build_parser().parse_args(argv)
|
|
50
|
+
|
|
51
|
+
logging.basicConfig(level=getattr(logging, args.log_level))
|
|
52
|
+
|
|
53
|
+
overrides: dict[str, str] = {}
|
|
54
|
+
if args.transport:
|
|
55
|
+
overrides["transport"] = args.transport
|
|
56
|
+
if args.name:
|
|
57
|
+
overrides["name"] = args.name
|
|
58
|
+
if args.host:
|
|
59
|
+
overrides["host"] = args.host
|
|
60
|
+
if args.port is not None:
|
|
61
|
+
overrides["port"] = str(args.port)
|
|
62
|
+
|
|
63
|
+
settings = Settings.from_env(**overrides)
|
|
64
|
+
server = create_server(settings)
|
|
65
|
+
server.run(transport=settings.transport)
|
|
66
|
+
return 0
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
sys.exit(main())
|