Acesso às ferramentas com menor privilégio
Conceda a cada ferramenta apenas as permissões de que realmente precisa.
Acesso às ferramentas com menor privilégio é uma aula grátis de MCP Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de MCP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de MCP Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
The Principle
Least privilege means each tool gets only the permissions its job requires, and nothing more. If a tool is tricked, the blast radius stays small. 🔒
Narrow the Scope
A tool that reads one report folder should not be able to touch the whole disk. Give it the smallest scope that still gets the work done, then stop there.
Read vs Write
Split read and write into separate tools when you can. A read-only tool that gets injected can leak data, but it cannot quietly change or delete anything.
Scope Credentials, Not Just Tools
Privilege also lives in the token your server holds. Use a database role or API key scoped to exactly the operations needed, so a slip cannot reach unscoped resources.
A Read-Only Tool
This tool can only look up an order, never modify one. The function body defines the ceiling on what the model can do through it.
@mcp.tool()
def get_order(order_id: int) -> str:
"Read one order by id."
return db.fetch_order(order_id)Avoid the God Tool
One run_anything tool that executes arbitrary code or SQL hands the model total control. Prefer many narrow tools with fixed, predictable behavior instead.
Allowlists Over Blocklists
Decide what is permitted, not what is forbidden. An allowlist of safe operations is far easier to reason about than trying to enumerate every dangerous one.
Constrain the Filesystem
If a tool reads files, pin it to one base directory and reject paths that escape it. A bounded root stops a tool from wandering into system files.
Separate Tools by Sensitivity
Keep low-risk lookups apart from high-risk actions. You can then apply stricter checks and confirmation to only the sensitive tools that truly need them.
Per-User Authorization
The server, not the model, decides who may do what. Check the caller's identity before acting so a tool cannot reach data outside that user's permissions.
Default Deny
Start every new tool from the assumption that it can do nothing, then grant exactly what it needs. A default-deny stance keeps accidental power from creeping in.
Quick Check
Pick the design that best follows least privilege.
Recap
Give each tool the smallest scope, split read from write, scope your credentials, and default to deny. Least privilege keeps any single mistake contained. ✅
Perguntas Frequentes
A aula “Acesso às ferramentas com menor privilégio” é grátis?
Sim — o texto completo de “Acesso às ferramentas com menor privilégio” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de MCP Academy, atualize para CoddyKit PRO. O curso de MCP Academy inclui 4 aulas no total.
O que vou aprender em “Acesso às ferramentas com menor privilégio”?
Conceda a cada ferramenta apenas as permissões de que realmente precisa. Você pratica MCP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar MCP Academy?
Nenhuma experiência prévia é necessária. MCP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.
Quanto tempo leva a aula “Acesso às ferramentas com menor privilégio”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de MCP Academy?
Sim. Cada aula de MCP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Ameaças exclusivas do MCP
- Acesso às ferramentas com menor privilégio
- Validar e higienizar tudo
- Proteger ações destrutivas