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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PropertyGroup Condition="$(MSBuildProjectName.StartsWith('CtxUi.Extensions'))">
<Authors>Echways</Authors>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Echways/ctx-ui/blob/main/docs/extensions.md</PackageProjectUrl>
<PackageProjectUrl>https://github.com/Echways/ctx-ui/blob/main/docs/en/extensions.md</PackageProjectUrl>
<PackageTags>ctx-ui;mcp;panel;extensions;blazor</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/Echways/ctx-ui</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="2.3.0" />
<PackageVersion Include="ModelContextProtocol.Core" Version="2.3.0" />
<PackageVersion Include="NJsonSchema" Version="11.6.1" />
<PackageVersion Include="Enfilade" Version="0.1.1" />
<PackageVersion Include="Enfilade" Version="0.2.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="5.6.0" />
<PackageVersion Include="MudBlazor" Version="9.12.0" />
<PackageVersion Include="MessageFormat" Version="8.0.0" />
Expand Down
309 changes: 56 additions & 253 deletions README.md

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<div align="center">

# ctx-ui

**Шлюз доступа к MCP-серверам.**
Один адрес перед удалённым MCP-сервером и свой токен, срок действия и лимиты для каждого клиента. Всё управляется из панели, CLI и REST API.

[English](README.md) · **Русский**

