Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"mcp"
],
"command": "mem-cli"
},
"rfc-cli": {
"args": [
"mcp"
],
"command": "rfc-cli"
}
}
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.7]

### Added
- `--version` and `-V` flags for displaying the installed `rfc-cli` version.

## [0.1.6]

### Added
- Read-only MCP server via `rfc-cli mcp` over stdio with RFC tools for listing,
viewing, checking status, and inspecting dependencies.
- Automatic `rfc-cli` MCP server configuration in `.mcp.json`, preserving other
configured servers.

## [0.1.5]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rfc-cli"
version = "0.1.5"
version = "0.1.7"
edition = "2021"

[dependencies]
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ test: ## Run all tests
clean: ## Remove build artifacts
cargo clean

install: release ## Install binary to ~/.cargo
install: release ## Install binary to ~/.local/bin
install -Dm755 target/release/rfc-cli ~/.local/bin/rfc-cli
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ For convenience, you can copy it to your PATH:
cp target/release/rfc-cli ~/.local/bin/
```

Check the installed version:

```sh
rfc-cli --version
# rfc-cli 0.1.7
```

## Shell Completion

Generate and install completion scripts:
Expand Down Expand Up @@ -282,6 +289,36 @@ RFC-0005 (logging):
Summary: 3 error(s), 1 warning(s) across 2 RFC(s).
```

### `mcp` — MCP server

Runs a read-only Model Context Protocol server over `stdio`. The server supports
JSON-RPC 2.0 and exposes RFC tools for MCP clients such as Copilot or Claude
Desktop:

- `list_rfcs`
- `view_rfc`
- `get_rfc_status`
- `get_rfc_dependencies`
- `ping`

```sh
rfc-cli mcp
```

`rfc-cli init` adds the following entry to `.mcp.json` while preserving other
configured servers:

```json
{
"mcpServers": {
"rfc-cli": {
"command": "rfc-cli",
"args": ["mcp"]
}
}
}
```

### `reindex` — rebuild index

Completely rebuilds `.index.json` from the RFC files on disk. Use when the index is corrupted or out of sync.
Expand All @@ -307,6 +344,7 @@ rfc-cli reindex
| `deps <N> [--reverse]` | Dependency tree |
| `check [N]` | Format validation |
| `doctor [--stale-days N]` | Health diagnostics |
| `mcp` | Run read-only MCP server over stdio |
| `reindex` | Rebuild index |

## RFC Process
Expand Down Expand Up @@ -407,6 +445,7 @@ src/
│ ├── deps.rs # rfc-cli deps
│ ├── check.rs # rfc-cli check
│ ├── doctor.rs # rfc-cli doctor
│ ├── mcp.rs # rfc-cli mcp
│ └── reindex.rs # rfc-cli reindex
└── rfclib/
├── mod.rs
Expand All @@ -424,7 +463,8 @@ docs/rfcs/
├── 0003.md # RFC-0003: implement list, view, status, edit commands
├── 0004.md # RFC-0004: implement set, check, reindex commands
├── 0005.md # RFC-0005: implement link, unlink, deps commands
└── 0006.md # RFC-0006: implement doctor command
├── 0006.md # RFC-0006: implement doctor command
└── 0010.md # RFC-0010: MCP server for RFC tools
```

## License
Expand Down
42 changes: 41 additions & 1 deletion README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ cargo build --release
cp target/release/rfc-cli ~/.local/bin/
```

Проверить установленную версию:

```sh
rfc-cli --version
# rfc-cli 0.1.7
```

## Быстрый старт

```sh
Expand Down Expand Up @@ -274,6 +281,36 @@ RFC-0005 (logging):
Summary: 3 error(s), 1 warning(s) across 2 RFC(s).
```

### `mcp` — MCP-сервер

Запускает read-only Model Context Protocol сервер через `stdio`. Сервер
поддерживает JSON-RPC 2.0 и предоставляет MCP-клиентам (например, Copilot или
Claude Desktop) инструменты:

- `list_rfcs`
- `view_rfc`
- `get_rfc_status`
- `get_rfc_dependencies`
- `ping`

```sh
rfc-cli mcp
```

Команда `rfc-cli init` добавляет запись `rfc-cli` в `.mcp.json`, сохраняя другие
настроенные серверы:

```json
{
"mcpServers": {
"rfc-cli": {
"command": "rfc-cli",
"args": ["mcp"]
}
}
}
```

### `reindex` — пересборка индекса

Полностью перестраивает `.index.json` из RFC-файлов на диске. Используйте, если индекс повреждён или рассинхронизирован.
Expand All @@ -299,6 +336,7 @@ rfc-cli reindex
| `deps <N> [--reverse]` | Дерево зависимостей |
| `check [N]` | Валидация формата |
| `doctor [--stale-days N]` | Диагностика здоровья |
| `mcp` | Read-only MCP-сервер через stdio |
| `reindex` | Пересборка индекса |

