AI SDK
Wrap AI SDK tools with brin checks before they install packages or fetch external content
Vercel's AI SDK runs tool logic inside each tool's execute function. That makes tools the right enforcement point for brin: check the artifact first, then call the risky action only if the verdict matches your policy.
##How it works
Put a shared brin helper in front of any tool that touches external context. That includes install tools, URL fetchers, repo readers, MCP setup flows, and any custom action that reaches outside your trusted system.
##Setup
1. Add a shared helper:
This example fails open if brin is unavailable. If you want fail-closed behavior, throw inside the catch block instead.
2. Wrap the tools that install packages or fetch pages:
##Where to extend it
Use the same helper for every external context type:
repo/<owner>/<repo>before clone or sync toolsmcp/<owner>/<repo>before server enable flowsskill/<owner>/<repo>before loading agent skillsdomain/<domain>orpage/<domain/path>before browsing or scraping
If you already centralize tool creation in one module, put the brin helper there so every new tool inherits the same policy by default.
On this page