#1664: Connecting Swarmica features to LLM using MCP
Отредактирована: сегодняSymptoms
- Can Swarmica be connected as an MCP server?
- Is it possible to teach our AI model (LLM) to work with Swarmica?
Solution
Yes, Swarmica is built according to the API-first approach, so almost all operations that can be performed through the graphical interface can be delegated to AI models that can work with MCP tools.
For your convenience, we provide an official MCP server that makes all operations available via the MCP protocol, except for deleting entities.
To use the official MCP server, follow these steps:
- Log in to the server where Swarmica is installed under a
rootaccount and go to the folder where the software is installed:
cd /root/swarmica
- In the
/root/swarmica/.envfile, make sure that there is a variable:
SW_MCP_VERSION=main
- Create a backup copy of the
/root/swarmica/docker-compose.ymlfile:
cp docker-compose.yml{,.backup}
- Using a text editor, open this file and add mcp to the services section:
mcp:
image: reg.gl.swd.im/swarmica/mcp:${SW_MCP_VERSION}
restart: always
depends_on:
- django
env_file:
- .env
labels:
- "traefik.enable=true"
- "traefik.http.services.mcp.loadbalancer.server.port=8001"
- "traefik.http.routers.mcp-router.rule=Host(`${SW_HOSTNAME}`)&&PathPrefix(`/mcp`)"
- "traefik.http.routers.mcp-router.priority=20"
- "traefik.http.routers.mcp-router.entrypoints=web-secure"
- "traefik.http.routers.mcp-router.middlewares=secure-headers,compression"
- "traefik.http.routers.mcp-router.service=mcp"
- "traefik.http.routers.mcp-router.tls.certresolver=letsencrypt"
If you are using an installation behind a load balancer that terminates the HTTPS connection, use the following settings:
mcp:
image: reg.gl.swd.im/swarmica/mcp:${SW_MCP_VERSION}
restart: always
depends_on:
- django
env_file:
- .env
labels:
- "traefik.enable=true"
- "traefik.http.services.mcp.loadbalancer.server.port=8001"
- "traefik.http.routers.mcp-router.rule=Host(`${SW_HOSTNAME}`)&&PathPrefix(`/mcp`)"
- "traefik.http.routers.mcp-router.priority=20"
- "traefik.http.routers.mcp-router.entrypoints=web"
- "traefik.http.routers.mcp-router.middlewares=compression"
- "traefik.http.routers.mcp-router.service=mcp"
- Download the container images and start the service:
docker compose pull
docker compose up -d
Now the MCP toolkit for connecting to your LLM will be available at https://your_swarmica_address/mcp.
Connecting Swarmica MCP to LLM
This MCP can be connected to AI that support connecting external tools via the MCP protocol.
To use the available APIs with the desired level of privileges, you must create an API token in the Settings > Integrations > API and Integrations > + Create New section:
- For all operations — with the "Admin" role
- For all operations, except for performing settings — with the "Manager" role
- For operations at the "Support Agent" level — with the "Agent" role
- For read-only operations — with the "Employee" role
Instructions for various AI tools:
- Connecting Swarmica MCP to Claude
- Connecting Swarmica MCP to Yandex GPT
- Connecting Swarmica MCP to Deepseek
- Connecting Swarmica MCP to ChatGPT
What is MCP?
MCP (Model Context Protocol) is a context expansion protocol for large language AI models (LLM) that helps them "learn" additional operations.