Token导航 LogoToken导航TokenDH.com
Faker MCP Server logo
数据服务stdio官方级别未说明来源级核验

Faker MCP Server

MCP Server

基于Faker.js的MCP服务器,提供多语言虚假数据生成功能,适用于数据库填充、API测试和开发环境。

工具数

0

提示词数

0

GitHub Stars

7

资源数

0
TypeScriptClaude数据分析Claude DesktopClaudeCursorClineVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

funsjanssen

提供方

funsjanssen

最后核验

2026/5/17 20:20

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -i faker-mcp-server

详细介绍

Faker MCP服务器

一个模型上下文协议(MCP)服务器,使用Faker.js库提供伪造/模拟数据生成功能。为数据库种子、API测试、演示应用程序和开发环境生成真实的测试数据。

阅读更多关于为什么以及何时在我的 博客文章.

特性

  • 基础数据生成:生成包含姓名、电子邮件、地址和联系信息的真实个人和公司数据
  • 结构化数据集:为复杂的测试场景创建具有引用完整性的多实体数据集
  • 自定义图案:根据特定于域的要求,按照自定义模式(正则表达式、枚举、格式、范围)生成数据
  • 多语言环境支持:生成英语、法语、德语、西班牙语和日语的数据
  • 可复制数据:基于种子的生成,以获得一致的测试数据
  • 高性能:每秒生成1000+条记录
  • 符合MCP协议:与MCP兼容客户端无缝集成

安装

先决条件

  • 系统上已安装Node.js 18+
  • MCP兼容客户端(例如,Claude Desktop、Cline、Cursor或任何MCP客户端)

快速开始

将Faker MCP服务器添加到 mcpServers 章节:

{
  "mcpServers": {
    "faker": {
      "command": "npx",
      "args": ["faker-mcp-server"]
    }
  }
}

MCP客户端配置 有关各种MCP客户端的详细设置说明,请参阅第节。

可用工具

Faker MCP服务器提供了四种生成虚假数据的强大工具:

1.生成人

生成真实的个人数据,包括姓名、电子邮件、电话号码和地址。

参数:

  • count (number,可选):要生成的人员记录数(1-10000,默认值:1)
  • locale (字符串,可选):生成数据的区域设置- en, fr, de, es, ja (默认值: en)
  • seed (数字,可选):用于可再生发电的种子
  • includeAddress (boolean,可选):是否包含地址信息(默认值: true)
  • includePhone (布尔值,可选):是否包含电话号码(默认值: true)
  • includeDateOfBirth (布尔值,可选):是否包含出生日期(默认值: false)

示例用法:

Generate 10 fake person records with names, emails, and addresses

示例请求 (MCP协议):

{
  "method": "tools/call",
  "params": {
    "name": "generate-person",
    "arguments": {
      "count": 5,
      "locale": "en",
      "seed": 12345,
      "includeAddress": true,
      "includePhone": true,
      "includeDateOfBirth": false
    }
  }
}

示例输出:

[
  {
    "id": "person_12345_0",
    "firstName": "John",
    "lastName": "Doe",
    "fullName": "John Doe",
    "email": "john.doe@example.com",
    "phone": "+1-555-123-4567",
    "address": {
      "street": "123 Main St",
      "city": "Springfield",
      "state": "IL",
      "postalCode": "62701",
      "country": "United States"
    }
  }
]

______________________________________________________________________

2.生成公司

生成真实的公司数据,包括姓名、行业、联系信息和地址。

参数:

  • count (number,可选):要生成的公司记录数(1-10000,默认值:1)
  • locale (字符串,可选):生成数据的区域设置- en, fr, de, es, ja (默认值: en)
  • seed (数字,可选):用于可再生发电的种子
  • includeAddress (boolean,可选):是否包含地址信息(默认值: true)
  • includeWebsite (布尔值,可选):是否包含网站URL(默认值: true)
  • includeFoundedYear (boolean,可选):是否包含成立年份(默认值: false)
  • includeEmployeeCount (布尔值,可选):是否包括员工人数(默认值: false)

示例用法:

Generate 5 company records with seed 54321 for reproducibility

示例请求 (MCP协议):

{
  "method": "tools/call",
  "params": {
    "name": "generate-company",
    "arguments": {
      "count": 3,
      "locale": "en",
      "seed": 54321,
      "includeAddress": true,
      "includeWebsite": true,
      "includeFoundedYear": true,
      "includeEmployeeCount": true
    }
  }
}

示例输出:

