Roots
Roots are a concept in MCP that define the boundaries where servers can operate. They provide a way for clients to inform servers about relevant resources and their locations.
What are Roots?
A root is a URI that a client suggests a server should focus on. When a client connects to a server, it declares which roots the server should work with. While primarily used for filesystem paths, roots can be any valid URI including HTTP URLs.
For example, roots could be:
file:///home/user/projects/myapp
https://api.example.com/v1
Why Use Roots?
Roots serve several important purposes:
- Leitlinie: Informiert Server über relevante Ressourcen und Orte
- Klarheit: Macht deutlich, welche Ressourcen zu Ihrem Workspace gehören
- Organisation: Mehrere Roots erlauben paralleles Arbeiten mit unterschiedlichen Ressourcen
How Roots Work
When a client supports roots, it:
- Deklariert die Fähigkeit
roots
während der Verbindung - Stellt dem Server eine Liste vorgeschlagener Roots bereit
- Benachrichtigt den Server bei Root‑Änderungen (falls unterstützt)
While roots are informational and not strictly enforcing, servers should:
- Die bereitgestellten Roots respektieren
- Root‑URIs zum Auffinden und Zugriff auf Ressourcen verwenden
- Operationen innerhalb der Root‑Grenzen priorisieren
Common Use Cases
Roots are commonly used to define:
- Projektverzeichnisse
- Repository‑Standorte
- API‑Endpunkte
- Konfigurationsorte
- Ressourcen‑Grenzen
Best Practices
When working with roots:
- Nur notwendige Ressourcen vorschlagen
- Klare, beschreibende Namen für Roots verwenden
- Erreichbarkeit der Roots überwachen
- Root‑Änderungen robust verarbeiten
Example
Here’s how a typical MCP client might expose roots:
{
"roots": [
{
"uri": "file:///home/user/projects/frontend",
"name": "Frontend Repository"
},
{
"uri": "https://api.example.com/v1",
"name": "API Endpoint"
}
]
}
This configuration suggests the server focus on both a local repository and an API endpoint while keeping them logically separated.