## RFC-процесс
Expand Down Expand Up @@ -399,6 +437,7 @@ src/
│ ├── deps.rs # rfc-cli deps
│ ├── check.rs # rfc-cli check
│ ├── doctor.rs # rfc-cli doctor
│ ├── mcp.rs # rfc-cli mcp
│ └── reindex.rs # rfc-cli reindex
└── rfclib/
├── mod.rs
Expand All @@ -416,7 +455,8 @@ docs/rfcs/
├── 0003.md # RFC-0003: реализация команд list, view, status и edit
├── 0004.md # RFC-0004: реализация команд set, check и reindex
├── 0005.md # RFC-0005: реализация команд link, unlink и deps
└── 0006.md # RFC-0006: реализация команды doctor
├── 0006.md # RFC-0006: реализация команды doctor
└── 0010.md # RFC-0010: MCP-сервер для инструментов RFC
```

## Лицензия
Expand Down
31 changes: 30 additions & 1 deletion docs/rfcs/.index.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,37 @@
"src/main.rs",
"tests/integration_test.rs"
],
"mtime": "1786338690",
"mtime": "1786338706",
"content_hash": "57258823363c37be4463a51b3fe9b4dc23794f457c3f4c80392bc227335574d7"
},
{
"number": "0010",
"title": "RFC-0010: MCP-сервер для инструментов RFC",
"status": "implemented",
"dependencies": [],
"superseded_by": null,
"links": [
"src/commands/mcp.rs",
"src/commands/init.rs",
"src/cli.rs",
"src/main.rs",
"tests/integration_test.rs"
],
"mtime": "1789459989",
"content_hash": "5ed22f940a64026b804fc74469b6608298628c8d0f26acbb97863b54a8dcdfea"
},
{
"number": "0011",
"title": "RFC-0011: вывод версии CLI",
"status": "implemented",
"dependencies": [],
"superseded_by": null,
"links": [
"src/cli.rs",
"tests/integration_test.rs"
],
"mtime": "1789460268",
"content_hash": "311a7361030a9843a64bb74332cc1a816896dbb1e70add77a5e992ec7a4fce75"
}
]
}
121 changes: 121 additions & 0 deletions docs/rfcs/0010.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
title: "RFC-0010: MCP-сервер для инструментов RFC"
status: implemented
dependencies: []
superseded_by: null
links:
- src/commands/mcp.rs
- src/commands/init.rs
- src/cli.rs
- src/main.rs
- tests/integration_test.rs
---

## Problem

Сейчас `rfc-cli` доступен AI-клиентам только через запуск shell-команд и
разбор текстового вывода. Это требует от каждого клиента знать CLI-синтаксис и
формат таблиц, а также не даёт стандартного интерфейса Model Context Protocol.

## Goal

Добавить подкоманду `rfc-cli mcp`, которая предоставляет read-only операции с
RFC как MCP tools через локальный `stdio`-транспорт. Существующий CLI остаётся
основным пользовательским интерфейсом.

## Requirements

1. Команда `rfc-cli mcp` запускает MCP-сервер через `stdio`.
2. Сервер поддерживает JSON-RPC 2.0 и принимает как newline-delimited JSON,
так и сообщения с заголовком `Content-Length`.
3. Сервер не пишет обычные логи в stdout, чтобы не загрязнять MCP-транспорт.
4. Сервер реализует MCP lifecycle:
- `initialize`;
- `notifications/initialized`;
- `ping`;
- `tools/list`;
- `tools/call`.
5. В первой версии доступны read-only tools:
- `ping`;
- `list_rfcs` с необязательным фильтром `status`;
- `view_rfc` с аргументом `number`;
- `get_rfc_status` с аргументом `number`;
- `get_rfc_dependencies` с аргументами `number` и `reverse`.
6. Результаты tools возвращаются как JSON-объекты в `structuredContent` и как
JSON-текст в `content`.
7. Некорректные аргументы возвращают JSON-RPC ошибку `-32602`, неизвестный
метод — `-32601`, внутренние ошибки — `-32603`.
8. MCP tools используют те же RFC-файлы и индекс, что и обычные команды, но
read-only операции не должны изменять `.index.json`.
9. `rfc-cli init` создаёт или обновляет запись `rfc-cli` в `.mcp.json`,
сохраняя другие MCP-серверы:

```json
{
"mcpServers": {
"rfc-cli": {
"command": "rfc-cli",
"args": ["mcp"]
}
}
}
```

## Design

### CLI

Добавить подкоманду:

```rust
/// Run MCP server over stdio
Mcp
```

`main.rs` передаёт в MCP-сервер уже определённый `project_root`, поэтому MCP и
CLI используют одинаковое разрешение `RFC_HOME`.

### MCP frontend

Новый модуль `src/commands/mcp.rs` содержит:

- stdio reader/writer;
- JSON-RPC dispatch;
- MCP tool schemas;
- преобразование ошибок в JSON-RPC;
- read-only обработчики tools.

Обработчики напрямую используют `rfclib::index` и `rfclib::rfc`, не запускают
другие CLI-команды и не парсят их человекочитаемый stdout.

### MCP configuration

`init` читает существующий `.mcp.json`, проверяет, что корень документа и
`mcpServers` являются JSON-объектами, добавляет запись `rfc-cli` и сохраняет
остальные записи без изменений. Повторный запуск идемпотентен.

## Alternatives

1. **Оставить только shell-вызовы CLI**
Не требует изменений, но сохраняет привязку клиентов к текстовому выводу.

2. **Добавить MCP через отдельный прокси-проект**
Усложняет установку и может привести к расхождению поведения с `rfc-cli`.

3. **Сразу добавить изменяющие tools**
Увеличивает риск случайной модификации RFC через AI-клиента. Изменяющие
операции можно добавить отдельным RFC после подтверждения схемы разрешений.

## Voting

Открытые вопросы для review:

1. Достаточен ли read-only набор tools для первой версии?
2. Нужны ли resources в следующей версии?
3. Нужны ли изменяющие tools после отдельного согласования безопасности?

## Migration

Миграция RFC-файлов и индекса не требуется. После обновления достаточно
запустить `rfc-cli init`, чтобы добавить запись сервера в `.mcp.json`. Старые
конфигурации MCP и существующие CLI-команды не изменяются.
Loading
Loading