02-ce-que-je-construis/bundles/tlr-mcp/tlr-mcp-exemples.md

Telaria MCP - Exemples JSON-RPC

Ces exemples illustrent le cycle de vie MCP et les méthodes principales, avec les outils V1 en production (list_docs, read_doc, search_docs).

1. Initialisation

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "clientInfo": {
      "name": "Telaria Client",
      "version": "1.0.0"
    },
    "capabilities": {
      "resources": { "listChanged": true },
      "prompts": { "listChanged": true },
      "tools": { "listChanged": true },
      "logging": {},
      "progress": {},
      "cancellation": {}
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "serverInfo": {
      "name": "Telaria MCP",
      "version": "1.0.0"
    },
    "capabilities": {
      "resources": { "listChanged": true },
      "prompts": { "listChanged": true },
      "tools": { "listChanged": true },
      "logging": {},
      "progress": {},
      "cancellation": {}
    }
  }
}
{
  "jsonrpc": "2.0",
  "method": "notifications/initialized"
}

Source : https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle

2. Tools

V1 en production : 3 outils lecture seule — list_docs, read_doc, search_docs. Les outils V0 (audit_rgaa) et V2+ (draft_readme_basic) ne sont pas exposés.

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list",
  "params": {}
}
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "tools": [
      {
        "name": "list_docs",
        "title": "Lister les documents",
        "description": "Liste les documents indexés dans la base RAG.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "prefix": { "type": "string", "description": "Filtre optionnel sur préfixe de chemin (ex. 'specs/')." },
            "limit":  { "type": "integer", "minimum": 1, "maximum": 500, "default": 200 }
          },
          "additionalProperties": false
        }
      },
      {
        "name": "read_doc",
        "title": "Lire un document",
        "description": "Retourne le contenu Markdown brut d'un document indexé.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "path": { "type": "string", "description": "Chemin relatif Ă  la racine du projet (ex. 'specs/ia-coeur.md')." }
          },
          "required": ["path"],
          "additionalProperties": false
        }
      },
      {
        "name": "search_docs",
        "title": "Recherche sémantique",
        "description": "Recherche sémantique dans la base RAG.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "query": { "type": "string", "description": "Question en langage naturel." },
            "k": { "type": "integer", "minimum": 1, "maximum": 20, "default": 5 }
          },
          "required": ["query"],
          "additionalProperties": false
        }
      }
    ]
  }
}

Source : https://modelcontextprotocol.io/specification/2025-11-25/server/tools

2.1 Tool V1 : search_docs

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "search_docs",
    "arguments": {
      "query": "comment configurer le rate limiter Symfony ?",
      "k": 3
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"status\":\"ok\",\"hits\":[{\"path\":\"bundles/tlr-symfony.md\",\"section\":\"Rate limiter\",\"score\":0.92,\"excerpt\":\"Le rate limiter Symfony est configuré via framework.rate_limiter...\"},{\"path\":\"specs/ia-coeur.md\",\"section\":\"Contraintes\",\"score\":0.74,\"excerpt\":\"Limite : 30 requêtes / minute par IP.\"}]}"
      }
    ]
  }
}

2.2 Tool V1 : list_docs

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "list_docs",
    "arguments": {
      "prefix": "specs/",
      "limit": 10
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"status\":\"ok\",\"documents\":[{\"path\":\"specs/ia-coeur.md\",\"title\":\"Cœur IA — spécification\"},{\"path\":\"specs/ia-mcp.md\",\"title\":\"Telaria MCP — spécification\"},{\"path\":\"specs/ia-veille.md\",\"title\":\"Veille IA — spécification\"}],\"truncated\":false}"
      }
    ]
  }
}

2.3 Tool V1 : read_doc

{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "read_doc",
    "arguments": {
      "path": "specs/ia-coeur.md"
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": 5,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"status\":\"ok\",\"path\":\"specs/ia-coeur.md\",\"title\":\"Cœur IA — spécification\",\"content\":\"---\\ntitle: Cœur IA...\\n---\\n# Cœur IA\\n...\",\"metadata\":{\"mtime\":\"2026-06-14T10:00:00Z\",\"content_hash\":\"sha256:abc123\",\"size_bytes\":4200}}"
      }
    ]
  }
}

Source : https://modelcontextprotocol.io/specification/2025-11-25/server/tools

3. Resources

{
  "jsonrpc": "2.0",
  "id": 10,
  "method": "resources/list",
  "params": {}
}
{
  "jsonrpc": "2.0",
  "id": 10,
  "result": {
    "resources": [
      {
        "uri": "file://docs/guide.md",
        "name": "Guide",
        "mimeType": "text/markdown"
      }
    ]
  }
}
{
  "jsonrpc": "2.0",
  "id": 11,
  "method": "resources/read",
  "params": {
    "uri": "file://docs/guide.md"
  }
}
{
  "jsonrpc": "2.0",
  "id": 11,
  "result": {
    "contents": [
      {
        "uri": "file://docs/guide.md",
        "mimeType": "text/markdown",
        "text": "# Guide\n\nContenu..."
      }
    ]
  }
}

Source : https://modelcontextprotocol.io/specification/2025-11-25/server/resources

4. Prompts

{
  "jsonrpc": "2.0",
  "id": 12,
  "method": "prompts/list",
  "params": {}
}
{
  "jsonrpc": "2.0",
  "id": 12,
  "result": {
    "prompts": [
      {
        "name": "doc_intro",
        "title": "Introduction",
        "description": "Rédige une introduction courte."
      }
    ]
  }
}
{
  "jsonrpc": "2.0",
  "id": 13,
  "method": "prompts/get",
  "params": {
    "name": "doc_intro",
    "arguments": {
      "subject": "Telaria"
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": 13,
  "result": {
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Rédige une introduction sur Telaria." }
        ]
      }
    ]
  }
}

Source : https://modelcontextprotocol.io/specification/2025-11-25/server/prompts

5. Erreur JSON-RPC

{
  "jsonrpc": "2.0",
  "id": 14,
  "error": {
    "code": -32601,
    "message": "Méthode non trouvée"
  }
}

Source : https://www.jsonrpc.org/specification

Assistant documentaire

Posez une question sur la documentation. Les réponses citent leurs sources — un clic ouvre le document à gauche.

Loading…
Loading the web debug toolbar…
Attempt #