# Базы знаний

> Инструменты раздела «Базы знаний»: 16

Подключение: `https://mcp.legalstack.ru/mcp/knowledge` или в составе общего подключения `https://mcp.legalstack.ru/mcp`.

## Добавить источник в базу знаний

`add_knowledge_source` · изменяет данные

Описание для модели: Add a text, a web page or a file to a knowledge base. Pass exactly one of text, url and path. A file is a PDF, DOCX, XLSX, TXT, MD or CSV from the working folder. Indexing goes on in the background, wait for it with get_knowledge_source.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `knowledge_base_id` | string | да | Knowledge base id. Длина: 1–64. |
| `name` | string | нет | Name of the source, required for a text. Длина: 1–255. |
| `text` | string | нет | Text to index. Длина: 1–2000000. |
| `url` | string | нет | HTTPS address of a page to index. Длина: 8–2000. |
| `path` | string | нет | Path of a file in the working folder. Длина: 1–1000. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "knowledge_base_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Knowledge base id"
    },
    "name": {
      "description": "Name of the source, required for a text",
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "text": {
      "description": "Text to index",
      "type": "string",
      "minLength": 1,
      "maxLength": 2000000
    },
    "url": {
      "description": "HTTPS address of a page to index",
      "type": "string",
      "minLength": 8,
      "maxLength": 2000
    },
    "path": {
      "description": "Path of a file in the working folder",
      "type": "string",
      "minLength": 1,
      "maxLength": 1000
    }
  },
  "required": [
    "knowledge_base_id"
  ],
  "additionalProperties": false
}
```

</details>

## Создать базу знаний

`create_knowledge_base` · изменяет данные

Описание для модели: Create a knowledge base of the team. Sources are added afterwards with add_knowledge_source.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `name` | string | да | Name of the base. Длина: 1–255. |
| `description` | string | нет | What the base keeps and what for. Длина: до 2000. |
| `folder_id` | string | нет | Folder of the base, the root by default. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "description": "Name of the base"
    },
    "description": {
      "description": "What the base keeps and what for",
      "type": "string",
      "maxLength": 2000
    },
    "folder_id": {
      "description": "Folder of the base, the root by default",
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    }
  },
  "required": [
    "name"
  ],
  "additionalProperties": false
}
```

</details>

## Удалить базу знаний

`delete_knowledge_base` · необратимое действие

Описание для модели: Delete a knowledge base with all its sources. Cannot be restored.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `knowledge_base_id` | string | да | Knowledge base id. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "knowledge_base_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Knowledge base id"
    }
  },
  "required": [
    "knowledge_base_id"
  ],
  "additionalProperties": false
}
```

</details>

## Удалить источник из базы знаний

`delete_knowledge_source` · необратимое действие

Описание для модели: Delete a source from a knowledge base. Cannot be restored.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `source_id` | string | да | Source id. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Source id"
    }
  },
  "required": [
    "source_id"
  ],
  "additionalProperties": false
}
```

</details>

## Оглавление источника

`get_knowledge_outline` · только чтение

Описание для модели: Get the outline of a source: chapters, articles and clauses. Use to find the needed part of a long document before read_knowledge_source.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `source_id` | string | да | Source id. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Source id"
    }
  },
  "required": [
    "source_id"
  ],
  "additionalProperties": false
}
```

</details>

## Карточка источника

`get_knowledge_source` · только чтение

Описание для модели: Get a source or a legal act with details and indexing status. With wait_seconds waits until indexing of a fresh source ends.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `source_id` | string | да | Source id. Длина: 1–64. |
| `wait_seconds` | integer | нет | Seconds to wait for indexing to end, does not wait by default. По умолчанию: `0`. Диапазон: 0–240. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Source id"
    },
    "wait_seconds": {
      "default": 0,
      "description": "Seconds to wait for indexing to end, does not wait by default",
      "type": "integer",
      "minimum": 0,
      "maximum": 240
    }
  },
  "required": [
    "source_id"
  ],
  "additionalProperties": false
}
```

</details>

## Кто ссылается на источник

`list_knowledge_backlinks` · только чтение

