Latency插件

延迟从配置的范围内的随机数毫秒的响应。 支持 HTTP 请求和 STDIO 通信。

开发代理模拟 API 请求的延迟。

配置示例

{
  "$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
  }
}

配置属性

财产 描述 违约
minMs 添加到请求的最小延迟量(以毫秒为单位)。 0
maxMs 添加到请求的最大延迟量(以毫秒为单位)。 五千

命令行选项

没有

STDIO 支持

使用LatencyPluginSTDIO命令时,插件会为 stdout 响应添加人为延迟。 模拟延迟对于测试应用程序如何处理慢模型上下文协议(MCP)服务器响应或其他基于 STDIO 的工具非常有用。

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"
  }
}

然后运行:

devproxy STDIO npx -y @modelcontextprotocol/server-filesystem

后续步骤