Skip to content

Commit 43c7eda

Browse files
committed
chore: mcp
1 parent d0bb8bf commit 43c7eda

5 files changed

Lines changed: 1057 additions & 1006 deletions

File tree

README.en.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ More examples at - https://t.me/blockmineJs
8888
<em>Interactive panel for working with WebSocket API</em>
8989
</p>
9090

91+
### 🤖 MCP Server (for AI assistants)
92+
- **Built-in** [Model Context Protocol](https://modelcontextprotocol.io/) endpoint at `POST /api/mcp`
93+
- **25 tools**: bot management, plugins, users/groups/permissions, plugin file authoring straight on the host
94+
- **Auth** via Panel API Key (`pk_*`) — same keys used by the WebSocket API
95+
- **Connect from anywhere** — Claude Desktop, Cursor, Cline, Claude Code, and any MCP-compatible client
96+
- **`plugin-author` prompt** — full plugin-development guide served by the MCP itself, AI clients fetch it with a single `prompts/get`
97+
- **npm package [`blockmine-mcp`](https://www.npmjs.com/package/blockmine-mcp)** — thin stdio↔HTTP bridge for clients without native HTTP MCP support
98+
9199
---
92100

93101
## ✨ Quick Start with `npx`
@@ -302,9 +310,72 @@ Automate bot actions on schedule:
302310

303311
---
304312

313+
## 🤖 MCP — drive BlockMine with AI assistants
314+
315+
BlockMine ships a **built-in MCP server** (Model Context Protocol) on `POST /api/mcp`. Any MCP-compatible AI client — Claude Desktop, Cursor, Cline, Claude Code — can manage your bots, author plugins, read settings and logs through a normal chat with the AI.
316+
317+
### What the AI gets through MCP
318+
319+
- **Bots:** `list_bots`, `get_bot_states`, `start_bot`, `stop_bot`, `restart_bot`, `send_message_to_bot`, `get_bot_logs`
320+
- **Plugins:** `get_bot_plugins`, `get_plugin_settings`, `update_plugin_settings`, `enable_disable_plugin`, `install_local_plugin`
321+
- **Plugin authoring on the host:** `create_plugin`, `read_plugin_file`, `write_plugin_file`, `plugin_fs`, `reload_plugin`
322+
- **Management:** `get_bot_users`, `get_user_info`, `get_bot_groups`, `get_bot_permissions`, `get_bot_commands`
323+
- **`plugin-author` prompt** — the full BlockMine plugin-development guide, served by MCP and fetched by the AI with a single `prompts/get`
324+
325+
### Setup
326+
327+
#### 1. Get a Panel API Key
328+
329+
In the BlockMine panel: **Settings → API Keys → Create key**. The key starts with `pk_`.
330+
331+
#### 2a. Through the npm wrapper (recommended — works in any MCP client)
332+
333+
```bash
334+
npx blockmine-mcp setup
335+
```
336+
337+
The wizard asks for your panel URL and token, verifies the connection and writes the right config into Claude Desktop / Claude Code / etc.
338+
339+
Manually for Claude Code:
340+
```bash
341+
claude mcp add blockmine --scope user \
342+
-e BLOCKMINE_URL=http://localhost:3001 \
343+
-e BLOCKMINE_API_TOKEN=pk_your_key \
344+
-- npx -y blockmine-mcp
345+
```
346+
347+
#### 2b. Native HTTP (for clients with built-in HTTP MCP support)
348+
349+
```bash
350+
claude mcp add blockmine --scope user --transport http \
351+
http://localhost:3001/api/mcp \
352+
--header "Authorization: Bearer pk_your_key"
353+
```
354+
355+
Or in `mcp.json` / `claude_desktop_config.json`:
356+
```json
357+
{
358+
"mcpServers": {
359+
"blockmine": {
360+
"type": "http",
361+
"url": "http://localhost:3001/api/mcp",
362+
"headers": { "Authorization": "Bearer pk_your_key" }
363+
}
364+
}
365+
}
366+
```
367+
368+
### Remote hosting
369+
370+
The MCP endpoint comes up together with the panel. If BlockMine runs on a VPS, just use its public URL instead of `localhost:3001`. Auth is per-request via `Authorization: Bearer pk_*` — same keys as the WebSocket API.
371+
372+
More about the npm package: [`blockmineJS/blockmine-mcp`](https://github.com/blockmineJS/blockmine-mcp).
373+
374+
---
375+
305376
## 🧑‍💻 For Developers and Contributors
306377

307-
> **🤖 For AI Agents:** If you are an AI agent that wants to create plugins for BlockMine, read the file [backend/src/ai/plugin-assistant-system-prompt.md](D:\webstormproject\blockmine\backend\src\ai\plugin-assistant-system-prompt.md) for plugin development instructions.
378+
> **🤖 For AI Agents:** If you are an AI agent connected via MCP, you already have the `plugin-author` prompt (call `prompts/get` with that name). Without MCP, see [backend/src/ai/plugin-assistant-system-prompt.md](./backend/src/ai/plugin-assistant-system-prompt.md).
308379
309380
If you want to contribute to the project or run it in development mode.
310381

README.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@
9090
<em>Интерактивная панель для работы с WebSocket API</em>
9191
</p>
9292

93+
### 🤖 MCP Server (для AI-ассистентов)
94+
- **Встроенный** [Model Context Protocol](https://modelcontextprotocol.io/) endpoint на `POST /api/mcp`
95+
- **25 tools**: управление ботами, плагины, пользователи/группы/права, чтение/запись файлов плагина прямо на хосте
96+
- **Авторизация** через Panel API Key (`pk_*`) — те же ключи, что и для WebSocket API
97+
- **Подключение из любого хоста** — Claude Desktop, Cursor, Cline, Claude Code и т.д.
98+
- **`plugin-author` prompt** — полное руководство по разработке плагинов прямо в MCP, AI получает его одним вызовом `prompts/get`
99+
- **npm-пакет [`blockmine-mcp`](https://www.npmjs.com/package/blockmine-mcp)** — тонкий stdio↔HTTP-мост для клиентов которые не умеют HTTP MCP
100+
93101
---
94102

95103
## ✨ Быстрый старт с `npx`
@@ -305,9 +313,72 @@ bot.registerCommand({
305313

306314
---
307315

316+
## 🤖 MCP — управление через AI-ассистентов
317+
318+
BlockMine выставляет **встроенный MCP-сервер** (Model Context Protocol) на `POST /api/mcp`. Это значит, что любой MCP-совместимый AI-клиент — Claude Desktop, Cursor, Cline, Claude Code — может управлять твоими ботами, создавать плагины, читать настройки и логи через обычный диалог с AI.
319+
320+
### Что доступно AI через MCP
321+
322+
- **Боты:** `list_bots`, `get_bot_states`, `start_bot`, `stop_bot`, `restart_bot`, `send_message_to_bot`, `get_bot_logs`
323+
- **Плагины:** `get_bot_plugins`, `get_plugin_settings`, `update_plugin_settings`, `enable_disable_plugin`, `install_local_plugin`
324+
- **Разработка плагинов прямо на хосте:** `create_plugin`, `read_plugin_file`, `write_plugin_file`, `plugin_fs`, `reload_plugin`
325+
- **Управление:** `get_bot_users`, `get_user_info`, `get_bot_groups`, `get_bot_permissions`, `get_bot_commands`
326+
- **Промпт `plugin-author`** — полное руководство по разработке плагинов BlockMine, которое AI получает одной командой `prompts/get`
327+
328+
### Подключение
329+
330+
#### 1. Получить Panel API Key
331+
332+
В панели BlockMine: **Настройки → API ключи → Создать ключ**. Ключ начинается с `pk_`.
333+
334+
#### 2a. Через npm-обёртку (рекомендуется — работает в любом MCP-клиенте)
335+
336+
```bash
337+
npx blockmine-mcp setup
338+
```
339+
340+
Визард сам спросит URL панели и токен, проверит соединение и пропишет нужный конфиг в Claude Desktop / Claude Code / etc.
341+
342+
Вручную для Claude Code:
343+
```bash
344+
claude mcp add blockmine --scope user \
345+
-e BLOCKMINE_URL=http://localhost:3001 \
346+
-e BLOCKMINE_API_TOKEN=pk_ваш_ключ \
347+
-- npx -y blockmine-mcp
348+
```
349+
350+
#### 2b. Напрямую по HTTP (для клиентов с нативной поддержкой HTTP MCP)
351+
352+
```bash
353+
claude mcp add blockmine --scope user --transport http \
354+
http://localhost:3001/api/mcp \
355+
--header "Authorization: Bearer pk_ваш_ключ"
356+
```
357+
358+
Или в `mcp.json`/`claude_desktop_config.json`:
359+
```json
360+
{
361+
"mcpServers": {
362+
"blockmine": {
363+
"type": "http",
364+
"url": "http://localhost:3001/api/mcp",
365+
"headers": { "Authorization": "Bearer pk_ваш_ключ" }
366+
}
367+
}
368+
}
369+
```
370+
371+
### Удалённое подключение
372+
373+
MCP endpoint поднимается вместе с самой панелью. Если BlockMine крутится на VPS — подставь публичный URL вместо `localhost:3001`. Авторизация per-request через `Authorization: Bearer pk_*` — те же ключи, что и для WebSocket API.
374+
375+
Подробнее об npm-пакете: [`blockmineJS/blockmine-mcp`](https://github.com/blockmineJS/blockmine-mcp).
376+
377+
---
378+
308379
## 🧑‍💻 Для разработчиков и контрибьюторов
309380

310-
> **🤖 Для AI агентов:** Если вы AI агент, который хочет создавать плагины для BlockMine, прочитайте файл [backend/src/ai/plugin-assistant-system-prompt.md](D:\webstormproject\blockmine\backend\src\ai\plugin-assistant-system-prompt.md) для получения инструкций по разработке плагинов.
381+
> **🤖 Для AI агентов:** Если вы AI агент через MCP, у вас уже есть промпт `plugin-author` (вызовите `prompts/get` с этим именем). Если нет MCP — см. [backend/src/ai/plugin-assistant-system-prompt.md](./backend/src/ai/plugin-assistant-system-prompt.md).
311382
312383
Если вы хотите внести свой вклад в проект или запустить его в режиме разработки.
313384

0 commit comments

Comments
 (0)