$git clone https://github.com/SecretiveShell/MCP-BridgeMCP-Bridge acts as a bridge between the OpenAI API and MCP (MCP) tools, allowing developers to leverage MCP tools through the OpenAI API interface.
| 1 | # MCP-Bridge |
| 2 | |
| 3 | <p> |
| 4 | <a href="https://discord.gg/4NVQHqNxSZ"><img alt="Discord" src="https://img.shields.io/discord/1320517159331430480?style=flat&logo=discord&color=blue"></a> |
| 5 | <a href="/docs/README.md"><img alt="Static Badge" src="https://img.shields.io/badge/docs-md-blue"></a> |
| 6 | <a href="LICENSE"><img alt="Static Badge" src="https://img.shields.io/badge/License-MIT-blue?style=flat"></a> |
| 7 | </p> |
| 8 | |
| 9 | |
| 10 | MCP-Bridge acts as a bridge between the OpenAI API and MCP (MCP) tools, allowing developers to leverage MCP tools through the OpenAI API interface. |
| 11 | |
| 12 | > [!NOTE] |
| 13 | > |
| 14 | > Looking for new maintainers to assist with the project. Reach out in the Discord or open an issue if you are interested. |
| 15 | > |
| 16 | > Additionally, Open WebUI natively supports MCP (Model Context Protocol) starting in v0.6.31, so MCP-Bridge should be considered as soft deprecated now. |
| 17 | |
| 18 | ## Overview |
| 19 | MCP-Bridge is designed to facilitate the integration of MCP tools with the OpenAI API. It provides a set of endpoints that can be used to interact with MCP tools in a way that is compatible with the OpenAI API. This allows you to use any client with any MCP tool without explicit support for MCP. For example, see this example of using Open Web UI with the official MCP fetch tool. |
| 20 | |
| 21 |  |
| 22 | |
| 23 | ## Current Features |
| 24 | |
| 25 | working features: |
| 26 | |
| 27 | - non streaming chat completions with MCP |
| 28 | - streaming chat completions with MCP |
| 29 | |
| 30 | - non streaming completions without MCP |
| 31 | |
| 32 | - MCP tools |
| 33 | - MCP sampling |
| 34 | |
| 35 | - SSE Bridge for external clients |
| 36 | |
| 37 | planned features: |
| 38 | |
| 39 | - streaming completions are not implemented yet |
| 40 | |
| 41 | - MCP resources are planned to be supported |
| 42 | |
| 43 | ## Installation |
| 44 | |
| 45 | The recommended way to install MCP-Bridge is to use Docker. See the example compose.yml file for an example of how to set up docker. |
| 46 | |
| 47 | Note that this requires an inference engine with tool call support. I have tested this with vLLM with success, though ollama should also be compatible. |
| 48 | |
| 49 | ### Docker installation |
| 50 | |
| 51 | 1. **Clone the repository** |
| 52 | |
| 53 | 2. **Edit the compose.yml file** |
| 54 | |
| 55 | You will need to add a reference to the config.json file in the compose.yml file. Pick any of |
| 56 | - add the config.json file to the same directory as the compose.yml file and use a volume mount (you will need to add the volume manually) |
| 57 | - add a http url to the environment variables to download the config.json file from a url |
| 58 | - add the config json directly as an environment variable |
| 59 | |
| 60 | see below for an example of each option: |
| 61 | ```bash |
| 62 | environment: |
| 63 | - MCP_BRIDGE__CONFIG__FILE=config.json # mount the config file for this to work |
| 64 | - MCP_BRIDGE__CONFIG__HTTP_URL=http://10.88.100.170:8888/config.json |
| 65 | - MCP_BRIDGE__CONFIG__JSON={"inference_server":{"base_url":"http://example.com/v1","api_key":"None"},"mcp_servers":{"fetch":{"command":"uvx","args":["mcp-server-fetch"]}}} |
| 66 | ``` |
| 67 | The mount point for using the config file would look like: |
| 68 | ```yaml |
| 69 | volumes: |
| 70 | - ./config.json:/mcp_bridge/config.json |
| 71 | ``` |
| 72 | |
| 73 | 3. **run the service** |
| 74 | ``` |
| 75 | docker-compose up --build -d |
| 76 | ``` |
| 77 | |
| 78 | ### Manual installation (no docker) |
| 79 | |
| 80 | If you want to run the application without docker, you will need to install the requirements and run the application manually. |
| 81 | |
| 82 | 1. **Clone the repository** |
| 83 | |
| 84 | 2. **Set up a dependencies:** |
| 85 | ```bash |
| 86 | uv sync |
| 87 | ``` |
| 88 | |
| 89 | 3. **Create a config.json file in the root directory** |
| 90 | |
| 91 | Here is an example config.json file: |
| 92 | ```json |
| 93 | { |
| 94 | "inference_server": { |
| 95 | "base_url": "http://example.com/v1", |
| 96 | "api_key": "None" |
| 97 | }, |
| 98 | "mcp_servers": { |
| 99 | "fetch": { |
| 100 | "command": "uvx", |
| 101 | "args": ["mcp-server-fetch"] |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | ``` |
| 106 | |
| 107 | 4. **Run the application:** |
| 108 | ```bash |
| 109 | uv run mcp_bridge/main.py |
| 110 | ``` |
| 111 | |
| 112 | ## Usage |
| 113 | Once the application is running, you can interact with it using the OpenAI API. |
| 114 | |
| 115 | View the documentation at [http://yourserver:8000/docs](http://localhost:8000/docs). There is an endpoint to list all the MCP tools available on the server, which you can use to test the application configuration. |
| 116 | |
| 117 | ## Rest API endpoints |
| 118 | |
| 119 | MCP-Bridge exposes many rest api endpoints for inte |