Skip to content

Commit de9feb5

Browse files
rob1nzonDenisjonigl
authored
Add docker and dc (#22)
* Add docker compose * Fix * Delete .vscode/settings.json * Update README.md * fix: using port 8000 for consistency * chore: using mock mcp server to avoid using a third party for security reasons * feat: updating mock weather mcp server to make it easier to work with docker * fix: updating tests * docs: updating README.md related to mock mcp server stuff * docs: updating README.md with new docker-compose way to run * chore: adding new line --------- Co-authored-by: Denis <chentsov@restream.rt.ru> Co-authored-by: Jonathan Gastón Löwenstern <jonigl@gmail.com>
1 parent 9dc1cab commit de9feb5

File tree

10 files changed

+633
-8
lines changed

10 files changed

+633
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ wheels/
1111

1212
# Dynamic package version
1313
_version.py
14+
.vscode

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.10.15-slim
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
git \
5+
&& rm -rf /var/lib/apt/lists/*
6+
7+
RUN pip install uv
8+
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OLLAMA_MCP_BRIDGE=0.1.0
9+
10+
COPY . ./
11+
12+
RUN uv sync
13+
14+
EXPOSE 8000
15+
16+
CMD ["uv", "run", "ollama-mcp-bridge"]

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
- [Installation](#installation)
2323
- [Quick Start](#quick-start)
2424
- [Or, install from PyPI with pip](#or-install-from-pypi-with-pip)
25+
- [Or, run with Docker Compose](#or-run-with-docker-compose)
26+
- [Or, run with Docker only](#or-run-with-docker-only)
2527
- [Or, install from source](#or-install-from-source)
2628
- [How It Works](#how-it-works)
2729
- [Configuration](#configuration)
@@ -77,6 +79,19 @@ uvx ollama-mcp-bridge
7779
pip install --upgrade ollama-mcp-bridge
7880
```
7981

82+
### Or, run with Docker Compose
83+
84+
```bash
85+
docker-compose up
86+
```
87+
88+
This uses the included [docker-compose.yml](./docker-compose.yml) file which:
89+
- Builds the bridge from source using this Dockerfile [Dockerfile](./Dockerfile)
90+
- Connects to Ollama running on the host machine (`host.docker.internal:11434`)
91+
- Maps the configuration file from [./mcp-config.json](./mcp-config.json) (includes mock [weather server for demo](./mock-weather-mcp-server))
92+
- Allows all CORS origins (configurable via `CORS_ORIGINS` environment variable)
93+
94+
8095
### Or, install from source
8196

8297
```bash
@@ -121,7 +136,7 @@ ollama-mcp-bridge
121136

122137
### MCP Servers Configuration
123138

124-
Create an MCP configuration file at `mcp-servers-config/mcp-config.json` with your servers:
139+
Create an MCP configuration file at `mcp-config.json` with your servers:
125140

126141
```json
127142
{
@@ -130,9 +145,9 @@ Create an MCP configuration file at `mcp-servers-config/mcp-config.json` with yo
130145
"command": "uv",
131146
"args": [
132147
"--directory",
133-
".",
148+
"./mock-weather-mcp-server",
134149
"run",
135-
"mock-weather-mcp-server.py"
150+
"main.py"
136151
],
137152
"env": {
138153
"MCP_LOG_LEVEL": "ERROR"
@@ -179,13 +194,13 @@ CORS_ORIGINS="http://localhost:3000,http://localhost:8080,https://app.example.co
179194
> Using `CORS_ORIGINS="*"` allows all origins and is not recommended for production. Always specify exact origins for security.
180195
181196
> [!NOTE]
182-
> An example MCP server script is provided at `mcp-servers-config/mock-weather-mcp-server.py`.
197+
> An example MCP server script is provided at [mock-weather-mcp-server/main.py](mock-weather-mcp-server/main.py).
183198
184199
## Usage
185200

186201
### Start the Server
187202
```bash
188-
# Start with default settings (config: mcp-servers-config/mcp-config.json, host: 0.0.0.0, port: 8000)
203+
# Start with default settings (config: ./mcp-config.json, host: 0.0.0.0, port: 8000)
189204
ollama-mcp-bridge
190205

191206
# Start with custom configuration file

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
ollama-mcp-bridge:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
ports:
7+
- "8000:8000"
8+
environment:
9+
- OLLAMA_URL=http://host.docker.internal:11434
10+
- CORS_ORIGINS=*
11+
volumes:
12+
- ./mcp-config.json:/root/mcp-config.json
13+
restart: unless-stopped
14+
command: uv run ollama-mcp-bridge --ollama-url=http://host.docker.internal:11434

mcp-servers-config/mcp-config.json renamed to mcp-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"command": "uv",
55
"args": [
66
"--directory",
7-
".",
7+
"./mock-weather-mcp-server",
88
"run",
9-
"mock-weather-mcp-server.py"
9+
"main.py"
1010
],
1111
"env": {
1212
"MCP_LOG_LEVEL": "ERROR"

mock-weather-mcp-server/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Mock Weather MCP Server
2+
3+
This is just a mock implementation of a weather MCP server for testing purposes.
File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[project]
2+
name = "mock-weather-mcp-server"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
dependencies = [
8+
"mcp>=1.9.4",
9+
]

mock-weather-mcp-server/uv.lock

Lines changed: 567 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_imports():
116116

117117
def test_example_config_structure():
118118
"""Test that the example config file has the correct structure"""
119-
config_path = Path(__file__).parent.parent / "mcp-servers-config" / "mcp-config.json"
119+
config_path = Path(__file__).parent.parent / "mcp-config.json"
120120

121121
if config_path.exists():
122122
with open(config_path, 'r', encoding='utf-8') as f:

0 commit comments

Comments
 (0)