Skip to content

Tool Security Important ​

Security mechanisms and permission control for the tool system.

Security Layers ​

Layer Description

Tool call requests must pass all security layer checks. Rejection at any layer results in call failure.

Risk Levels ​

LevelIconDescriptionExample
Safe🟢Read-only, no side effectsGet time, query info
Medium🟡Limited side effectsSend messages
Higher🟠Significant actionsGroup admin, file ops
Dangerous🔴System accessShell commands

Permission Control ​

User Permission Levels ​

LevelDescriptionAllowed Operations
allAll usersBasic chat, view info
whitelistWhitelist usersSpecific restricted commands
adminAdministratorsGroup management, tool calls
masterBot ownerAll operations, system config

Whitelist/Blacklist Control ​

Dangerous Tools ​

Dangerous Tool Categories ​

Dangerous Tool Configuration ​

yaml
builtinTools:
  # Allow dangerous tools
  allowDangerous: false
  
  # Dangerous tool list
  dangerousTools:
    - kick_member
    - recall_message
    - set_group_whole_ban
    - execute_command

Temporary Authorization ​

Some scenarios require temporary dangerous tool access:

javascript
const agent = await createSkillsAgent({
  event: e,
  allowDangerous: true  // Temporary authorization
})

Global Configuration ​

Enable/Disable Categories ​

yaml
builtinTools:
  enabledCategories:
    - basic
    - user
    - web
  # Unlisted categories are disabled

Disable Specific Tools ​

yaml
builtinTools:
  disabledTools:
    - execute_command
    - delete_file

Preset-Level Control ​

Whitelist Mode ​

yaml
# Preset file
tools:
  mode: whitelist
  allowedTools:
    - get_current_time
    - get_weather
    - web_search

Blacklist Mode ​

yaml
tools:
  mode: blacklist
  excludedTools:
    - send_group_message
    - kick_member

Security Execution Flow ​

Audit Logging ​

Log Recording ​

yaml
mcp:
  logging:
    enabled: true
    level: info
    retention: 30  # Keep 30 days

Log Content ​

json
{
  "id": "uuid",
  "toolName": "send_group_message",
  "args": {"target": "123", "content": "..."},
  "result": "success",
  "userId": "456",
  "timestamp": "2024-12-15T06:30:00.000Z",
  "duration": 150
}

View Logs ​

bash
# Command
#工具日志

# API
GET /api/tools/logs?limit=100&toolName=send_group_message

Best Practices ​

Security Recommendations

Follow these best practices to ensure secure tool system operation.

PracticeDescription
Least PrivilegeOnly enable needed tools
Use Whitelist ModeUse whitelist in presets, explicitly list allowed tools
Disable Dangerous ToolsAlways set allowDangerous: false in production
Regular Log AuditsRegularly check tool call logs for anomalies
Strict Parameter ValidationDefine parameter Schema to prevent injection attacks

Security Checklist ​

Pre-deployment Check

Ensure completion of the following security checks:

  • [ ] Disabled unnecessary tool categories
  • [ ] Dangerous tools disabled or controlled
  • [ ] Admin tools properly configured
  • [ ] Presets using whitelist mode
  • [ ] Audit logging enabled
  • [ ] Rate limiting configured

Next Steps ​

Released under the MIT License