← 返回 Skills 市场
kaiyuelv

API Mock Server

作者 Lv Lancer · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
82
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install api-mock-server
功能描述
Lightweight API mock server for prototyping and testing, supporting JSON/JSON Schema responses, dynamic data, validation, latency, and webhook simulation.
使用说明 (SKILL.md)

api-mock-server - API Mock服务器

Metadata

Field Value
Name api-mock-server
Slug api-mock-server
Version 1.0.0
Homepage https://github.com/openclaw/api-mock-server
Category development
Tags api, mock, server, testing, stub, http, rest, json

Description

English

A lightweight API mock server for rapid prototyping and testing. Define routes with JSON/JSON Schema responses, support dynamic data generation, request validation, latency simulation, and webhook simulation.

中文

轻量级API Mock服务器,用于快速原型开发和测试。支持JSON/JSON Schema响应定义、动态数据生成、请求验证、延迟模拟和Webhook模拟。

Requirements

  • Python 3.8+
  • Flask >= 2.3.0
  • Faker >= 19.0.0
  • jsonschema >= 4.17.0
  • requests >= 2.31.0

Configuration

Environment Variables

MOCK_PORT=3000
MOCK_HOST=0.0.0.0
MOCK_LATENCY=0

Usage

Define Routes

from api_mock_server import MockServer

server = MockServer(port=3000)

# Simple JSON response
server.get("/users", {"users": [{"id": 1, "name": "Alice"}]})

# Dynamic response with path params
server.get("/users/{id}", lambda req: {
    "id": req.params["id"],
    "name": f"User_{req.params['id']}"
})

# POST with validation
server.post("/users", 
    response={"id": 123, "created": True},
    validate_schema={
        "type": "object",
        "required": ["name", "email"],
        "properties": {
            "name": {"type": "string"},
            "email": {"type": "string", "format": "email"}
        }
    }
)

server.start()

Load from Config File

from api_mock_server import MockServer

server = MockServer.from_config("mock-routes.json")
server.start()

API Reference

MockServer

  • get(path, response) - Define GET route
  • post(path, response, validate_schema) - Define POST route
  • put(path, response) - Define PUT route
  • delete(path, response) - Define DELETE route
  • patch(path, response) - Define PATCH route
  • from_config(path) - Load routes from JSON config
  • start() - Start the server
  • stop() - Stop the server

MockRequest

  • params - URL path parameters
  • query - Query string parameters
  • body - Request body
  • headers - Request headers

Examples

See examples/ directory for complete examples.

Testing

cd /root/.openclaw/workspace/skills/api-mock-server
python -m pytest tests/ -v

License

MIT License

安全使用建议
This skill appears to be what it says: a local Flask-based API mock server. Before installing/running: (1) note the documentation mentions webhook simulation and includes 'requests' in requirements but the current implementation does not perform outbound webhooks — if you expect webhook callbacks, inspect or extend the code. (2) The default host is 0.0.0.0 (binds all interfaces); avoid exposing the server to untrusted networks or the public internet. (3) Install dependencies in a virtualenv and review scripts/mock_server.py if you need additional behavior (outbound requests, auth, logging). If you need the webhook feature or outbound callbacks, request clarification or a newer version that implements them.
功能分析
Type: OpenClaw Skill Name: api-mock-server Version: 1.0.0 The api-mock-server skill is a legitimate utility for creating mock API endpoints for testing and development. The core logic in scripts/mock_server.py uses Flask to serve user-defined routes with support for JSON Schema validation and dynamic responses, and the documentation in SKILL.md and README.md accurately reflects this functionality without any suspicious instructions or hidden behaviors.
能力评估
Purpose & Capability
The code (scripts/mock_server.py) implements a Flask-based mock server with JSON Schema validation, latency simulation, dynamic handlers, and config loading, which matches the skill name and description. Minor mismatch: README/SKILL.md mention webhook simulation and include 'requests' in requirements, but the server implementation contains no outbound webhook logic or use of requests. This looks like a documentation/feature-gap rather than intentional misdirection.
Instruction Scope
SKILL.md stays on-topic (how to define routes, run the server, load config, run tests). It mentions environment variables (MOCK_PORT, MOCK_HOST, MOCK_LATENCY) but the code does not read those environment variables directly — configuration is passed via constructor/CLI flags. Instructions also tell you to run pytest in the workspace; tests and examples operate only on local files (/tmp usage in an example). No instructions request reading unrelated system files or credentials.
Install Mechanism
There is no install spec supplied (instruction-only skill). Code files and a requirements.txt are included; installing would be a normal pip install of listed dependencies. Nothing in the manifest pulls arbitrary archives or runs remote installers.
Credentials
The skill does not declare required environment variables, credentials, or config paths. The optional env vars shown in SKILL.md are reasonable for configuring a local mock server but are not required by the code as written. No secrets or external credentials are requested.
Persistence & Privilege
always is false and the skill does not request persistent platform privileges or modify other skills or system-wide agent settings. It runs as a standalone Flask server when invoked.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install api-mock-server
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /api-mock-server 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of api-mock-server: - Lightweight API mock server for rapid prototyping and testing. - Supports defining routes with static or dynamic JSON/JSON Schema responses. - Includes features for request validation, dynamic data generation, latency simulation, and webhook simulation. - Provides usage examples and configuration via environment variables or config files. - Offers a simple Python interface for defining GET, POST, PUT, DELETE, and PATCH routes.
元数据
Slug api-mock-server
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

API Mock Server 是什么?

Lightweight API mock server for prototyping and testing, supporting JSON/JSON Schema responses, dynamic data, validation, latency, and webhook simulation. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 82 次。

如何安装 API Mock Server?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install api-mock-server」即可一键安装,无需额外配置。

API Mock Server 是免费的吗?

是的,API Mock Server 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

API Mock Server 支持哪些平台?

API Mock Server 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 API Mock Server?

由 Lv Lancer(@kaiyuelv)开发并维护,当前版本 v1.0.0。

💬 留言讨论