Skip to content
Back to search

mcp-bridge

A middleware to provide an openAI compatible endpoint that can call MCP tools

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/secretiveshell--mcp-bridge/badge.svg)](/listings/secretiveshell--mcp-bridge)

HTML

<a href="/listings/secretiveshell--mcp-bridge"><img src="/api/listings/secretiveshell--mcp-bridge/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

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.

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.

Docker installation

1. **Clone the repository**

2. **Edit the compose.yml file**

You will need to add a reference to the config.json file in the compose.yml file. Pick any of - 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) - add a http url to the environment variables to download the config.json file from a url - add the config json directly as an environment variable

see below for an example of each option:

environment:
  - MCP_BRIDGE__CONFIG__FILE=config.json # mount the config file for this to work
  - MCP_BRIDGE__CONFIG__HTTP_URL=http://10.88.100.170:8888/config.json
  - MCP_BRIDGE__CONFIG__JSON={"inference_server":{"base_url":"http://example.com/v1","api_key":"None"},"mcp_servers":{"fetch":{"command":"uvx","args":["mcp-server-fetch"]}}}

The mount point for using the config file would look like:

    volumes:
      - ./config.json:/mcp_bridge/config.json

3. **run the service**

docker-compose up --build -d

Manual installation (no docker)

If you want to run the application without docker, you will need to install the requirements and run the application manually.

1. **Clone the repository**

2. **Set up a dependencies:**

uv sync

3. **Create a config.json file in the root directory**

Here is an example config.json file:

{
   "inference_server": {
      "base_url": "http://example.com/v1",
      "api_key": "None"
   },
   "mcp_servers": {
      "fetch": {
        "command": "uvx",
        "args": ["mcp-server-fetch"]
      }
   }
}

4. **Run the application:**

