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 new file mode 100644 index 0000000..22ac1a9 --- /dev/null +++ b/.devcontainer/ollama/devcontainer.json @@ -0,0 +1,46 @@ +{ + "name": "Python MCP Demos (Ollama)", + "build": { + "dockerfile": "Dockerfile" + }, + "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": { + "pull": "qwen3.5:9b" + } + }, + "postCreateCommand": "uv sync && cp .env.sample.ollama .env", + "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..341ef4f --- /dev/null +++ b/.env.sample.ollama @@ -0,0 +1,14 @@ +# API Host Selection +API_HOST=ollama + +# Ollama Configuration +OLLAMA_MODEL=qwen3.5:9b +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..de2971a 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: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. @@ -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..bfee1ca 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: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. @@ -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.