From 9a4b946f67c65f8994ab80953d3de636af5b7c2a Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Thu, 18 Sep 2025 17:03:50 -0700 Subject: [PATCH 01/10] mcp --- examples/README.md | 13 +++ examples/mcp_web_search_crawl_server.py | 132 ++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 examples/mcp_web_search_crawl_server.py diff --git a/examples/README.md b/examples/README.md index 3d44fa97..83d76c13 100644 --- a/examples/README.md +++ b/examples/README.md @@ -78,3 +78,16 @@ Requirement: `pip install tqdm` ### Thinking (levels) - Choose the thinking level - [thinking-levels.py](thinking-levels.py) + + +### MCP server - Expose web search and crawl tools to MCP clients +Requires: `pip install mcp` +- [mcp_web_search_crawl_server.py](mcp_web_search_crawl_server.py) + +Run via stdio (for Cursor/Claude MCP): +```sh +python3 examples/mcp_web_search_crawl_server.py +``` + +Optional environment: +- `OLLAMA_API_KEY`: If set, will be passed as an Authorization header for Ollama hosted web search/crawl APIs. diff --git a/examples/mcp_web_search_crawl_server.py b/examples/mcp_web_search_crawl_server.py new file mode 100644 index 00000000..42f2f419 --- /dev/null +++ b/examples/mcp_web_search_crawl_server.py @@ -0,0 +1,132 @@ +# /// script +# requires-python = ">=3.11" +# dependencies = [ +# "mcp", +# "rich", +# "ollama", +# ] +# /// +""" +Minimal MCP stdio server exposing Ollama web_search and web_crawl as tools. + +This lets MCP clients (e.g., Cursor, Claude Desktop) call these tools. + +Environment: +- OLLAMA_API_KEY (optional): if set, will be used as Authorization header. + +Run directly (stdio transport): + python examples/mcp_web_search_crawl_server.py + +In Cursor/Claude MCP config, point a command to this script. +""" + +from __future__ import annotations + +import asyncio +import os +from typing import Any, Dict, List + +from ollama import Client + +try: + # Preferred high-level API (if available) + from mcp.server.fastmcp import FastMCP # type: ignore + _FASTMCP_AVAILABLE = True +except Exception: + _FASTMCP_AVAILABLE = False + +if not _FASTMCP_AVAILABLE: + # Fallback to the low-level stdio server API + from mcp.server import Server # type: ignore + from mcp.server.stdio import stdio_server # type: ignore + + +def _make_client() -> Client: + headers = {} + api_key = os.getenv("OLLAMA_API_KEY") + if api_key: + headers["Authorization"] = api_key + return Client(headers=headers) + + +client = _make_client() + + +def _web_search_impl(queries: List[str], max_results: int = 3) -> Dict[str, Any]: + res = client.web_search(queries=queries, max_results=max_results) + return res.model_dump() + + +def _web_crawl_impl(urls: List[str]) -> Dict[str, Any]: + res = client.web_crawl(urls=urls) + return res.model_dump() + + +if _FASTMCP_AVAILABLE: + app = FastMCP("ollama-web-tools") + + @app.tool() + def web_search(queries: List[str], max_results: int = 3) -> Dict[str, Any]: + """ + Perform a web search using Ollama's hosted search API. + + Args: + queries: A list of search queries to run. + max_results: Maximum results per query (default: 3). + + Returns: + JSON-serializable dict matching ollama.WebSearchResponse.model_dump() + """ + + return _web_search_impl(queries=queries, max_results=max_results) + + @app.tool() + def web_crawl(urls: List[str]) -> Dict[str, Any]: + """ + Crawl one or more web pages and return extracted content. + + Args: + urls: A list of absolute URLs to crawl. + + Returns: + JSON-serializable dict matching ollama.WebCrawlResponse.model_dump() + """ + + return _web_crawl_impl(urls=urls) + + if __name__ == "__main__": + app.run() + +else: + server = Server("ollama-web-tools") # type: ignore[name-defined] + + @server.tool() # type: ignore[attr-defined] + async def web_search(queries: List[str], max_results: int = 3) -> Dict[str, Any]: + """ + Perform a web search using Ollama's hosted search API. + + Args: + queries: A list of search queries to run. + max_results: Maximum results per query (default: 3). + """ + + return await asyncio.to_thread(_web_search_impl, queries, max_results) + + @server.tool() # type: ignore[attr-defined] + async def web_crawl(urls: List[str]) -> Dict[str, Any]: + """ + Crawl one or more web pages and return extracted content. + + Args: + urls: A list of absolute URLs to crawl. + """ + + return await asyncio.to_thread(_web_crawl_impl, urls) + + async def _main() -> None: + async with stdio_server() as (read, write): # type: ignore[name-defined] + await server.run(read, write) # type: ignore[attr-defined] + + if __name__ == "__main__": + asyncio.run(_main()) + From 5e54b4241c7f4bc980987030c61c4d8c72c81e5a Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Tue, 23 Sep 2025 17:16:18 -0700 Subject: [PATCH 02/10] update mcp server --- examples/mcp-web-search-and-fetch.py | 117 +++++++++++++++++++++ examples/mcp_web_search_crawl_server.py | 132 ------------------------ 2 files changed, 117 insertions(+), 132 deletions(-) create mode 100644 examples/mcp-web-search-and-fetch.py delete mode 100644 examples/mcp_web_search_crawl_server.py diff --git a/examples/mcp-web-search-and-fetch.py b/examples/mcp-web-search-and-fetch.py new file mode 100644 index 00000000..ae388f81 --- /dev/null +++ b/examples/mcp-web-search-and-fetch.py @@ -0,0 +1,117 @@ +# /// script +# requires-python = ">=3.11" +# dependencies = [ +# "mcp", +# "rich", +# "ollama", +# ] +# /// +""" +MCP stdio server exposing Ollama web_search and web_fetch as tools. + +Environment: +- OLLAMA_API_KEY (required): if set, will be used as Authorization header. +""" + +from __future__ import annotations + +import asyncio +from typing import Any, Dict + +from ollama import Client + +try: + # Preferred high-level API (if available) + from mcp.server.fastmcp import FastMCP # type: ignore + _FASTMCP_AVAILABLE = True +except Exception: + _FASTMCP_AVAILABLE = False + +if not _FASTMCP_AVAILABLE: + # Fallback to the low-level stdio server API + from mcp.server import Server # type: ignore + from mcp.server.stdio import stdio_server # type: ignore + + + +client = Client() + + +def _web_search_impl(query: str, max_results: int = 3) -> Dict[str, Any]: + res = client.web_search(query=query, max_results=max_results) + return res.model_dump() + + +def _web_fetch_impl(url: str) -> Dict[str, Any]: + res = client.web_fetch(url=url) + return res.model_dump() + + +if _FASTMCP_AVAILABLE: + app = FastMCP("ollama-search-fetch") + + @app.tool() + def web_search(query: str, max_results: int = 3) -> Dict[str, Any]: + """ + Perform a web search using Ollama's hosted search API. + + Args: + query: The search query to run. + max_results: Maximum results to return (default: 3). + + Returns: + JSON-serializable dict matching ollama.WebSearchResponse.model_dump() + """ + + return _web_search_impl(query=query, max_results=max_results) + + @app.tool() + def web_fetch(url: str) -> Dict[str, Any]: + """ + Fetch the content of a web page for the provided URL. + + Args: + url: The absolute URL to fetch. + + Returns: + JSON-serializable dict matching ollama.WebFetchResponse.model_dump() + """ + + return _web_fetch_impl(url=url) + + if __name__ == "__main__": + app.run() + +else: + server = Server("ollama-search-fetch") # type: ignore[name-defined] + + @server.tool() # type: ignore[attr-defined] + async def web_search(query: str, max_results: int = 3) -> Dict[str, Any]: + """ + Perform a web search using Ollama's hosted search API. + + Args: + query: The search query to run. + max_results: Maximum results to return (default: 3). + """ + + return await asyncio.to_thread(_web_search_impl, query, max_results) + + @server.tool() # type: ignore[attr-defined] + async def web_fetch(url: str) -> Dict[str, Any]: + """ + Fetch the content of a web page for the provided URL. + + Args: + url: The absolute URL to fetch. + """ + + return await asyncio.to_thread(_web_fetch_impl, url) + + async def _main() -> None: + async with stdio_server() as (read, write): # type: ignore[name-defined] + await server.run(read, write) # type: ignore[attr-defined] + + if __name__ == "__main__": + asyncio.run(_main()) + diff --git a/examples/mcp_web_search_crawl_server.py b/examples/mcp_web_search_crawl_server.py deleted file mode 100644 index 42f2f419..00000000 --- a/examples/mcp_web_search_crawl_server.py +++ /dev/null @@ -1,132 +0,0 @@ -# /// script -# requires-python = ">=3.11" -# dependencies = [ -# "mcp", -# "rich", -# "ollama", -# ] -# /// -""" -Minimal MCP stdio server exposing Ollama web_search and web_crawl as tools. - -This lets MCP clients (e.g., Cursor, Claude Desktop) call these tools. - -Environment: -- OLLAMA_API_KEY (optional): if set, will be used as Authorization header. - -Run directly (stdio transport): - python examples/mcp_web_search_crawl_server.py - -In Cursor/Claude MCP config, point a command to this script. -""" - -from __future__ import annotations - -import asyncio -import os -from typing import Any, Dict, List - -from ollama import Client - -try: - # Preferred high-level API (if available) - from mcp.server.fastmcp import FastMCP # type: ignore - _FASTMCP_AVAILABLE = True -except Exception: - _FASTMCP_AVAILABLE = False - -if not _FASTMCP_AVAILABLE: - # Fallback to the low-level stdio server API - from mcp.server import Server # type: ignore - from mcp.server.stdio import stdio_server # type: ignore - - -def _make_client() -> Client: - headers = {} - api_key = os.getenv("OLLAMA_API_KEY") - if api_key: - headers["Authorization"] = api_key - return Client(headers=headers) - - -client = _make_client() - - -def _web_search_impl(queries: List[str], max_results: int = 3) -> Dict[str, Any]: - res = client.web_search(queries=queries, max_results=max_results) - return res.model_dump() - - -def _web_crawl_impl(urls: List[str]) -> Dict[str, Any]: - res = client.web_crawl(urls=urls) - return res.model_dump() - - -if _FASTMCP_AVAILABLE: - app = FastMCP("ollama-web-tools") - - @app.tool() - def web_search(queries: List[str], max_results: int = 3) -> Dict[str, Any]: - """ - Perform a web search using Ollama's hosted search API. - - Args: - queries: A list of search queries to run. - max_results: Maximum results per query (default: 3). - - Returns: - JSON-serializable dict matching ollama.WebSearchResponse.model_dump() - """ - - return _web_search_impl(queries=queries, max_results=max_results) - - @app.tool() - def web_crawl(urls: List[str]) -> Dict[str, Any]: - """ - Crawl one or more web pages and return extracted content. - - Args: - urls: A list of absolute URLs to crawl. - - Returns: - JSON-serializable dict matching ollama.WebCrawlResponse.model_dump() - """ - - return _web_crawl_impl(urls=urls) - - if __name__ == "__main__": - app.run() - -else: - server = Server("ollama-web-tools") # type: ignore[name-defined] - - @server.tool() # type: ignore[attr-defined] - async def web_search(queries: List[str], max_results: int = 3) -> Dict[str, Any]: - """ - Perform a web search using Ollama's hosted search API. - - Args: - queries: A list of search queries to run. - max_results: Maximum results per query (default: 3). - """ - - return await asyncio.to_thread(_web_search_impl, queries, max_results) - - @server.tool() # type: ignore[attr-defined] - async def web_crawl(urls: List[str]) -> Dict[str, Any]: - """ - Crawl one or more web pages and return extracted content. - - Args: - urls: A list of absolute URLs to crawl. - """ - - return await asyncio.to_thread(_web_crawl_impl, urls) - - async def _main() -> None: - async with stdio_server() as (read, write): # type: ignore[name-defined] - await server.run(read, write) # type: ignore[attr-defined] - - if __name__ == "__main__": - asyncio.run(_main()) - From 43090cf116dd955050bd1fea52a104ec1f688ebc Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Tue, 23 Sep 2025 17:24:15 -0700 Subject: [PATCH 03/10] update readme --- examples/README.md | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/examples/README.md b/examples/README.md index 83d76c13..be366c58 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,6 +1,7 @@ # Running Examples Run the examples in this directory with: + ```sh # Run example python3 examples/.py @@ -9,85 +10,87 @@ python3 examples/.py See [ollama/docs/api.md](https://github.com/ollama/ollama/blob/main/docs/api.md) for full API documentation ### Chat - Chat with a model + - [chat.py](chat.py) - [async-chat.py](async-chat.py) - [chat-stream.py](chat-stream.py) - Streamed outputs - [chat-with-history.py](chat-with-history.py) - Chat with model and maintain history of the conversation - ### Generate - Generate text with a model + - [generate.py](generate.py) - [async-generate.py](async-generate.py) - [generate-stream.py](generate-stream.py) - Streamed outputs - [fill-in-middle.py](fill-in-middle.py) - Given a prefix and suffix, fill in the middle - ### Tools/Function Calling - Call a function with a model + - [tools.py](tools.py) - Simple example of Tools/Function Calling - [async-tools.py](async-tools.py) - [multi-tool.py](multi-tool.py) - Using multiple tools, with thinking enabled - #### gpt-oss +#### gpt-oss + - [gpt-oss-tools.py](gpt-oss-tools.py) -- [gpt-oss-tools-stream.py](gpt-oss-tools-stream.py) +- [gpt-oss-tools-stream.py](gpt-oss-tools-stream.py) - [gpt-oss-tools-browser.py](gpt-oss-tools-browser.py) - Using browser research tools with gpt-oss - [gpt-oss-tools-browser-stream.py](gpt-oss-tools-browser-stream.py) - Using browser research tools with gpt-oss, with streaming enabled - ### Multimodal with Images - Chat with a multimodal (image chat) model + - [multimodal-chat.py](multimodal-chat.py) - [multimodal-generate.py](multimodal-generate.py) - ### Structured Outputs - Generate structured outputs with a model + - [structured-outputs.py](structured-outputs.py) - [async-structured-outputs.py](async-structured-outputs.py) - [structured-outputs-image.py](structured-outputs-image.py) - ### Ollama List - List all downloaded models and their properties -- [list.py](list.py) +- [list.py](list.py) ### Ollama Show - Display model properties and capabilities -- [show.py](show.py) +- [show.py](show.py) ### Ollama ps - Show model status with CPU/GPU usage -- [ps.py](ps.py) +- [ps.py](ps.py) ### Ollama Pull - Pull a model from Ollama + Requirement: `pip install tqdm` -- [pull.py](pull.py) +- [pull.py](pull.py) ### Ollama Create - Create a model from a Modelfile -- [create.py](create.py) +- [create.py](create.py) ### Ollama Embed - Generate embeddings with a model -- [embed.py](embed.py) +- [embed.py](embed.py) ### Thinking - Enable thinking mode for a model + - [thinking.py](thinking.py) ### Thinking (generate) - Enable thinking mode for a model + - [thinking-generate.py](thinking-generate.py) ### Thinking (levels) - Choose the thinking level + - [thinking-levels.py](thinking-levels.py) +### Web search and fetch MCP server -### MCP server - Expose web search and crawl tools to MCP clients -Requires: `pip install mcp` - [mcp_web_search_crawl_server.py](mcp_web_search_crawl_server.py) -Run via stdio (for Cursor/Claude MCP): ```sh -python3 examples/mcp_web_search_crawl_server.py +uv run examples/mcp-web-search-and-fetch.py ``` -Optional environment: -- `OLLAMA_API_KEY`: If set, will be passed as an Authorization header for Ollama hosted web search/crawl APIs. +`OLLAMA_API_KEY` is required. You can get one from [ollama.com/settings/keys](https://ollama.com/settings/keys). From 9dbdcdf3378e7f30957d5fd0827139db0e0c56b9 Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Tue, 23 Sep 2025 17:31:17 -0700 Subject: [PATCH 04/10] update docs --- examples/README.md | 27 ++++++++++++------- ...eb-search-crawl.py => web-search-fetch.py} | 0 2 files changed, 17 insertions(+), 10 deletions(-) rename examples/{web-search-crawl.py => web-search-fetch.py} (100%) diff --git a/examples/README.md b/examples/README.md index be366c58..2e52ff84 100644 --- a/examples/README.md +++ b/examples/README.md @@ -5,6 +5,9 @@ Run the examples in this directory with: ```sh # Run example python3 examples/.py + +# or with uv +uv run examples/.py ``` See [ollama/docs/api.md](https://github.com/ollama/ollama/blob/main/docs/api.md) for full API documentation @@ -36,6 +39,20 @@ See [ollama/docs/api.md](https://github.com/ollama/ollama/blob/main/docs/api.md) - [gpt-oss-tools-browser.py](gpt-oss-tools-browser.py) - Using browser research tools with gpt-oss - [gpt-oss-tools-browser-stream.py](gpt-oss-tools-browser-stream.py) - Using browser research tools with gpt-oss, with streaming enabled +### Web search and fetch - Use web search and fetch tools with a model + +`OLLAMA_API_KEY` is required. You can get one from [ollama.com/settings/keys](https://ollama.com/settings/keys). + +- [web-search-fetch.py](web-search-fetch.py) + +#### MCP server + +```sh +uv run examples/mcp-web-search-and-fetch.py +``` + +- [mcp_web_search_crawl_server.py](mcp_web_search_crawl_server.py) + ### Multimodal with Images - Chat with a multimodal (image chat) model - [multimodal-chat.py](multimodal-chat.py) @@ -84,13 +101,3 @@ Requirement: `pip install tqdm` ### Thinking (levels) - Choose the thinking level - [thinking-levels.py](thinking-levels.py) - -### Web search and fetch MCP server - -- [mcp_web_search_crawl_server.py](mcp_web_search_crawl_server.py) - -```sh -uv run examples/mcp-web-search-and-fetch.py -``` - -`OLLAMA_API_KEY` is required. You can get one from [ollama.com/settings/keys](https://ollama.com/settings/keys). diff --git a/examples/web-search-crawl.py b/examples/web-search-fetch.py similarity index 100% rename from examples/web-search-crawl.py rename to examples/web-search-fetch.py From c5bbd4562ae481ede9f01174d3696ef1a5729d80 Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Tue, 23 Sep 2025 17:31:56 -0700 Subject: [PATCH 05/10] lint --- examples/mcp-web-search-and-fetch.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/mcp-web-search-and-fetch.py b/examples/mcp-web-search-and-fetch.py index ae388f81..3dabf3cf 100644 --- a/examples/mcp-web-search-and-fetch.py +++ b/examples/mcp-web-search-and-fetch.py @@ -23,6 +23,7 @@ try: # Preferred high-level API (if available) from mcp.server.fastmcp import FastMCP # type: ignore + _FASTMCP_AVAILABLE = True except Exception: _FASTMCP_AVAILABLE = False @@ -33,7 +34,6 @@ from mcp.server.stdio import stdio_server # type: ignore - client = Client() @@ -48,7 +48,7 @@ def _web_fetch_impl(url: str) -> Dict[str, Any]: if _FASTMCP_AVAILABLE: - app = FastMCP("ollama-search-fetch") + app = FastMCP('ollama-search-fetch') @app.tool() def web_search(query: str, max_results: int = 3) -> Dict[str, Any]: @@ -79,11 +79,11 @@ def web_fetch(url: str) -> Dict[str, Any]: return _web_fetch_impl(url=url) - if __name__ == "__main__": + if __name__ == '__main__': app.run() else: - server = Server("ollama-search-fetch") # type: ignore[name-defined] + server = Server('ollama-search-fetch') # type: ignore[name-defined] @server.tool() # type: ignore[attr-defined] async def web_search(query: str, max_results: int = 3) -> Dict[str, Any]: @@ -112,6 +112,5 @@ async def _main() -> None: async with stdio_server() as (read, write): # type: ignore[name-defined] await server.run(read, write) # type: ignore[attr-defined] - if __name__ == "__main__": + if __name__ == '__main__': asyncio.run(_main()) - From 0e5b69bf737917efc0f992cd67a1ab8f5720ef24 Mon Sep 17 00:00:00 2001 From: Parth Sareen Date: Tue, 23 Sep 2025 17:43:47 -0700 Subject: [PATCH 06/10] Update examples/README.md Co-authored-by: Jeffrey Morgan --- examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index 2e52ff84..0b142b6a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -39,7 +39,7 @@ See [ollama/docs/api.md](https://github.com/ollama/ollama/blob/main/docs/api.md) - [gpt-oss-tools-browser.py](gpt-oss-tools-browser.py) - Using browser research tools with gpt-oss - [gpt-oss-tools-browser-stream.py](gpt-oss-tools-browser-stream.py) - Using browser research tools with gpt-oss, with streaming enabled -### Web search and fetch - Use web search and fetch tools with a model +### Web search `OLLAMA_API_KEY` is required. You can get one from [ollama.com/settings/keys](https://ollama.com/settings/keys). From 533e8233c67f25d6e2ecb62a59fe4209bd129eaa Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Tue, 23 Sep 2025 18:12:39 -0700 Subject: [PATCH 07/10] cleanup --- examples/README.md | 21 ++++++++++++++++--- ...-search-and-fetch.py => web-search-mcp.py} | 0 .../{web-search-fetch.py => web-search.py} | 0 3 files changed, 18 insertions(+), 3 deletions(-) rename examples/{mcp-web-search-and-fetch.py => web-search-mcp.py} (100%) rename examples/{web-search-fetch.py => web-search.py} (100%) diff --git a/examples/README.md b/examples/README.md index 0b142b6a..8c695eff 100644 --- a/examples/README.md +++ b/examples/README.md @@ -43,15 +43,30 @@ See [ollama/docs/api.md](https://github.com/ollama/ollama/blob/main/docs/api.md) `OLLAMA_API_KEY` is required. You can get one from [ollama.com/settings/keys](https://ollama.com/settings/keys). -- [web-search-fetch.py](web-search-fetch.py) +- [web-search.py](web-search.py) #### MCP server ```sh -uv run examples/mcp-web-search-and-fetch.py +uv run examples/web-search-mcp.py ``` -- [mcp_web_search_crawl_server.py](mcp_web_search_crawl_server.py) +Configuration to use with an MCP client: + +```json +{ + "mcpServers": { + "web_search": { + "type": "stdio", + "command": "uv", + "args": ["run", "path/to/ollama-python/examples/web-search-mcp.py"], + "env": { "OLLAMA_API_KEY": "api-key" } + } + } +} +``` + +- [web-search-mcp.py](web-search-mcp.py) ### Multimodal with Images - Chat with a multimodal (image chat) model diff --git a/examples/mcp-web-search-and-fetch.py b/examples/web-search-mcp.py similarity index 100% rename from examples/mcp-web-search-and-fetch.py rename to examples/web-search-mcp.py diff --git a/examples/web-search-fetch.py b/examples/web-search.py similarity index 100% rename from examples/web-search-fetch.py rename to examples/web-search.py From 2328bb6a19e368691d9db526936a548caaba1534 Mon Sep 17 00:00:00 2001 From: Parth Sareen Date: Tue, 23 Sep 2025 21:05:40 -0700 Subject: [PATCH 08/10] Update examples/README.md Co-authored-by: Jeffrey Morgan --- examples/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index 8c695eff..1f7ccca7 100644 --- a/examples/README.md +++ b/examples/README.md @@ -41,7 +41,11 @@ See [ollama/docs/api.md](https://github.com/ollama/ollama/blob/main/docs/api.md) ### Web search -`OLLAMA_API_KEY` is required. You can get one from [ollama.com/settings/keys](https://ollama.com/settings/keys). +An API key from Ollama's cloud service is required. You can create one [here](https://ollama.com/settings/keys). + +```shell +export OLLAMA_API_KEY="your_api_key_here" +``` - [web-search.py](web-search.py) From 12ce9e307dfc1890594f8a7e56278b89b9a0f1a1 Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Tue, 23 Sep 2025 21:15:21 -0700 Subject: [PATCH 09/10] update readme --- examples/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/README.md b/examples/README.md index 1f7ccca7..7ffc0502 100644 --- a/examples/README.md +++ b/examples/README.md @@ -51,6 +51,8 @@ export OLLAMA_API_KEY="your_api_key_here" #### MCP server +The MCP server can be used with an MCP client like Cursor, Cline, Codex, Open WebUI, Goose, and more. + ```sh uv run examples/web-search-mcp.py ``` From a11e9b4a80eed71cfc3d634fab27168111ae0e4d Mon Sep 17 00:00:00 2001 From: ParthSareen Date: Tue, 23 Sep 2025 21:48:54 -0700 Subject: [PATCH 10/10] api key update --- examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index 7ffc0502..82ccbe1b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -66,7 +66,7 @@ Configuration to use with an MCP client: "type": "stdio", "command": "uv", "args": ["run", "path/to/ollama-python/examples/web-search-mcp.py"], - "env": { "OLLAMA_API_KEY": "api-key" } + "env": { "OLLAMA_API_KEY": "your_api_key_here" } } } }