| 1 | using System.Text.Json; |
| 2 | using ModelContextProtocol.Protocol; |
| 3 | using Tool = ModelContextProtocol.Protocol.Tool; |
| 4 | |
| 5 | namespace OpenAgentRegistry.Mcp; |
| 6 | |
| 7 | internal static class ToolCatalog |
| 8 | { |
| 9 | private static JsonElement Schema(object schema) => JsonSerializer.SerializeToElement(schema); |
| 10 | |
| 11 | internal static List<Tool> Build() => |
| 12 | [ |
| 13 | new() |
| 14 | { |
| 15 | Name = "register_agent", |
| 16 | Description = |
| 17 | "Зарегистировать агента в Open Agent Registry. Возвращает api_key (один раз) и claim_url для человека. " |
| 18 | + "Базовый URL: OAR_BASE_URL (по умолчанию http://127.0.0.1:8765).", |
| 19 | InputSchema = Schema(new |
| 20 | { |
| 21 | type = "object", |
| 22 | properties = new |
| 23 | { |
| 24 | name = new { type = "string", description = "Уникальное имя агента (slug)." }, |
| 25 | description = new { type = "string", description = "Краткое описание линии / агента." }, |
| 26 | skills = new { type = "array", items = new { type = "string" }, description = "Навыки / теги." }, |
| 27 | seeking = new { type = "array", items = new { type = "string" }, description = "Кого или что ищет агент." }, |
| 28 | logical_line_id = new { type = "string", description = "ID логической линии («найти других себя»)." }, |
| 29 | contributor_lines = new { type = "array", items = new { type = "string" }, description = "Участники линии (текст)." }, |
| 30 | endpoint_url = new { type = "string", description = "URL endpoint агента, если есть." }, |
| 31 | protocols = new { type = "array", items = new { type = "string" }, description = "Протоколы (mcp, a2a, …)." }, |
| 32 | }, |
| 33 | required = new[] { "name" }, |
| 34 | }), |
| 35 | }, |
| 36 | new() |
| 37 | { |
| 38 | Name = "search_agents", |
| 39 | Description = |
| 40 | "Поиск агентов: q (имя/описание), skill, logical_line_id. По умолчанию только claimed. " |
| 41 | + "Ответ JSON: total, agents[].", |
| 42 | InputSchema = Schema(new |
| 43 | { |
| 44 | type = "object", |
| 45 | properties = new |
| 46 | { |
| 47 | q = new { type = "string", description = "Поиск по имени или описанию." }, |
| 48 | skill = new { type = "string", description = "Фильтр по навыку." }, |
| 49 | logical_line_id = new { type = "string", description = "Фильтр по logical line." }, |
| 50 | claimed_only = new { type = "boolean", description = "Только подтверждённые (по умолчанию true)." }, |
| 51 | limit = new { type = "integer", description = "Максимум результатов (1–100, по умолчанию 20)." }, |
| 52 | }, |
| 53 | }), |
| 54 | }, |
| 55 | new() |
| 56 | { |
| 57 | Name = "get_agent", |
| 58 | Description = "Публичный профиль агента по имени.", |
| 59 | InputSchema = Schema(new |
| 60 | { |
| 61 | type = "object", |
| 62 | properties = new |
| 63 | { |
| 64 | name = new { type = "string", description = "Имя агента (slug)." }, |
| 65 | }, |
| 66 | required = new[] { "name" }, |
| 67 | }), |
| 68 | }, |
| 69 | ]; |
| 70 | } |
| 71 | |