100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.
feat(browser_mcp_agent): document and unblock local Ollama / OpenAI-compatible providers
Ryan Alexander Alberts664e65c593f8
diff --git a/mcp_ai_agents/browser_mcp_agent/README.md b/mcp_ai_agents/browser_mcp_agent/README.mdindex 9a415713..eb21f51d 100644--- a/mcp_ai_agents/browser_mcp_agent/README.md+++ b/mcp_ai_agents/browser_mcp_agent/README.md@@ -43,12 +43,45 @@ A Streamlit application that allows you to browse and interact with websites usi```Both commands should return version numbers. If they don't, please install Node.js.-4. Set up your API keys:- - Set OpenAI API Key as an environment variable:- ```bash- export OPENAI_API_KEY=your-openai-api-key- ```+4. Set up your API keys. Pick **one** of:+ **a) Via environment variable (simplest for OpenAI):**+ ```bash+ export OPENAI_API_KEY=your-openai-api-key+ ```++ **b) Via `mcp_agent.secrets.yaml` (required for Ollama / any custom base URL):**+ ```bash+ cp mcp_agent.secrets.yaml.example mcp_agent.secrets.yaml+ # edit mcp_agent.secrets.yaml and put your key under openai.api_key+ ```++### Running with a local Ollama model++Because `mcp-agent` talks to an OpenAI-compatible endpoint and Ollama exposes one at `http://localhost:11434/v1`, this agent runs against a local model with just config changes — no code edits or extra dependencies. See discussion in [#329](https://github.com/Shubhamsaboo/awesome-llm-apps/issues/329).++1. Install and start Ollama, then pull a tool-capable model:+ ```bash+ ollama pull llama3.2+ ollama serve+ ```++2. Edit `mcp_agent.config.yaml` and replace the `openai:` block with:+ ```yaml+ openai:+ base_url: "http://localhost:11434/v1"+ default_model: "llama3.2"+ ```++3. In `mcp_agent.secrets.yaml`, set any non-empty `api_key` (Ollama ignores it):+ ```yaml+ openai:+ api_key: "ollama"+ ```++4. Run as normal — `streamlit run main.py`. No `OPENAI_API_KEY` env var is required in this path.++> Note: browser automation benefits from a reasoning-capable model. Smaller local models may struggle with multi-step Playwright tasks.### Running the Appdiff --git a/mcp_ai_agents/browser_mcp_agent/main.py b/mcp_ai_agents/browser_mcp_agent/main.pyindex 6cf81e1b..8d83dbf1 100644--- a/mcp_ai_agents/browser_mcp_agent/main.py+++ b/mcp_ai_agents/browser_mcp_agent/main.py@@ -88,9 +88,19 @@ async def setup_agent():# Main function to run agentasync def run_mcp_agent(message):- if not os.getenv("OPENAI_API_KEY"):- return "Error: OpenAI API key not provided"-+ # Credentials come from mcp_agent.secrets.yaml (api_key) and+ # mcp_agent.config.yaml (base_url, default_model). Both OpenAI and any+ # OpenAI-compatible server (e.g. Ollama at http://localhost:11434/v1)+ # are supported via the same `openai:` config section — see README.+ if not os.getenv("OPENAI_API_KEY") and not os.path.exists(+ os.path.join(os.path.dirname(__file__), "mcp_agent.secrets.yaml")+ ):+ return (+ "Error: no LLM credentials found. Either set OPENAI_API_KEY in "+ "your environment, or create mcp_agent.secrets.yaml from the "+ "provided example (works for OpenAI and local Ollama)."+ )+try:# Make sure agent is initializederror = await setup_agent()diff --git a/mcp_ai_agents/browser_mcp_agent/mcp_agent.config.yaml b/mcp_ai_agents/browser_mcp_agent/mcp_agent.config.yamlindex ba06227e..8f091b0b 100644--- a/mcp_ai_agents/browser_mcp_agent/mcp_agent.config.yaml+++ b/mcp_ai_agents/browser_mcp_agent/mcp_agent.config.yaml@@ -18,3 +18,14 @@ mcp:openai:# Secrets (API keys, etc.) are stored in an mcp_agent.secrets.yaml file which can be gitignoreddefault_model: "gpt-4o-mini"++# To run against a local Ollama (or any OpenAI-compatible) server, override+# the `openai` block above with the commented example below and put a dummy+# api_key (e.g. "ollama") in mcp_agent.secrets.yaml. Ollama exposes an+# OpenAI-compatible endpoint at /v1, so no framework changes are needed —+# this was confirmed by the mcp-agent maintainer in issue #329.+#+# openai:+# base_url: "http://localhost:11434/v1"+# default_model: "llama3.2"+diff --git a/mcp_ai_agents/browser_mcp_agent/mcp_agent.secrets.yaml.example b/mcp_ai_agents/browser_mcp_agent/mcp_agent.secrets.yaml.exampleindex a5f101b6..90093469 100644--- a/mcp_ai_agents/browser_mcp_agent/mcp_agent.secrets.yaml.example+++ b/mcp_ai_agents/browser_mcp_agent/mcp_agent.secrets.yaml.example@@ -1,2 +1,7 @@openai:- api_key: YOUR_OPENAI_API_KEY\ No newline at end of file+ api_key: YOUR_OPENAI_API_KEY++# For a local Ollama backend, any non-empty api_key works because Ollama+# doesn't authenticate; the important part is the base_url in config.yaml.+# openai:+# api_key: "ollama"