From 7ff145ce88ca3d334f7edac61150d870cc3d1ae4 Mon Sep 17 00:00:00 2001 From: Gwyneth Pena-Siguenza Date: Wed, 1 Apr 2026 18:41:53 +0000 Subject: [PATCH 1/6] Add ollama specific devcontainer --- .devcontainer/ollama/devcontainer.json | 42 ++++++++++++++++++++++++++ .env.sample.ollama | 14 +++++++++ README.md | 14 +++++++-- spanish/README.md | 14 +++++++-- 4 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 .devcontainer/ollama/devcontainer.json create mode 100644 .env.sample.ollama diff --git a/.devcontainer/ollama/devcontainer.json b/.devcontainer/ollama/devcontainer.json new file mode 100644 index 0000000..999c542 --- /dev/null +++ b/.devcontainer/ollama/devcontainer.json @@ -0,0 +1,42 @@ +{ + "name": "Python MCP Demos (Ollama)", + "image": "mcr.microsoft.com/devcontainers/python:3-3.13-bookworm", + "features": { + "ghcr.io/va-h/devcontainers-features/uv:1": {}, + "ghcr.io/devcontainers/features/node:1": { "version": "lts" }, + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/azure/azure-dev/azd:latest": {}, + "ghcr.io/prulloac/devcontainer-features/ollama:1": {} + }, + "postCreateCommand": "uv sync && cp .env.sample.ollama .env && ollama pull qwen3.5:0.6b", + "forwardPorts": [6277, 6274], + "portsAttributes": { + "6277": { + "label": "MCP Proxy Server", + "visibility": "public", + "onAutoForward": "silent" + }, + "6274": { + "label": "MCP Inspector UI", + "visibility": "public" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "github.copilot", + "github.copilot-chat" + ], + "settings": { + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", + "chat.mcp.autostart": "never" + } + } + }, + "hostRequirements": { + "memory": "64gb" + }, + "remoteUser": "vscode" +} diff --git a/.env.sample.ollama b/.env.sample.ollama new file mode 100644 index 0000000..edecbdf --- /dev/null +++ b/.env.sample.ollama @@ -0,0 +1,14 @@ +# API Host Selection +API_HOST=ollama + +# Ollama Configuration +OLLAMA_MODEL=qwen3.5:0.6b +OLLAMA_ENDPOINT=http://localhost:11434/v1 +OLLAMA_API_KEY=no-key-needed + +# GitHub MCP Configuration (for Langchain+GitHub example) +GITHUB_TOKEN=your_github_token_here + +# OpenTelemetry Configuration (for Aspire Dashboard) +# Uncomment to enable tracing, metrics, and logs export +# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 diff --git a/README.md b/README.md index a27f936..2943d07 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,17 @@ You have a few options for setting up this project. The quickest way to get star ### GitHub Codespaces -You can run this project virtually by using GitHub Codespaces. Click the button to open a web-based VS Code instance in your browser: +You can run this project virtually by using GitHub Codespaces. Click one of the buttons below to open a web-based VS Code instance in your browser: -[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/pamelafox/python-mcp-demo) +**Default (Azure OpenAI):** + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/python-mcp-demos) + +**Ollama (local models, requires 64GB+ memory):** + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/python-mcp-demos?devcontainer_path=.devcontainer/ollama/devcontainer.json) + +The Ollama Codespace pre-installs Ollama and pulls the `qwen3.5:0.6b` model, and copies `.env.sample.ollama` as your `.env` file. Note that the 64GB memory requirement will consume your Codespace quota faster. Once the Codespace is open, open a terminal window and continue with the deployment steps. @@ -37,7 +45,7 @@ Once the Codespace is open, open a terminal window and continue with the deploym A related option is VS Code Dev Containers, which will open the project in your local VS Code using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers): 1. Start Docker Desktop (install it if not already installed) -2. Open the project: [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/pamelafox/python-mcp-demo) +2. Open the project: [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/python-mcp-demos) 3. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window. 4. Continue with the deployment steps. diff --git a/spanish/README.md b/spanish/README.md index 33fcf3a..4016b98 100644 --- a/spanish/README.md +++ b/spanish/README.md @@ -25,9 +25,17 @@ Hay varias opciones para configurar este proyecto. La forma más rápida es GitH ### GitHub Codespaces -Puedes ejecutar este proyecto de forma virtual usando GitHub Codespaces. Haz clic en el botón para abrir una instancia web de VS Code en tu navegador: +Puedes ejecutar este proyecto de forma virtual usando GitHub Codespaces. Haz clic en uno de los botones para abrir una instancia web de VS Code en tu navegador: -[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/pamelafox/python-mcp-demo) +**Predeterminado (Azure OpenAI):** + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/python-mcp-demos) + +**Ollama (modelos locales, requiere 64GB+ de memoria):** + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/python-mcp-demos?devcontainer_path=.devcontainer/ollama/devcontainer.json) + +El Codespace de Ollama pre-instala Ollama y descarga el modelo `qwen3.5:0.6b`, y copia `.env.sample.ollama` como tu archivo `.env`. Ten en cuenta que el requisito de 64GB de memoria consumirá tu cuota de Codespace más rápido. Una vez abierto el Codespace, abre una terminal y continúa con los pasos de despliegue. @@ -36,7 +44,7 @@ Una vez abierto el Codespace, abre una terminal y continúa con los pasos de des Otra opción relacionada es VS Code Dev Containers, que abre el proyecto en tu VS Code local usando la extensión [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers): 1. Inicia Docker Desktop (instálalo si todavía no lo tienes) -2. Abre el proyecto: [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/pamelafox/python-mcp-demo) +2. Abre el proyecto: [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/python-mcp-demos) 3. En la ventana de VS Code que se abre, cuando aparezcan los archivos (puede tardar varios minutos), abre una terminal. 4. Continúa con los pasos de despliegue. From 31c8e7c6323eaab0f82110bd088dc64653cbd5b0 Mon Sep 17 00:00:00 2001 From: Gwyneth Pena-Siguenza Date: Wed, 1 Apr 2026 18:50:59 +0000 Subject: [PATCH 2/6] add zstd --- .devcontainer/ollama/Dockerfile | 2 ++ .devcontainer/ollama/devcontainer.json | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/ollama/Dockerfile diff --git a/.devcontainer/ollama/Dockerfile b/.devcontainer/ollama/Dockerfile new file mode 100644 index 0000000..487550e --- /dev/null +++ b/.devcontainer/ollama/Dockerfile @@ -0,0 +1,2 @@ +FROM mcr.microsoft.com/devcontainers/python:3-3.13-bookworm +RUN apt-get update && apt-get install -y --no-install-recommends zstd && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/ollama/devcontainer.json b/.devcontainer/ollama/devcontainer.json index 999c542..616a6d9 100644 --- a/.devcontainer/ollama/devcontainer.json +++ b/.devcontainer/ollama/devcontainer.json @@ -1,6 +1,8 @@ { "name": "Python MCP Demos (Ollama)", - "image": "mcr.microsoft.com/devcontainers/python:3-3.13-bookworm", + "build": { + "dockerfile": "Dockerfile" + }, "features": { "ghcr.io/va-h/devcontainers-features/uv:1": {}, "ghcr.io/devcontainers/features/node:1": { "version": "lts" }, From 8c3c286d0219eadd7163b65a277d0474dd460a10 Mon Sep 17 00:00:00 2001 From: Gwyneth Pena-Siguenza Date: Wed, 1 Apr 2026 19:03:13 +0000 Subject: [PATCH 3/6] run ollama on postcreate --- .devcontainer/ollama/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/ollama/devcontainer.json b/.devcontainer/ollama/devcontainer.json index 616a6d9..eb50f0d 100644 --- a/.devcontainer/ollama/devcontainer.json +++ b/.devcontainer/ollama/devcontainer.json @@ -10,7 +10,7 @@ "ghcr.io/azure/azure-dev/azd:latest": {}, "ghcr.io/prulloac/devcontainer-features/ollama:1": {} }, - "postCreateCommand": "uv sync && cp .env.sample.ollama .env && ollama pull qwen3.5:0.6b", + "postCreateCommand": "uv sync && cp .env.sample.ollama .env && ollama serve &>/dev/null & sleep 5 && ollama pull qwen3.5:0.6b", "forwardPorts": [6277, 6274], "portsAttributes": { "6277": { From f2c752ca7d14169942a61bc1100a0beb6ee44650 Mon Sep 17 00:00:00 2001 From: Gwyneth Pena-Siguenza Date: Wed, 1 Apr 2026 19:09:29 +0000 Subject: [PATCH 4/6] use pull from feature --- .devcontainer/ollama/devcontainer.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.devcontainer/ollama/devcontainer.json b/.devcontainer/ollama/devcontainer.json index eb50f0d..94c8815 100644 --- a/.devcontainer/ollama/devcontainer.json +++ b/.devcontainer/ollama/devcontainer.json @@ -8,9 +8,11 @@ "ghcr.io/devcontainers/features/node:1": { "version": "lts" }, "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/azure/azure-dev/azd:latest": {}, - "ghcr.io/prulloac/devcontainer-features/ollama:1": {} + "ghcr.io/prulloac/devcontainer-features/ollama:1": { + "pull": "qwen3.5:0.6b" + } }, - "postCreateCommand": "uv sync && cp .env.sample.ollama .env && ollama serve &>/dev/null & sleep 5 && ollama pull qwen3.5:0.6b", + "postCreateCommand": "uv sync && cp .env.sample.ollama .env", "forwardPorts": [6277, 6274], "portsAttributes": { "6277": { From d9aae9d88d7a4b9db39047aca9f0da07f78c3220 Mon Sep 17 00:00:00 2001 From: Gwyneth Pena-Siguenza Date: Wed, 1 Apr 2026 19:17:05 +0000 Subject: [PATCH 5/6] model pull to postCreate --- .devcontainer/ollama/devcontainer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.devcontainer/ollama/devcontainer.json b/.devcontainer/ollama/devcontainer.json index 94c8815..9661ccb 100644 --- a/.devcontainer/ollama/devcontainer.json +++ b/.devcontainer/ollama/devcontainer.json @@ -8,11 +8,10 @@ "ghcr.io/devcontainers/features/node:1": { "version": "lts" }, "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/azure/azure-dev/azd:latest": {}, - "ghcr.io/prulloac/devcontainer-features/ollama:1": { - "pull": "qwen3.5:0.6b" - } + "ghcr.io/prulloac/devcontainer-features/ollama:1": {} }, "postCreateCommand": "uv sync && cp .env.sample.ollama .env", + "postStartCommand": "ollama pull qwen3.5:0.6b", "forwardPorts": [6277, 6274], "portsAttributes": { "6277": { From 33884b8009e0b4c717859793dfa1fd483532c612 Mon Sep 17 00:00:00 2001 From: Gwyneth Pena-Siguenza Date: Wed, 1 Apr 2026 19:26:06 +0000 Subject: [PATCH 6/6] update to correct model version --- .devcontainer/ollama/devcontainer.json | 5 +++-- .env.sample.ollama | 2 +- README.md | 2 +- spanish/README.md | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.devcontainer/ollama/devcontainer.json b/.devcontainer/ollama/devcontainer.json index 9661ccb..22ac1a9 100644 --- a/.devcontainer/ollama/devcontainer.json +++ b/.devcontainer/ollama/devcontainer.json @@ -8,10 +8,11 @@ "ghcr.io/devcontainers/features/node:1": { "version": "lts" }, "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/azure/azure-dev/azd:latest": {}, - "ghcr.io/prulloac/devcontainer-features/ollama:1": {} + "ghcr.io/prulloac/devcontainer-features/ollama:1": { + "pull": "qwen3.5:9b" + } }, "postCreateCommand": "uv sync && cp .env.sample.ollama .env", - "postStartCommand": "ollama pull qwen3.5:0.6b", "forwardPorts": [6277, 6274], "portsAttributes": { "6277": { diff --git a/.env.sample.ollama b/.env.sample.ollama index edecbdf..341ef4f 100644 --- a/.env.sample.ollama +++ b/.env.sample.ollama @@ -2,7 +2,7 @@ API_HOST=ollama # Ollama Configuration -OLLAMA_MODEL=qwen3.5:0.6b +OLLAMA_MODEL=qwen3.5:9b OLLAMA_ENDPOINT=http://localhost:11434/v1 OLLAMA_API_KEY=no-key-needed diff --git a/README.md b/README.md index 2943d07..de2971a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ You can run this project virtually by using GitHub Codespaces. Click one of the [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/python-mcp-demos?devcontainer_path=.devcontainer/ollama/devcontainer.json) -The Ollama Codespace pre-installs Ollama and pulls the `qwen3.5:0.6b` model, and copies `.env.sample.ollama` as your `.env` file. Note that the 64GB memory requirement will consume your Codespace quota faster. +The Ollama Codespace pre-installs Ollama and pulls the `qwen3.5:9b` model, and copies `.env.sample.ollama` as your `.env` file. Note that the 64GB memory requirement will consume your Codespace quota faster. Once the Codespace is open, open a terminal window and continue with the deployment steps. diff --git a/spanish/README.md b/spanish/README.md index 4016b98..bfee1ca 100644 --- a/spanish/README.md +++ b/spanish/README.md @@ -35,7 +35,7 @@ Puedes ejecutar este proyecto de forma virtual usando GitHub Codespaces. Haz cli [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/python-mcp-demos?devcontainer_path=.devcontainer/ollama/devcontainer.json) -El Codespace de Ollama pre-instala Ollama y descarga el modelo `qwen3.5:0.6b`, y copia `.env.sample.ollama` como tu archivo `.env`. Ten en cuenta que el requisito de 64GB de memoria consumirá tu cuota de Codespace más rápido. +El Codespace de Ollama pre-instala Ollama y descarga el modelo `qwen3.5:9b`, y copia `.env.sample.ollama` como tu archivo `.env`. Ten en cuenta que el requisito de 64GB de memoria consumirá tu cuota de Codespace más rápido. Una vez abierto el Codespace, abre una terminal y continúa con los pasos de despliegue.