Описание для модели: List documents that refer to a source or to one part of it.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `source_id` | string | да | Source id. Длина: 1–64. |
| `part_id` | string | нет | Narrow to references to this part. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Source id"
    },
    "part_id": {
      "description": "Narrow to references to this part",
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    }
  },
  "required": [
    "source_id"
  ],
  "additionalProperties": false
}
```

</details>

## Базы знаний команды

`list_knowledge_bases` · только чтение

Описание для модели: List knowledge bases of the team. A base is a collection of sources. writable tells whether the current user may add to the base.

**Параметры**

Параметров нет.

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {},
  "additionalProperties": false
}
```

</details>

## Ссылки источника на акты

`list_knowledge_citations` · только чтение

Описание для модели: List references from a source to laws and court acts.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `source_id` | string | да | Source id. Длина: 1–64. |
| `from_number` | integer | нет | Number of the first part, with to_number. Диапазон: 0–9007199254740991. |
| `to_number` | integer | нет | Number of the last part, with from_number. Диапазон: 0–9007199254740991. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Source id"
    },
    "from_number": {
      "description": "Number of the first part, with to_number",
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "to_number": {
      "description": "Number of the last part, with from_number",
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "source_id"
  ],
  "additionalProperties": false
}
```

</details>

## Источники базы знаний

`list_knowledge_sources` · только чтение

Описание для модели: List sources of a knowledge base with indexing status.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `knowledge_base_id` | string | да | Knowledge base id. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "knowledge_base_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Knowledge base id"
    }
  },
  "required": [
    "knowledge_base_id"
  ],
  "additionalProperties": false
}
```

</details>

## Правовая база платформы

`list_legal_acts` · только чтение

Описание для модели: List laws and court acts of the legal base of the platform. Gives ids of acts for reading, exact links and narrowing search_knowledge.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `kind` | string | нет | Kind of the act. Значения: `Конституция`, `Международный акт`, `Федеральный конституционный закон`, `Кодекс`, `Федеральный закон`, `Акт Президента`, `Акт Правительства`, `Ведомственный акт`, `Региональный акт`, `Муниципальный акт`, `Постановление Пленума ВС`, `Обзор практики ВС`, `Определение ВС`, `Постановление КС`, `Акт арбитражного суда`, `Акт суда общей юрисдикции`, `Договор`, `Справочный материал`, `Комментарий`, `Не определён`. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "Конституция",
        "Международный акт",
        "Федеральный конституционный закон",
        "Кодекс",
        "Федеральный закон",
        "Акт Президента",
        "Акт Правительства",
        "Ведомственный акт",
        "Региональный акт",
        "Муниципальный акт",
        "Постановление Пленума ВС",
        "Обзор практики ВС",
        "Определение ВС",
        "Постановление КС",
        "Акт арбитражного суда",
        "Акт суда общей юрисдикции",
        "Договор",
        "Справочный материал",
        "Комментарий",
        "Не определён"
      ],
      "description": "Kind of the act"
    }
  },
  "additionalProperties": false
}
```

</details>

## Прочитать источник

`read_knowledge_source` · только чтение

Описание для модели: Read the text of a source in order or one part of it. With part_id returns that part in full for exact quoting, otherwise parts in order from the given number. Cite a norm as a markdown link whose address is the link of the result, the link stays valid when the base is updated.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `source_id` | string | да | Source id. Длина: 1–64. |
| `part_id` | string | нет | Part to read in full, from search or the outline. Длина: 1–64. |
| `from_number` | integer | нет | Number of the first part to read. По умолчанию: `0`. Диапазон: 0–9007199254740991. |
| `limit` | integer | нет | Maximum number of items to return, 10 by default. По умолчанию: `10`. Диапазон: 1–50. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Source id"
    },
    "part_id": {
      "description": "Part to read in full, from search or the outline",
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "from_number": {
      "default": 0,
      "description": "Number of the first part to read",
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "limit": {
      "default": 10,
      "description": "Maximum number of items to return, 10 by default",
      "type": "integer",
      "minimum": 1,
      "maximum": 50
    }
  },
  "required": [
    "source_id"
  ],
  "additionalProperties": false
}
```

