Skip to content

MCP Server

SafeLLM includes a built-in MCP stdio server with a plugin architecture. It exposes core security capabilities as tools that can be called from MCP clients.

  • Reuse SafeLLM detection stack outside HTTP gateway path.
  • Keep one policy engine for APISIX traffic and agent workflows.
  • Extend capabilities via plugin-style MCP tools.
  • safellm.guard_decide
    • Runs full input pipeline (cache -> keywords -> PII -> AI guard when enabled).
    • Inputs: prompt, uri, optional request_id.
  • safellm.pii_scan
    • Runs PII layer only.
    • Inputs: text, optional request_id.
  • safellm.dlp_scan
    • Runs output DLP scanner.
    • Inputs: text, optional mode (block|anonymize|log).

From safellm-oss:

Terminal window
source .venv/bin/activate
python -m sidecar.mcp

From safellm-enterprise/safellm:

Terminal window
source .venv/bin/activate
python -m sidecar.mcp
  • initialize
  • ping
  • tools/list
  • tools/call
Terminal window
printf '%s\n%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' \
'{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
| python -m sidecar.mcp

Core plugin API lives in:

  • sidecar/mcp/base.py
  • sidecar/mcp/registry.py

Built-in plugin implementations:

  • sidecar/mcp/plugins/security.py

Server bootstrap and stdio runtime:

  • sidecar/mcp/server.py
  • sidecar/mcp/__main__.py

To add custom tools, implement MCPToolPlugin, register it in MCPToolRegistry, and expose it during server bootstrap.

  • Docs: /deployments/mcp-reference/
  • Repo folder: safellm-oss/examples/mcp-reference/