Skip to main content
Glama
North-CS

maxkb-knowledge-mcp

by North-CS

MaxKB Knowledge Base Retrieval MCP

An MCP service based on the MaxKB Admin API that retrieves knowledge base segments by user question. Supports vector retrieval, hybrid retrieval, and full-text retrieval. Default Top K is 10, retrieval mode is vector retrieval.

Served over Streamable HTTP by default:

  • MCP endpoint: http://<host>:8000/mcp

  • Health check: http://<host>:8000/health

Capabilities

Tool

Purpose

search_knowledge

Retrieve relevant segments by question

list_knowledge_bases

List knowledge bases

get_knowledge_base

View a single knowledge base

list_documents

List knowledge base documents

list_workspaces

List workspaces

search_mode (uses environment variable when not specified by the tool, defaults to vector retrieval):

  • 向量 / 向量检索 / embedding

  • 混合 / 混合检索 / blend

  • 全量 / 全量检索 / keywords

  • auto: hybrid retrieval → vector retrieval → full-text retrieval, until hits are found

When knowledge_ids is not specified, retrieval is performed across all knowledge bases in the current workspace that have a vector model configured.

Related MCP server: mcp-business-bot

Environment Variables

Copy the example file and modify it according to your actual environment:

cp .env.example .env

Variable

Default

Description

MAXKB_BASE_URL

None

MaxKB address, e.g. https://host:2801 (required)

MAXKB_API_KEY

None

User API Key; can be omitted in HTTP mode, prefers client headers.Authorization

MAXKB_WORKSPACE_ID

default

Default workspace

MAXKB_TOP_K

10

Number of results returned, range 1-100

MAXKB_SEARCH_MODE

向量

向量 / 混合 / 全量

MAXKB_VERIFY_SSL

true

Set to false when certificate validation fails

MAXKB_TIMEOUT

30

Request timeout in seconds

MCP_TRANSPORT

http

http (streamable-http) / stdio / sse

MCP_HOST

0.0.0.0

HTTP listen address

MCP_PORT

8000

HTTP port

MAXKB_LOG_DIR

logs

Local log directory

MAXKB_LOG_RETENTION_DAYS

7

Log retention days, automatically deleted upon expiry

If top_n or search_mode is passed in a single search_knowledge call, it overrides the server-side defaults.

Local Startup

Requires Python 3.10+ and uv.

cp .env.example .env
uv sync
uv run maxkb-mcp

After startup:

  • MCP: http://127.0.0.1:8000/mcp

  • Health check: http://127.0.0.1:8000/health

  • Log file: logs/mcp.log (rotated daily, retained for 7 days by default)

Client integration example:

{
  "mcpServers": {
    "maxkb-knowledge": {
      "transport": "streamable_http",
      "url": "http://127.0.0.1:8000/mcp",
      "headers": {
        "Authorization": "你的 MaxKB API Key"
      },
      "disabled": false
    }
  }
}

Authorization can be either the raw Key or Bearer <key>.

For stdio mode:

MCP_TRANSPORT=stdio uv run maxkb-mcp

Docker Image Build

Requires Docker 20.10+.

docker build -t maxkb-mcp:latest .

For networks in China, it is recommended to specify a PyPI mirror:

docker build \
  --build-arg PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
  -t maxkb-mcp:latest .

Push to an image registry (optional):

docker tag maxkb-mcp:latest <registry>/<namespace>/maxkb-mcp:0.1.0
docker push <registry>/<namespace>/maxkb-mcp:0.1.0

Docker Deployment

docker-compose.yml does not build the image; it only starts with an existing image. Complete a local build or pull the image from a registry before deployment.

cp .env.example .env
docker-compose up -d
docker-compose logs -f maxkb-mcp

When using a remote image:

MAXKB_MCP_IMAGE=<registry>/<namespace>/maxkb-mcp:0.1.0 docker-compose up -d

After startup:

  • MCP: http://<host>:8000/mcp

  • Health check: http://<host>:8000/health

  • Log directory: host ./logs (container /app/logs)

After HTTPS reverse proxying, change the client url to https://your-domain/mcp.

If MaxKB is deployed on the host machine, set MAXKB_BASE_URL to http://host.docker.internal:<port>.

To stop the service:

docker-compose down

Logs

All HTTP requests and MCP tool calls are written to local logs, with Authorization redacted.

  • File: {MAXKB_LOG_DIR}/mcp.log, rotated daily to mcp.log.YYYY-MM-DD

  • Expired files are cleaned once at startup, then every 6 hours

  • Logs older than MAXKB_LOG_RETENTION_DAYS (default 7 days) are deleted

FAQ

  • No API Key provided: Pass the MaxKB user Key in the client headers.Authorization, or configure MAXKB_API_KEY in .env

  • Slow build or timeout: Add --build-arg PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple when building

  • Container cannot reach MaxKB: Check MAXKB_BASE_URL, the network, and whether host.docker.internal is needed

  • Certificate validation failure: Set MAXKB_VERIFY_SSL=false

Related MCP Connectors

Related MCP Servers