uv run mcp_bridge/main.py

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 260 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # MCP-Bridge
  2. <p>
  3. <a href="https://discord.gg/4NVQHqNxSZ"><img alt="Discord" src="https://img.shields.io/discord/1320517159331430480?style=flat&logo=discord&color=blue"></a>
  4. <a href="/docs/README.md"><img alt="Static Badge" src="https://img.shields.io/badge/docs-md-blue"></a>
  5. <a href="LICENSE"><img alt="Static Badge" src="https://img.shields.io/badge/License-MIT-blue?style=flat"></a>
  6. </p>
  7. 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.
  8. > [!NOTE]
  9. >
  10. > Looking for new maintainers to assist with the project. Reach out in the Discord or open an issue if you are interested.
  11. >
  12. > Additionally, Open WebUI natively supports MCP (Model Context Protocol) starting in v0.6.31, so MCP-Bridge should be considered as soft deprecated now.
  13. ## Overview
  14. 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.
  15. ![open web ui example](/assets/owui_example.png)
  16. ## Current Features
  17. working features:
  18. - non streaming chat completions with MCP
  19. - streaming chat completions with MCP
  20. - non streaming completions without MCP
  21. - MCP tools
  22. - MCP sampling
  23. - SSE Bridge for external clients
  24. planned features:
  25. - streaming completions are not implemented yet
  26. - MCP resources are planned to be supported
  27. ## Installation
  28. 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.
  29. 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.
  30. ### Docker installation
  31. 1. **Clone the repository**
  32. 2. **Edit the compose.yml file**
  33. You will need to add a reference to the config.json file in the compose.yml file. Pick any of
  34. - 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)
  35. - add a http url to the environment variables to download the config.json file from a url
  36. - add the config json directly as an environment variable
  37. see below for an example of each option:
  38. ```bash
  39. environment:
  40. - MCP_BRIDGE__CONFIG__FILE=config.json # mount the config file for this to work
  41. - MCP_BRIDGE__CONFIG__HTTP_URL=http://10.88.100.170:8888/config.json
  42. - MCP_BRIDGE__CONFIG__JSON={"inference_server":{"base_url":"http://example.com/v1","api_key":"None"},"mcp_servers":{"fetch":{"command":"uvx","args":["mcp-server-fetch"]}}}
  43. ```
  44. The mount point for using the config file would look like:
  45. ```yaml
  46. volumes:
  47. - ./config.json:/mcp_bridge/config.json
  48. ```
  49. 3. **run the service**
  50. ```
  51. docker-compose up --build -d
  52. ```
  53. ### Manual installation (no docker)
  54. If you want to run the application without docker, you will need to install the requirements and run the application manually.
  55. 1. **Clone the repository**
  56. 2. **Set up a dependencies:**
  57. ```bash
  58. uv sync
  59. ```
  60. 3. **Create a config.json file in the root directory**
  61. Here is an example config.json file:
  62. ```json
  63. {
  64. "inference_server": {
  65. "base_url": "http://example.com/v1",
  66. "api_key": "None"
  67. },
  68. "mcp_servers": {
  69. "fetch": {
  70. "command": "uvx",
  71. "args": ["mcp-server-fetch"]
  72. }
  73. }
  74. }
  75. ```
  76. 4. **Run the application:**
  77. ```bash
  78. uv run mcp_bridge/main.py
  79. ```
  80. ## Usage
  81. Once the application is running, you can interact with it using the OpenAI API.
  82. 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.
  83. ## Rest API endpoints
  84. MCP-Bridge exposes many rest api endpoints for interacting with all of the native MCP primatives. This lets you outsource the complexity of dealing with MCP servers to MCP-Bridge without comprimising on functionality. See the openapi docs for examples of how to use this functionality.
  85. ## SSE Bridge
  86. MCP-Bridge also provides an SSE bridge for external clients. This lets external chat apps with explicit MCP support use MCP-Bridge as a MCP server. Point your client at the SSE endpoint (http://yourserver:8000/mcp-server/sse) and you should be able to see all the MCP tools available on the server.
  87. This also makes it easy to test if your configuration is working correctly. You can use [wong2/mcp-cli](https://github.com/wong2/mcp-cli?tab=readme-ov-file#connect-to-a-running-server-over-sse) to test your configuration. `npx @wong2/mcp-cli --sse http://localhost:8000/mcp-server/sse`
  88. If you want to use the tools inside of [claude desktop](https://claude.ai/download) or other `STDIO` only MCP clients, you can do this with a tool such as [lightconetech/mcp-gateway](https://github.com/lightconetech/mcp-gateway)
  89. ## Configuration
  90. To add new MCP servers, edit the config.json file.
  91. ### API Key Authentication
  92. MCP-Bridge supports API key authentication to secure your server. To enable this feature, add something like this to your `config.json` file:
  93. ```json
  94. {
  95. "security": {
  96. "auth": {
  97. "enabled": true,
  98. "api_keys": [
  99. {
  100. "key": "your-secure-api-key-here"
  101. }
  102. ]
  103. }
  104. }
  105. }
  106. ```
  107. When making requests to the MCP-Bridge server, include the API key in the Authorization header as a Bearer token:
  108. ```
  109. Authorization: Bearer your-secure-api-key-here
  110. ```
  111. If the `api_key` field is empty or not present in the configuration, authentication will be skipped, allowing backward compatibility.
  112. ### Full Configuration Example
  113. an example config.json file with most of the options explicitly set:
  114. ```json
  115. {
  116. "inference_server": {
  117. "base_url": "http://localhost:8000/v1",
  118. "api_key": "None"
  119. },
  120. "sampling": {
  121. "timeout": 10,
  122. "models": [
  123. {
  124. "model": "gpt-4o",
  125. "intelligence": 0.8,
  126. "cost": 0.9,
  127. "speed": 0.3
  128. },
  129. {
  130. "model": "gpt-4o-mini",
  131. "intelligence": 0.4,
  132. "cost": 0.1,
  133. "speed": 0.7
  134. }
  135. ]
  136. },
  137. "mcp_servers": {
  138. "fetch": {
  139. "command": "uvx",
  140. "args": [
  141. "mcp-server-fetch"
  142. ]
  143. }
  144. },
  145. "security": {
  146. "auth": {
  147. "enabled": true,
  148. "api_keys": [
  149. {
  150. "key": "your-secure-api-key-here"
  151. }
  152. ]
  153. }
  154. },
  155. "network": {
  156. "host": "0.0.0.0",
  157. "port": 9090
  158. },
  159. "logging": {
  160. "log_level": "DEBUG"
  161. }
  162. }
  163. ```
  164. | Section | Description |
  165. | ---------------- | ---------------------------------- |
  166. | inference_server | The inference server configuration |
  167. | mcp_servers | The MCP servers configuration |
  168. | network | uvicorn network configuration |
  169. | logging | The logging configuration |
  170. | api_key | API key for server authentication |
  171. ## Support
  172. If you encounter any issues please open an issue or join the [discord](https://discord.gg/4NVQHqNxSZ).
  173. There is also documentation available [here](/docs/README.md).
  174. ## How does it work
  175. The application sits between the OpenAI API and the inference engine. An incoming request is modified to include tool definitions for all MCP tools available on the MCP servers. The request is then forwarded to the inference engine, which uses the tool definitions to create tool calls. MCP bridge then manage the calls to the tools. The request is then modified to include the tool call results, and is returned to the inference engine again so the LLM can create a response. Finally, the response is returned to the OpenAI API.
  176. ```mermaid
  177. sequenceDiagram
  178. participant OpenWebUI as Open Web UI
  179. participant MCPProxy as MCP Proxy
  180. participant MCPserver as MCP Server
  181. participant InferenceEngine as Inference Engine
  182. OpenWebUI ->> MCPProxy: Request
  183. MCPProxy ->> MCPserver: list tools
  184. MCPserver ->> MCPProxy: list of tools
  185. MCPProxy ->> InferenceEngine: Forward Request
  186. InferenceEngine ->> MCPProxy: Response
  187. MCPProxy ->> MCPserver: call tool
  188. MCPserver ->> MCPProxy: tool response
  189. MCPProxy ->> InferenceEngine: llm uses tool response
  190. InferenceEngine ->> MCPProxy: Response
  191. MCPProxy ->> OpenWebUI: Return Response
  192. ```
  193. ## Contribution Guidelines
  194. Contributions to MCP-Bridge are welcome! To contribute, please follow these steps:
  195. 1. Fork the repository.
  196. 2. Create a new branch for your feature or bug fix.
  197. 3. Make your changes and commit them.
  198. 4. Push your changes to your fork.
  199. 5. Create a pull request to the main repository.
  200. ## License
  201. MCP-Bridge is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.