Freigeben über


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/v2.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/v2.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. 0
maxMs Die maximale Verzögerung, die einer Anforderung in Millisekunden hinzugefügt wurde. 5.000

Befehlszeilenoptionen

Nichts

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/v2.1.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/v2.1.0/latencyplugin.schema.json",
    "minMs": 100,
    "maxMs": 500
  },
  "mockSTDIOResponsePlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.1.0/mockSTDIOresponseplugin.schema.json",
    "mocksFile": "STDIO-mocks.json"
  }
}

Führen Sie dann Folgendes aus:

devproxy STDIO npx -y @modelcontextprotocol/server-filesystem

Nächster Schritt