[
  {
    "id": "company_54321_0",
    "name": "Acme Corporation",
    "industry": "Technology",
    "email": "contact@acme.example.com",
    "phone": "+1-555-111-2222",
    "website": "https://acme.example.com",
    "address": {
      "street": "100 Tech Blvd",
      "city": "San Francisco",
      "state": "CA",
      "postalCode": "94105",
      "country": "United States"
    },
    "founded": 2010,
    "employeeCount": 250
  }
]

______________________________________________________________________

3.生成数据集

生成具有多个实体类型和它们之间的引用完整性的结构化数据集。

参数:

  • schema (object,必填):定义实体和关系的数据集架构

- entities (对象):实体名称到实体定义的映射 - count (number):此实体要生成的记录数(1-10000) - type (string):实体类型- person, company,或 custom - fields (数组,可选):要包含的字段列表(默认为全部) - relationships (object,可选):与其他实体的外键关系 - references (string):父实体的名称 - type (string):关系类型- one-to-manymany-to-many - nullable (boolean,可选):外键是否可以为空(默认值: false)

  • locale (字符串,可选):生成数据的区域设置- en, fr, de, es, ja (默认值: en)
  • seed (数字,可选):用于可再生发电的种子

示例用法:

Generate a dataset with 20 users and 100 orders, where each order references a user

示例请求 (MCP协议):

{
  "method": "tools/call",
  "params": {
    "name": "generate-dataset",
    "arguments": {
      "schema": {
        "entities": {
          "users": {
            "count": 10,
            "type": "person",
            "fields": ["id", "fullName", "email", "phone"]
          },
          "orders": {
            "count": 30,
            "type": "custom",
            "fields": ["id", "userId", "productName", "price", "orderDate"],
            "relationships": {
              "userId": {
                "references": "users",
                "type": "one-to-many",
                "nullable": false
              }
            }
          }
        }
      },
      "locale": "en",
      "seed": 99999
    }
  }
}

示例输出:

{
  "users": [
    {
      "id": "user_99999_0",
      "fullName": "John Doe",
      "email": "john.doe@example.com",
      "phone": "+1-555-100-0001"
    },
    {
      "id": "user_99999_1",
      "fullName": "Jane Smith",
      "email": "jane.smith@example.com",
      "phone": "+1-555-100-0002"
    }
  ],
  "orders": [
    {
      "id": "order_99999_0",
      "userId": "user_99999_0",
      "productName": "Laptop",
      "price": 1299.99,
      "orderDate": "2024-03-15"
    },
    {
      "id": "order_99999_1",
      "userId": "user_99999_0",
      "productName": "Mouse",
      "price": 29.99,
      "orderDate": "2024-03-16"
    },
    {
      "id": "order_99999_2",
      "userId": "user_99999_1",
      "productName": "Keyboard",
      "price": 89.99,
      "orderDate": "2024-03-17"
    }
  ]
}

______________________________________________________________________

4.生成自定义

按照自定义模式生成数据,包括正则表达式模式、枚举、格式和范围。

参数:

  • count (number,可选):要生成的记录数(1-10000,默认值:1)
  • patterns (object,必填):字段名称到模式定义的映射

- type (string):图案类型- regex, enum, format,或 range - value:模式值(取决于模式类型): - regex:正则表达式字符串(例如。, "PRD-[0-9]{4}-[A-Z]{2}") - enum:可供选择的字符串值数组(例如。, ["pending", "active", "completed"]) - format:带有占位符的模板字符串(例如。, "REF-{{year}}-{{random:5}}") - range:对象 minmax 数值(例如。, {"min": 10, "max": 1000})

  • locale (字符串,可选):生成数据的区域设置-影响基于格式的模式(默认值: en)
  • seed (数字,可选):用于可再生发电的种子

示例用法:

Generate 50 product records with codes matching pattern PRD-####-XX where # is a digit and X is an uppercase letter

示例请求 (MCP协议):

{
  "method": "tools/call",
  "params": {
    "name": "generate-custom",
    "arguments": {
      "count": 5,
      "patterns": {
        "productCode": {
          "type": "regex",
          "value": "PRD-[0-9]{4}-[A-Z]{2}"
        },
        "status": {
          "type": "enum",
          "value": ["pending", "active", "completed", "cancelled"]
        },
        "price": {
          "type": "range",
          "value": { "min": 10, "max": 1000 }
        },
        "reference": {
          "type": "format",
          "value": "REF-{{year}}-{{random:5}}"
        }
      },
      "locale": "en",
      "seed": 11111
    }
  }
}

示例输出:

[
  {
    "id": "custom_11111_0",
    "productCode": "PRD-1234-AB",
    "status": "active",
    "price": 456.78,
    "reference": "REF-2024-A3B5C"
  },
  {
    "id": "custom_11111_1",
    "productCode": "PRD-5678-CD",
    "status": "pending",
    "price": 123.45,
    "reference": "REF-2024-D7E9F"
  }
]

