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:

  1. Leitlinie: Informiert Server über relevante Ressourcen und Orte
  2. Klarheit: Macht deutlich, welche Ressourcen zu Ihrem Workspace gehören
  3. Organisation: Mehrere Roots erlauben paralleles Arbeiten mit unterschiedlichen Ressourcen

How Roots Work

When a client supports roots, it:

  1. Deklariert die Fähigkeit roots während der Verbindung
  2. Stellt dem Server eine Liste vorgeschlagener Roots bereit
  3. Benachrichtigt den Server bei Root‑Änderungen (falls unterstützt)

While roots are informational and not strictly enforcing, servers should:

  1. Die bereitgestellten Roots respektieren
  2. Root‑URIs zum Auffinden und Zugriff auf Ressourcen verwenden
  3. 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:

  1. Nur notwendige Ressourcen vorschlagen
  2. Klare, beschreibende Namen für Roots verwenden
  3. Erreichbarkeit der Roots überwachen
  4. 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.