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, "stream": stream,
} }
if tools and settings.llm.function_calling: 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" kwargs["tool_choice"] = "auto"
resp = self._client.chat.completions.create(**kwargs) resp = self._client.chat.completions.create(**kwargs)

View File

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

View File

@ -317,12 +317,14 @@ class AppConfig:
for skill in self.mcp_skills: for skill in self.mcp_skills:
icon = "" if skill.enabled else "" icon = "" if skill.enabled else ""
lines.append(f" {icon} {skill.display()}") 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 += [ 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" [MEM] max_history = {self.memory.max_history}",
f" [AGT] max_chain_steps = {self.agent.max_chain_steps}", f" [AGT] max_chain_steps = {self.agent.max_chain_steps}",
f" [LOG] level = {self.logging.level}", f" [LOG] level = {self.logging.level}",