______________________________________________________________________

常见用例

数据库种子

生成真实的测试数据以填充开发数据库:

Generate a dataset with 100 users, 500 orders, and 1000 order items with proper relationships, using seed 100

API集成测试

创建具有真实数据结构的测试有效载荷:

Generate 20 user registration payloads with emails, passwords, and profile information

UI演示数据

使用特定于地区的数据构建演示环境:

Generate French locale data: 50 customers with addresses and 200 orders for a demo e-commerce site

性能测试

为负载测试生成大量数据:

Generate 10000 person records for load testing my user import API

______________________________________________________________________

最佳实践

1.使用种子进行繁殖

当您需要跨环境的一致测试数据时,请始终指定种子:

Generate 100 users with seed 12345

2.选择合适的地点

将区域设置与您的目标市场相匹配,以获得真实的数据:

Generate 50 companies in German locale (de)

3.批量处理大型请求

对于非常大的数据集,考虑批量生成:

Generate 3000 records with seed 111 (first batch)
Generate 3000 records with seed 222 (second batch)
Generate 3000 records with seed 333 (third batch)

4.仔细定义关系

确保在生成子实体之前生成父实体:

{
  "entities": {
    "users": { "count": 10, "type": "person" },
    "orders": { 
      "count": 50, 
      "type": "custom",
      "relationships": { 
        "userId": { "references": "users", "type": "one-to-many" } 
      }
    }
  }
}

______________________________________________________________________

绩效预期

操作记录预期时间内存使用情况
生成人100\ {

const response = JSON.parse(data.toString()); console.log('Generated data:', response.result); });


______________________________________________________________________

### 配置故障排除

**问题**:“找不到命令:faker mcp服务器”

**解决方案**:

- 使用 `npx faker-mcp-server` 而不是 `faker-mcp-server`
- 先全局安装: `npm install -g faker-mcp-server`
- 使用二进制文件的绝对路径

**问题**:“MCP服务器连接超时”

**解决方案**:

- 验证是否安装了Node.js 18+: `node --version`
- 检查服务器是否手动启动: `npx faker-mcp-server`
- 查看客户端日志中的特定错误消息
- 确保没有防火墙/防病毒阻止Node.js进程

**问题**:“来自服务器的JSON响应无效”

**解决方案**:

- 确保运输设置为 `stdio` (不是 `http` 或 `sse`)
- 检查Node.js版本兼容性(需要18+)
- 验证没有其他进程正在使用stdio流

______________________________________________________________________

### 平台特定注意事项

**macOS**:

- 配置文件通常位于 `~/Library/Application Support/`
- 使用Homebrew for Node.js: `brew install node@18`

**视窗**:

- 配置文件通常位于 `%APPDATA%\` 或 `%USERPROFILE%\.config\`
- 使用nodejs.org上的Node.js安装程序或 `nvm-windows`
- 在JSON路径中使用正斜杠或转义反斜杠

**Linux**:

- 配置文件通常位于 `~/.config/`
- 使用nvm进行Node.js版本管理
- 确保执行权限: `chmod +x /path/to/faker-mcp-server`

______________________________________________________________________

## 故障排除

### “找不到MCP服务器”

**原因**:服务器安装或配置不正确。

**解决方案**:

1. 验证安装: `npm list -g faker-mcp-server`
1. 检查MCP客户端配置文件中的命令是否正确
1. 配置更改后重新启动MCP客户端

### “无效的区域设置错误”

**原因**:请求的区域设置不受支持。

**解决方案**:使用支持的区域设置之一: `en`, `fr`, `de`, `es`, `ja`

### “请求大型数据集超时”

**原因**:生成>5000条记录可能需要几秒钟。

**解决方案**:

- 使用较小的批量
- 耐心等待(10000条记录通常需要\
cd faker-mcp

# Install dependencies
npm install

# Run tests
npm test

# Build the project
npm run build

# Run in development mode
npm run dev

脚本

  • npm run build -建设生产项目
  • npm run dev -内置手表模式进行开发
  • npm test -运行一次测试
  • npm run test:watch -在监视模式下运行测试
  • npm run test:coverage -使用覆盖率报告运行测试
  • npm run lint -读取代码
  • npm run lint:fix -梳理并修复问题
  • npm run format -使用Prettier格式化代码
  • npm run typecheck -不发射的类型检查

许可证

麻省理工学院

作者

Funs杨森

贡献

欢迎投稿!请随时提交拉取请求。

目录标签

目录标签

TypeScriptClaude数据分析虚假数据生成本地部署测试数据数据库填充API测试多语言支持

支持客户端

Claude DesktopClaudeCursorClineVS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Docker

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononeremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP