LatenzPlugin

Verzögert antworten um eine zufallszahl von Millisekunden aus dem konfigurierten Bereich. Unterstützt sowohl HTTP-Anforderungen als auch STDIO-Kommunikation.

Dev Proxy simuliert die Latenz für eine API-Anforderung.

Konfigurationsbeispiel

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "LatencyPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "latencyPlugin"
    }
  ],
  "latencyPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/latencyplugin.schema.json",
    "minMs": 200,
    "maxMs": 10000
  }
}

Konfigurationseigenschaften

Eigentum Beschreibung Vorgabe
minMs Die minimale Verzögerung, die einer Anforderung in Millisekunden hinzugefügt wurde. Muss kleiner oder gleich maxMssein. 0
maxMs Die maximale Verzögerung, die einer Anforderung in Millisekunden hinzugefügt wurde. 5.000

Befehlszeilenoptionen

Nichts

Bemerkungen

Dev Proxy überprüft die Konfiguration des Plug-Ins beim Start. Wenn minMs der Wert größer als maxMsist, wird der Dev-Proxy nicht gestartet und zeigt einen Fehler an, z. B.:

LatencyPlugin: minMs (500) must be less than or equal to maxMs (100).

Wenn Sie eine feste Verzögerung hinzufügen möchten, legen Sie sie fest minMs und maxMs auf denselben Wert fest.

STDIO-Unterstützung

Wenn Sie den LatencyPlugin Befehl mit dem stdio Befehl verwenden, fügt das Plug-In künstliche Latenz zu Stdout-Antworten hinzu. Die Simulation der Latenz ist nützlich, um zu testen, wie Ihre Anwendung langsame MCP-Serverantworten (Slow Model Context Protocol) oder andere STDIO-basierte Tools verarbeitet.

Konfigurationsbeispiel für STDIO

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "LatencyPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "latencyPlugin"
    },
    {
      "name": "MockStdioResponsePlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "mockStdioResponsePlugin"
    }
  ],
  "latencyPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/latencyplugin.schema.json",
    "minMs": 100,
    "maxMs": 500
  },
  "mockStdioResponsePlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/mockstdioresponseplugin.schema.json",
    "mocksFile": "stdio-mocks.json"
  }
}

Führen Sie dann Folgendes aus:

devproxy stdio npx -y @modelcontextprotocol/server-filesystem

Nächster Schritt