brokeless as an MCP server for AI apps like Claude Code
/api/mcp (Streamable HTTP, stateless) with personal tokens made on Connect your AI (stored as a hash, shown once, revocable; migration 0033). Each call runs as the token's user in their own session, so RLS applies; AI switched off in Settings refuses. Summary only, like every cloud path: the existing summary tools, plus tools that change things through placeholders and answer with counts: list categories and rules, create rule, delete rule (with undo), recategorize, find transfers, merge accounts (preview first). Rule past-matching and merging moved to shared libraries (lib/rule-past.ts, lib/merge-run.ts) so the app and the tools run the same code. Tested with the official MCP client: bad token refused, tools listed, and the 'ing' rule found, undone and replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c7298cf955
commit
1253f4e7fb
13 files changed
+471
-100
No files matched your search
@@ -0,0 +1,17 @@
|
||||
-- Personal tokens for the MCP endpoint (/api/mcp): an AI app such as Claude Code connects with one and acts as you,
|
||||
-- summary only. Only a hash is stored; the token itself is shown once. You see and revoke your own; the server checks them.
|
||||
create table if not exists public.mcp_tokens (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
user_id uuid not null references auth.users on delete cascade,
|
||||
token_hash text not null unique,
|
||||
label text not null default 'Claude',
|
||||
created_at timestamptz not null default now(),
|
||||
last_used_at timestamptz
|
||||
);
|
||||
create index if not exists mcp_tokens_user on public.mcp_tokens (user_id);
|
||||
alter table public.mcp_tokens enable row level security;
|
||||
drop policy if exists "own" on public.mcp_tokens;
|
||||
create policy "own" on public.mcp_tokens for select to authenticated using (user_id = (select auth.uid()));
|
||||
drop policy if exists "own delete" on public.mcp_tokens;
|
||||
create policy "own delete" on public.mcp_tokens for delete to authenticated using (user_id = (select auth.uid()));
|
||||
grant select (id, user_id, label, created_at, last_used_at), delete on public.mcp_tokens to authenticated;
|
||||
Reference in new issue
Block a user