</details>

## Переиндексировать источник

`reindex_knowledge_source` · изменяет данные

Описание для модели: Index a source of a knowledge base again after a failure. Indexing goes on in the background, wait for it with get_knowledge_source.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `source_id` | string | да | Source id. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "source_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Source id"
    }
  },
  "required": [
    "source_id"
  ],
  "additionalProperties": false
}
```

</details>

## Запомнить для команды

`save_knowledge_note` · изменяет данные

Описание для модели: Save a note to a knowledge base shared with colleagues. For notes the user wants colleagues to see, a note only for the user goes to the own memory of the agent. Without knowledge_base_id the only writable base is used, with several writable bases ask the user which one.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `title` | string | да | Short name of the note. Длина: 1–255. |
| `note` | string | да | Text of the note in the words of the user. Длина: 1–20000. |
| `knowledge_base_id` | string | нет | Writable base from list_knowledge_bases. Длина: 1–64. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "description": "Short name of the note"
    },
    "note": {
      "type": "string",
      "minLength": 1,
      "maxLength": 20000,
      "description": "Text of the note in the words of the user"
    },
    "knowledge_base_id": {
      "description": "Writable base from list_knowledge_bases",
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    }
  },
  "required": [
    "title",
    "note"
  ],
  "additionalProperties": false
}
```

</details>

## Поиск по базам знаний

`search_knowledge` · только чтение

Описание для модели: Search laws, court practice and team documents by meaning. Use for questions about law and the content of documents. A cut text is read in full with read_knowledge_source. Cite a norm as a markdown link whose address is the link of the result, the link stays valid when the base is updated.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `query` | string | да | Question or phrase in natural language. Длина: 1–2000. |
| `scope` | string | нет | Where to search, everywhere by default. Значения: `Везде`, `Базы команды`, `Правовая база`. |
| `knowledge_base_ids` | массив string | нет | Bases of the team to search. Элементов: до 50. |
| `legal_act_ids` | массив string | нет | Acts from list_legal_acts to search. Элементов: до 50. |
| `limit` | integer | нет | Maximum number of items to return, 10 by default. По умолчанию: `10`. Диапазон: 1–50. |
| `graph_depth` | integer | нет | How far to follow links between documents. По умолчанию: `1`. Диапазон: 0–3. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000,
      "description": "Question or phrase in natural language"
    },
    "scope": {
      "type": "string",
      "enum": [
        "Везде",
        "Базы команды",
        "Правовая база"
      ],
      "description": "Where to search, everywhere by default"
    },
    "knowledge_base_ids": {
      "description": "Bases of the team to search",
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Knowledge base id"
      }
    },
    "legal_act_ids": {
      "description": "Acts from list_legal_acts to search",
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Legal act id"
      }
    },
    "limit": {
      "default": 10,
      "description": "Maximum number of items to return, 10 by default",
      "type": "integer",
      "minimum": 1,
      "maximum": 50
    },
    "graph_depth": {
      "default": 1,
      "description": "How far to follow links between documents",
      "type": "integer",
      "minimum": 0,
      "maximum": 3
    }
  },
  "required": [
    "query"
  ],
  "additionalProperties": false
}
```

</details>

## Изменить базу знаний

`update_knowledge_base` · изменяет данные

Описание для модели: Rename a knowledge base or change its description.

**Параметры**

| Параметр | Тип | Обязательный | Описание |
| --- | --- | --- | --- |
| `knowledge_base_id` | string | да | Knowledge base id. Длина: 1–64. |
| `name` | string | нет | New name. Длина: 1–255. |
| `description` | string | нет | New description, an empty text removes it. Длина: до 2000. |

<details>
<summary>JSON Schema параметров</summary>

```json
{
  "type": "object",
  "properties": {
    "knowledge_base_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Knowledge base id"
    },
    "name": {
      "description": "New name",
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "description": {
      "description": "New description, an empty text removes it",
      "type": "string",
      "maxLength": 2000
    }
  },
  "required": [
    "knowledge_base_id"
  ],
  "additionalProperties": false
}
```

</details>
