This commit is contained in:
sontolau 2026-04-13 16:16:16 +08:00
parent 6b7cba4939
commit f174e571bc
3 changed files with 65 additions and 55 deletions

View File

@ -89,7 +89,7 @@ class LLMClient:
"stream": stream,
}
if tools and settings.llm.function_calling:
kwargs["tools"] = [{"type": "function", "function": t} for t in tools]
kwargs["tools"] = [{"type": "function", "function": t} for t in tools[:128]]
kwargs["tool_choice"] = "auto"
resp = self._client.chat.completions.create(**kwargs)

View File

@ -35,67 +35,75 @@ mcp:
mcp_skills:
# 示例一SSE 传输(最常见的在线 MCP Server 形式)
- name: "everything" # skill 组名称(用于日志/调试)
enabled: true
transport: "sse" # sse | http | stdio
url: "http://localhost:3001/sse"
# 请求头(可用于 API Key 认证)
headers:
Authorization: "" # 优先读取环境变量 MCP_EVERYTHING_TOKEN
timeout: 30 # 连接超时(秒)
retry: 2 # 失败重试次数
# 只暴露指定工具(空列表=全部暴露)
include_tools: []
# 排除指定工具
exclude_tools: []
# - name: "everything" # skill 组名称(用于日志/调试)
# enabled: true
# transport: "sse" # sse | http | stdio
# url: "http://localhost:3001/sse"
# # 请求头(可用于 API Key 认证)
# headers:
# Authorization: "" # 优先读取环境变量 MCP_EVERYTHING_TOKEN
# timeout: 30 # 连接超时(秒)
# retry: 2 # 失败重试次数
# # 只暴露指定工具(空列表=全部暴露)
# include_tools: []
# # 排除指定工具
# exclude_tools: []
# 示例二Streamable HTTP 传输
- name: "remote-tools"
enabled: false
transport: "http"
url: "http://api.example.com/mcp"
headers:
Authorization: "Bearer your_token_here"
X-Client-ID: "agent-demo"
timeout: 30
retry: 2
include_tools: []
exclude_tools: []
# - name: "remote-tools"
# enabled: false
# transport: "http"
# url: "http://api.example.com/mcp"
# headers:
# Authorization: "Bearer your_token_here"
# X-Client-ID: "agent-demo"
# timeout: 30
# retry: 2
# include_tools: []
# exclude_tools: []
# 示例三stdio 子进程(本地可执行文件作为 MCP Server
- name: "filesystem"
# - name: "filesystem"
# enabled: false
# transport: "stdio"
# # stdio 模式使用 command 启动子进程,不需要 url
# command: "npx"
# args:
# - "-y"
# - "@modelcontextprotocol/server-filesystem"
# - "/tmp"
# env:
# NODE_ENV: "production"
# timeout: 30
# retry: 1
# include_tools: []
# exclude_tools: []
- name: "hexstrike-ai"
enabled: true
transport: "stdio"
# stdio 模式使用 command 启动子进程,不需要 url
command: "npx"
command: "python3"
args:
- "-y"
- "@modelcontextprotocol/server-filesystem"
- "/tmp"
env:
NODE_ENV: "production"
timeout: 30
retry: 1
include_tools: []
exclude_tools: []
- "/Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py"
- "--server"
- "http://localhost:8999"
description: "HexStrike AI v6.0 - Advanced Cybersecurity Automation Platform"
timeout: 300
# 示例四:带鉴权的在线 MCP SaaS 服务
- name: "brave-search"
enabled: false
transport: "sse"
url: "https://mcp.brave.com/sse"
headers:
Authorization: "" # 优先读取环境变量 MCP_BRAVE_SEARCH_TOKEN
timeout: 20
retry: 2
include_tools:
- "brave_web_search"
- "brave_local_search"
exclude_tools: []
# - name: "brave-search"
# enabled: false
# transport: "sse"
# url: "https://mcp.brave.com/sse"
# headers:
# Authorization: "" # 优先读取环境变量 MCP_BRAVE_SEARCH_TOKEN
# timeout: 20
# retry: 2
# include_tools:
# - "brave_web_search"
# - "brave_local_search"
# exclude_tools: []
# ── 工具配置 ───────────────────────────────────────────────────
tools:
calculator:
precision: 10

View File

@ -317,12 +317,14 @@ class AppConfig:
for skill in self.mcp_skills:
icon = "" if skill.enabled else ""
lines.append(f" {icon} {skill.display()}")
for tool_name in self.tools.keys():
tool = self.tools[tool_name]
for config, value in tool.items():
lines += [
f" [TOOL][{tool_name}] {config}\t\t= {value}"
]
lines += [
"",
f" [TOOL] web_search.engine = {ws['engine']}",
f" [TOOL] web_search.timeout = {ws['timeout']}s",
f" [TOOL] static_analyzer.tool= {sa['default_tool']}",
f" [TOOL] ssh_docker.port = {ssh['default_ssh_port']}",
f" [MEM] max_history = {self.memory.max_history}",
f" [AGT] max_chain_steps = {self.agent.max_chain_steps}",
f" [LOG] level = {self.logging.level}",