MCP: короткий id во всех инструментах, журнал вызовов acc_mcp_log и представление acc_mcp_error_rate, расширены instructions
Some checks failed
ci / test (push) Failing after 39s
ci / deploy (push) Has been skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 11:36:17 +03:00
parent 6c061929a1
commit de20e0400f
4 changed files with 111 additions and 17 deletions

View File

@@ -0,0 +1,31 @@
-- Журнал вызовов MCP accounting_automation: разбор ошибок и доли неудачных запросов, когда чата сотрудника не видно.
create table if not exists acc_mcp_log (
id bigserial primary key,
at timestamptz not null default now(),
person_id text,
method text not null, -- tools/call, tools/list, initialize, resources/read ...
tool text, -- имя инструмента для tools/call
args jsonb, -- аргументы (усечённые)
ok boolean not null,
error_kind text, -- invalid_args | not_found | forbidden | internal | unknown_tool | rpc | partial
error text,
items_total int, -- для acc_review_batch: действий в пакете
items_failed int, -- для acc_review_batch: неудачных действий
duration_ms int,
result_bytes int
);
create index if not exists acc_mcp_log_at_idx on acc_mcp_log (at desc);
create index if not exists acc_mcp_log_tool_idx on acc_mcp_log (tool, at desc);
-- Доля ошибок по инструментам и дням: >3-5% = баг инструмента или мало инструкций.
create or replace view acc_mcp_error_rate as
select date_trunc('day', at)::date as day, tool,
count(*) as calls,
count(*) filter (where not ok or coalesce(items_failed, 0) > 0) as bad_calls,
round(100.0 * count(*) filter (where not ok or coalesce(items_failed, 0) > 0) / count(*), 1) as bad_pct,
coalesce(sum(items_total), 0) as batch_items,
coalesce(sum(items_failed), 0) as batch_items_failed
from acc_mcp_log
where method = 'tools/call'
group by 1, 2
order by 1 desc, 2;