{"id":30176813,"url":"https://github.com/simagix/vector-openai-mcp","last_synced_at":"2025-08-12T03:10:01.662Z","repository":{"id":309183323,"uuid":"1032113649","full_name":"simagix/vector-openai-mcp","owner":"simagix","description":"Demo on Vector Search, OpenAI, and MCP","archived":false,"fork":false,"pushed_at":"2025-08-10T10:31:29.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-10T12:27:30.471Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simagix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-04T20:34:59.000Z","updated_at":"2025-08-10T10:31:32.000Z","dependencies_parsed_at":"2025-08-10T12:27:32.696Z","dependency_job_id":"66461432-31fb-42f9-bb96-b4563a983427","html_url":"https://github.com/simagix/vector-openai-mcp","commit_stats":null,"previous_names":["simagix/vector-openai-mcp"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/simagix/vector-openai-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fvector-openai-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fvector-openai-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fvector-openai-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fvector-openai-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simagix","download_url":"https://codeload.github.com/simagix/vector-openai-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simagix%2Fvector-openai-mcp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269993473,"owners_count":24509028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-12T03:09:56.302Z","updated_at":"2025-08-12T03:10:01.655Z","avatar_url":"https://github.com/simagix.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vector Search + OpenAI MCP Demo\n\nThis project demonstrates how to implement vector search using Sentence-Transformers locally and on MongoDB Atlas, followed by integrating OpenAI’s Model Context Protocol (MCP) for intelligent routing and semantic querying. For more details, see the [Gen AI \u0026 Vector Search](https://sites.google.com/simagix.com/genai-vector-search) guide.\n\n## Table of Contents\n\n- [Vector Search + OpenAI MCP Demo](#vector-search--openai-mcp-demo)\n  - [Table of Contents](#table-of-contents)\n  - [Overview](#overview)\n  - [Setup](#setup)\n  - [Environment Variables](#environment-variables)\n  - [Components](#components)\n    - [🔹 `load_data.py`](#-load_datapy)\n    - [🔹 `sbert_vector_search.py`](#-sbert_vector_searchpy)\n    - [🔹 `atlas_vector_search.py`](#-atlas_vector_searchpy)\n    - [🔹 `mcp_server.py` \\\u0026 `mcp_client.py`](#-mcp_serverpy--mcp_clientpy)\n    - [🔹 `mcp_news_server.py`](#-mcp_news_serverpy)\n    - [🔹 `openai_client.py`](#-openai_clientpy)\n  - [Run Instructions](#run-instructions)\n  - [Testing](#testing)\n  - [License](#license)\n\n---\n\n## Overview\n\nThe project begins with populating data from the AG News dataset and showcases:\n\n1. **Local Vector Search** using [Sentence-Transformers](https://www.sbert.net/)\n2. **MongoDB Atlas Vector Search** using `$vectorSearch`\n3. **Intent Routing via MCP** to direct user input using semantic understanding\n4. **OpenAI Integration** with Azure to power a natural language interface\n\n---\n\n## Setup\n\nInstall dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n---\n\n## Environment Variables\n\nYou can set environment variables in a `.env` file or export them in your shell. Required variables include:\n\n- `MONGO_URL`\n- `AZURE_OPENAI_API_KEY`\n- `AZURE_OPENAI_ENDPOINT`\n- `OPENAI_API_KEY`\n- `USE_AZURE_OPENAI` (set to `true` to use Azure OpenAI)\n\nExample for Azure OpenAI (if using `mcp_news_server.py`):\n\n```bash\nexport AZURE_OPENAI_API_KEY=your_key\nexport AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/\n```\n\n---\n\n## Components\n\n### 🔹 `load_data.py`\n\nPopulates the `ag_news` collection with news data for use in local and Atlas vector search.\n\n### 🔹 `sbert_vector_search.py`\n\nPerforms vector search locally using Sentence-Transformers (`all-MiniLM-L6-v2`).\n\n### 🔹 `atlas_vector_search.py`\n\nUses MongoDB Atlas's `$vectorSearch` operator to run vector search on the cloud.\n\n### 🔹 `mcp_server.py` \u0026 `mcp_client.py`\n\nDemonstrates a simple MCP-based server and client setup to handle tool routing using user intent.\n\n### 🔹 `mcp_news_server.py`\n\nExtends `mcp_server` by integrating Azure OpenAI to route user input intelligently and combine it with local vector search.\n\n### 🔹 `openai_client.py`\n\nProvides a unified client for querying OpenAI or Azure OpenAI models.\n\n---\n\n## Run Instructions\n\n1. **Populate the database**:\n   ```bash\n   python load_data.py\n   ```\n\n2. **Run local vector search demo**:\n   ```bash\n   python sbert_vector_search.py\n   ```\n\n3. **Run Atlas vector search demo**:\n   ```bash\n   python atlas_vector_search.py\n   ```\n\n4. **Start the MCP server**:\n   ```bash\n   python mcp_server.py\n   ```\n\n5. **Send a query**:\n   ```bash\n   python mcp_client.py\n   ```\n\n6. **Optional**: For the AI-powered experience:\n   ```bash\n   python mcp_news_server.py\n   ```\n\n---\n\n## Testing\n\nTo run all unit and integration tests:\n\n```bash\npython -m unittest discover -s tests\n```\n\n---\n\n## License\n\nLicensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimagix%2Fvector-openai-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimagix%2Fvector-openai-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimagix%2Fvector-openai-mcp/lists"}