[![Release](https://img.shields.io/github/v/release/Echways/ctx-ui)](https://github.com/Echways/ctx-ui/releases/latest)
[![CI](https://github.com/Echways/ctx-ui/actions/workflows/ci.yml/badge.svg)](https://github.com/Echways/ctx-ui/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/license-GPL--3.0-blue)](LICENSE)

</div>

## Зачем ctx-ui

MCP-сервер обычно — один адрес и один общий секрет. ctx-ui ставит между этим сервером и людьми прослойку, чтобы доступ можно было выдавать, ограничивать и отзывать для каждого клиента отдельно.

- **Один адрес на сервер.** Inbound — это `/mcp/<slug>`, за которым стоит удалённый MCP-сервер со streamable HTTP. Адрес upstream и его секретные заголовки не доходят до клиента.
- **Токен на клиента.** У каждого клиента свой токен, срок действия и набор inbound'ов. Перевыпустить или отключить его можно, не трогая остальных.
- **Лимиты, которые ведут себя прилично.** Частота запросов, одновременные запросы и квота вызовов инструментов за период. Исчерпанная квота приходит результатом инструмента, и модель объясняет её человеку, а соединение не рвётся.
- **Вход в браузере.** Claude, ChatGPT и Cursor подключаются по одному адресу сервера. Войти можно ключом клиента, через Google, GitHub или любого провайдера OpenID Connect. По умолчанию выключено.
- **Панель, которая показывает происходящее.** Обзор, метрики с перцентилями времени ответа, журнал вызовов, устройства, ключи API. Живёт по случайному секретному пути.
- **Всё автоматизируется.** CLI и REST API со Swagger UI покрывают всю панель. Изменения доходят до работающего шлюза за секунду.
- **Расширяется.** Расширения панели добавляют разделы, блоки и действия из zip-архива, без пересборки ctx-ui.
- **Серверы, не выходя из панели.** Необязательный конструктор собирает FastMCP-серверы из форм или кода, запускает каждый в изолированном Docker-контейнере и подключает как inbound.
- **Просто запускать.** Один бинарник с systemd или Docker с Caddy на Linux x86_64 и aarch64. Английский и русский везде.

## Установка

Бинарник и systemd:

```bash
curl -fsSL https://github.com/Echways/ctx-ui/releases/latest/download/install.sh | sudo bash
```

Нужен Linux x86_64 или aarch64 с systemd. Сервис говорит по обычному HTTP: для TLS поставьте перед ним Caddy или nginx. Docker с Caddy, обновление, удаление и резервная копия описаны в разделе [Установка](docs/ru/install.md).

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

```bash
sudo ctx-ui admin add admin
sudo ctx-ui inbound add learn --url https://learn.microsoft.com/api/mcp
sudo ctx-ui client add "Иванов 4419" --inbound learn --expires 2027-07-01
```

`admin add` печатает логин, одноразовый пароль и секретный адрес панели. `client add` печатает токен и адреса подключения. В Docker перед командами ставится `docker compose exec ctx-ui`.

Подключите клиента с токеном в заголовке:

```bash
claude mcp add --transport http learn https://mcp.example.com/mcp/learn \
--header "Authorization: Bearer tnk_..."
```

Подробнее — в разделе [Быстрый старт](docs/ru/getting-started.md).

## Что входит

| Область | Возможности |
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Шлюз | Inbound'ы со streamable HTTP, токены клиентов, срок действия, аутентификация заголовком и путём. |
| Лимиты | Частота, одновременные запросы, квота `tools/call` с периодом сброса, таймаут запроса и размер тела. |
| Вход через браузер | OAuth для MCP-приложений, девять способов входа, ссылки-приглашения, устройства с лимитом. |
| Панель | Обзор, метрики, журнал вызовов, клиенты, inbound'ы, ключи API, английский и русский. |
| CLI | `admin`, `inbound`, `client`, `usage`, `oauth`, `apikey`, `backup`, `extension`. |
| REST API | Вся панель под `/api/v1`, документ OpenAPI 3.1, Swagger UI. |
| Расширения | Разделы, слоты, действия, эндпоинты, фоновые сервисы и база данных, шаблон проекта и браузерные тесты. |
| Конструктор | FastMCP-серверы из форм, импорта OpenAPI или кода; изолированные контейнеры; версии и откат. |
| Эксплуатация | Установка, обновление и удаление одной командой, согласованная копия работающего сервиса. |

## Документация

| | |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| [Быстрый старт](docs/ru/getting-started.md) | Установка, первый клиент, подключение приложения |
| [Установка](docs/ru/install.md) | systemd, Docker, TLS, обновление, резервная копия |
| [Настройки](docs/ru/configuration.md) | Переменные, язык, каталог данных |
| [Панель](docs/ru/panel.md) | Разделы, вход, безопасность |
| [CLI](docs/ru/cli.md) | Все команды и параметры |
| [REST API](docs/ru/api.md) | Ресурсы, ошибки, Swagger |
| [Шлюз](docs/ru/gateway.md) | Аутентификация, лимиты, ответы, upstream |
| [Вход через браузер (OAuth)](docs/ru/oauth.md) | Устройства, приглашения, провайдеры |
| [Расширения панели](docs/ru/extensions.md) | Создание и установка расширений |
| [Конструктор серверов](docs/ru/builder.md) | FastMCP-серверы в панели |
| [Если что-то не работает](docs/ru/troubleshooting.md) | Частые проблемы и что проверить |

## Лицензия

[GPL-3.0](LICENSE)
2 changes: 1 addition & 1 deletion deploy/builder/builder-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ main() {
fi

if [ -z "$mode" ]; then
fail "ctx-ui is not installed here: no $unit and no running compose project with a ctx-ui service. Install ctx-ui first, see docs/install.md"
fail "ctx-ui is not installed here: no $unit and no running compose project with a ctx-ui service. Install ctx-ui first, see docs/en/install.md"
fi
if [ -z "$version" ]; then
fail "no version given: add --version or take builder-install.sh from the release page"
Expand Down
2 changes: 1 addition & 1 deletion deploy/linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ main() {
fail "root privileges required, run with sudo"
fi
if ! command -v systemctl > /dev/null 2>&1 || [ ! -d /run/systemd/system ]; then
fail "systemd is required; without it install with Docker, see docs/install.md"
fail "systemd is required; without it install with Docker, see docs/en/install.md"
fi

if [ "$uninstall" -eq 1 ]; then
Expand Down
24 changes: 24 additions & 0 deletions docs/en/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Documentation

[English](README.md) · [Русский](../ru/README.md) · [Project](../../README.md)

## Use

| | |
| - | - |
| [Getting started](getting-started.md) | Installation, the first client, connecting an app |
| [Installation](install.md) | systemd, Docker, TLS, updating, removal, backup |
| [Configuration](configuration.md) | Variables, language, data directory |
| [Panel](panel.md) | Sections, sign-in, security |
| [CLI](cli.md) | Every command and option |
| [REST API](api.md) | Resources, errors, Swagger |
| [Gateway](gateway.md) | Authentication, limits, responses, upstream |
| [Browser sign-in (OAuth)](oauth.md) | Devices, invites, providers |
| [Troubleshooting](troubleshooting.md) | Common problems and what to check |

## Extend

| | |
| - | - |
| [Panel extensions](extensions.md) | Sections, slots, actions, database, testing, installing |
| [Server builder](builder.md) | FastMCP servers built and run from the panel |
53 changes: 53 additions & 0 deletions docs/en/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# REST API

[English](api.md) · [Русский](../ru/api.md) · [Documentation](README.md)

The API covers everything the panel does. It lives under the secret path of the panel, so it cannot be found by scanning.

| Address | What |
| ------- | ---- |
| `https://<host>/<secret>/api/v1/…` | The API. The key goes in `Authorization: Bearer ctxk_…`. |
| `https://<host>/<secret>/swagger/` | Swagger UI. "Authorize" takes the key. |
| `https://<host>/<secret>/openapi/v1.json` | The OpenAPI 3.1 document. |

## Keys

```bash
sudo ctx-ui apikey add ci
```

The command prints the key once, with the API and Swagger addresses. Keys are also issued and revoked in the **API keys** section of the panel. A revoked key gets 401 at once.

A panel session does not open the API: browsers send the cookie with requests from any site.

```bash
curl -H "Authorization: Bearer ctxk_..." https://mcp.example.com/<secret>/api/v1/clients
```

## Resources

| Resource | Methods |
| -------- | ------- |
| `inbounds`, `inbounds/{slug}` | List, get, `PUT` creates or replaces, `enable`, `disable`, `DELETE`. |
| `clients`, `clients/{id}` | List (`?name=` finds one), get, `POST` issues, `PATCH` changes, `connection`, `enable`, `disable`, `reset-quota`, `reissue`, `DELETE`. |
| `clients/{id}/devices`, `…/devices/{deviceId}` | List devices, `DELETE` disconnects one or all. |
| `clients/{id}/invite`, `clients/{id}/links`, `…/links/{linkId}`, `…/links/{provider}` | `POST` issues an invite link, list links, `DELETE` unlinks one account or every account of a provider. |
| `oauth`, `oauth/providers/{name}` | Settings (`PATCH`), providers (`PUT`, `enable`, `disable`, `DELETE`). Secrets are never returned. |
| `usage/days`, `usage/log`, `overview`, `metrics` | Daily totals, recent calls, the overview of the panel, the Metrics page (`days`, `clientId`, `inboundId`, `tool`). |

## Errors

Errors are `application/problem+json`. The `detail` text is the same as the CLI prints.

| Status | Meaning |
| ------ | ------- |
| 400 | Wrong input. |
| 401 | No key, or an unknown key. |
| 404 | No such object. |
| 409 | The token cannot be shown: the `keys/` directory is lost. |

Changes reach the gateway at once.

## Extensions

An extension can add its own endpoints under `/<secret>/extensions/<id>/`. They accept the same keys. The [server builder](builder.md#api-for-ci) uses this for CI.
19 changes: 8 additions & 11 deletions docs/builder.md → docs/en/builder.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Server builder

The builder is a panel extension. It builds MCP servers on FastMCP in the panel,
runs each one in its own isolated Docker container and connects it as an HTTP
inbound, so it reaches clients like any other server. Tokens, limits, journal,
metrics and OAuth work for built servers without extra settings.
[English](builder.md) · [Русский](../ru/builder.md) · [Documentation](README.md)

[English](builder.md) · [Русский](ru/builder.md)
The builder is a panel extension. It builds MCP servers on FastMCP in the panel, runs each one in its own isolated Docker container and connects it as an HTTP inbound, so it reaches clients like any other server. Tokens, limits, journal, metrics and OAuth work for built servers without extra settings.

The builder is not part of ctx-ui. Without it the panel shows no trace of it, and
the main image and the systemd install need neither Python nor Docker.
Expand Down Expand Up @@ -68,7 +65,7 @@ release page as the source of the assets.

```bash
curl -fsSL https://github.com/Echways/ctx-ui/releases/latest/download/builder-install.sh \
| sudo bash -s -- --version 0.2.0
| sudo bash -s -- --version 0.1.4
```

Run the command again to update: the token and the built servers are kept. `--remove`
Expand Down Expand Up @@ -197,7 +194,7 @@ Use it when you do not want the script. Download from the release page
systemd install:

```bash
export CTXB_VERSION=0.2.0
export CTXB_VERSION=0.1.4
export CTXB_RUNNER_TOKEN=$(openssl rand -hex 32)
docker compose -f builder-compose.yaml up -d
```
Expand All @@ -212,15 +209,15 @@ CtxUi__Extensions__builder__RunnerToken=<the same token>
```

```bash
sudo ctx-ui extension install builder-0.2.0.zip
sudo ctx-ui extension install builder-0.1.4.zip
sudo systemctl restart ctx-ui
```

Docker install: put `builder-compose.yaml` and `builder-compose.docker.yaml` next to
the `compose.yaml` of ctx-ui and add to `.env`:

```
CTXB_VERSION=0.2.0
CTXB_VERSION=0.1.4
CTXB_RUNNER_TOKEN=<64 hex digits>
COMPOSE_FILE=compose.yaml:builder-compose.yaml:builder-compose.docker.yaml
```
Expand All @@ -232,7 +229,7 @@ Then:

```bash
docker compose up -d
docker compose cp builder-0.2.0.zip ctx-ui:/tmp/builder.zip
docker compose cp builder-0.1.4.zip ctx-ui:/tmp/builder.zip
docker compose exec ctx-ui ctx-ui extension install /tmp/builder.zip
docker compose restart ctx-ui
```
Expand Down Expand Up @@ -269,7 +266,7 @@ Other Runner settings, in the `environment` of the `runner` service:
## API for CI

The extension has endpoints under `/<panel>/extensions/builder/`. They need an API key
in `Authorization: Bearer ctxk_…`, as in the [REST API](../README.md#rest-api).
in `Authorization: Bearer ctxk_…`, as in the [REST API](api.md).

| Request | Result |
| --- | --- |
Expand Down
Loading