首页 公告 项目 RSS

⬇️⬇️⬇️ 欢迎关注我的 telegram 频道和 twitter ⬇️⬇️⬇️


联系方式: Twitter Github Email Telegram

mcpo搭建

June 18, 2025 本文有 1125 个字 需要花费 3 分钟阅读

简介

关于什么是mcp,什么是mcpo详细可以看下面

https://docs.openwebui.com/openapi-servers/mcp/

简单来说MCP 是一个管理和存储大模型上下文的标准化协议服务,MCPO 是协调多个 MCP 服务的调度器,两者配合可实现多模型上下文的统一管理与调用。

这里我只说明如何在 Kubernetes 上搭建 mcpo,并让 openwebui 使用。

首先创建deploy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mcpo
  namespace: app
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  selector:
    matchLabels:
      app: mcpo
  template:
    metadata:
      labels:
        app: mcpo
    spec:
      imagePullSecrets:
      - name: regcred
      volumes:
      - name: mcpo-conf
        configMap:
          name: mcpo-conf
      - name: mcpo-data
        persistentVolumeClaim:
          claimName: mcpo-pvc
      containers:
      - name: mcpo
        image: ghcr.io/open-webui/mcpo:latest
        args:
        - --config
        - /app/config.json
        - --api-key 
        - passwd
        ports:
        - containerPort: 8000
        volumeMounts:
        - name: mcpo-conf
          mountPath: /app/config.json
          subPath: config.json
        - name: mcpo-data
          mountPath: /app/data

我们重点要关注的是

        args:
        - --config
        - /app/config.json
        - --api-key 
        - passwd
  • --config 后面配置的是mcp server的配置
  • --api-key 为了安全最好配置一个key,后面配置的是你客户端连接到mcpo的key,比如openwebui链接到mcpo的时候就要用到这个

这里我挂载了两个东西

        - name: mcpo-conf
          mountPath: /app/config.json
          subPath: config.json
        - name: mcpo-data
          mountPath: /app/data

mcpo-conf 就是挂载mcp 配置的地方,mcpo-data是持久化一些数据的地方

创建 service ingress pvc kustomization

下面没什么好说的

创建service

apiVersion: v1
kind: Service
metadata:
  name: mcpo
  namespace: app
spec:
  selector:
    app: mcpo
  ports:
  - port: 8000
    targetPort: 8000
    name: mcpo

创建pvc

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mcpo-pvc
  namespace: app
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

创建ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mcpo-ingress
  namespace: app
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: "mcpo.xxx.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: mcpo
            port:
              number: 8000
  tls:
  - hosts:
    - mcpo.xxx.com
    secretName: xxx-cn-tls

创建kustomization

resources:
- deploy.yaml
- svc.yaml
- ingress.yaml
- pvc.yaml
namespace: app
configMapGenerator:
- name: mcpo-conf
  files:
  - config.json
  options:
    disableNameSuffixHash: true

关注下config.json

config.json定义了你要使用的mcp 服务器和规则,下面是我的配置

{
  "mcpServers": {
    "time": {
      "command": "uvx",
      "args": ["mcp-server-time", "--local-timezone=America/New_York"]
    },
    "fetch": {
      "command": "uvx",
      "args": ["mcp-server-fetch"]
    },
    "mcp-hn": {
      "command": "uvx",
      "args": ["mcp-hn"]
    },
    "openmemory": {
      "command": "npx",
      "args": ["-y","openmemory"],
      "env": {
        "OPENMEMORY_API_KEY": "om-xxxxxxxxxxxxxxxx",
        "CLIENT_NAME": "openmemory"
      }
    },
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp"]
      }
  }
}

说一下我接的几个mcp 服务器

  • time 用来获取时间的
  • fetch 用来获取网页的
  • mcp-hn 获取hacknews内容的
  • context7 这个可以看https://github.com/upstash/context7是用来获取最新的代码文档的
  • openmemory 给AI带来记忆功能,但是云服务有点不可靠,老是挂,具体可以看https://status.mem0.ai/,所以可以使用这个项目自建https://github.com/baryhuang/mcp-openmemory除了openmemory还有supermemory,同样我感觉也不是很可靠

其他的mcp服务器感兴趣的可以看下面

https://github.com/modelcontextprotocol/servers
https://mcpservers.org/
https://mcp.so/
https://github.com/metorial/mcp-containers

配置openwebui

openwebui 有两个地方可以配置,一个是用户里面的设置-> 工具,另外一个是管理员面板里面的设置->工具,值得注意的是如果你是普通用户创建工具的时候向mcpo的请求是前端js发起的,不是openwebui后端,如果你是管理员在管理员面板里面创建工具的时候就是后端去请求了。所以如果连接不上mcpo要注意这个

地址就是mcpo的地址,类似于http://mcpo:8000/timetime就是mcpserver名字

欢迎关注我的博客www.bboy.app

Have Fun