feat(ai): 支持 MCP 少量查数与分服务商思考强度,修复 DeepSeek Anthropic

- MCP HTTP 默认可注册 execute_sql,行数默认 50/上限 200,设置页可切换仅结构模式
- 思考强度按 OpenAI/Anthropic/DeepSeek/Gemini 体系映射档位与请求参数
- 自定义端点 DeepSeek Anthropic 自动纠正 base 路径并回传 thinking 块
- 补充前后端回归测试与多语言文案
This commit is contained in:
Syngnat
2026-07-09 11:34:38 +08:00
parent f930ffe153
commit 4fcd7ff61f
29 changed files with 1129 additions and 56 deletions

View File

@@ -83,7 +83,7 @@ func NewServerWithOptions(backend Backend, options ServerOptions) *mcp.Server {
if !options.SchemaOnly {
mcp.AddTool(server, &mcp.Tool{
Name: "execute_sql",
Description: "执行 SQL,支持多语句结果集。执行范围受 GoNavi AI 设置中的安全控制约束;命中允许范围内的 DML/DDL 等非只读语句时,仍必须显式传 allowMutating=true。",
Description: "执行 SQL 并返回少量结果行(默认每结果集最多 50 行,上限 200。适合探查样例数据不适合大批量导出。执行范围受 GoNavi AI 设置中的安全控制约束;命中允许范围内的 DML/DDL 等非只读语句时,仍必须显式传 allowMutating=true。",
}, service.ExecuteSQL)
}

View File

@@ -15,8 +15,9 @@ import (
)
const (
defaultMaxRowsPerResult = 200
maxRowsPerResultLimit = 1000
// 默认/上限刻意压低MCP 只用于「少量样例数据」探查,避免把大结果集灌进 Agent 上下文。
defaultMaxRowsPerResult = 50
maxRowsPerResultLimit = 200
redactedOpaqueTarget = "opaque-connection-string-configured"
)
@@ -56,7 +57,7 @@ type executeSQLArgs struct {
DBName string `json:"dbName,omitempty" jsonschema:"可选数据库/Schema 名称。为空时优先使用保存连接里的默认数据库"`
SQL string `json:"sql" jsonschema:"待执行的 SQL 文本,可以包含多条语句"`
AllowMutating bool `json:"allowMutating,omitempty" jsonschema:"当 SQL 包含当前 AI 安全控制允许范围内的 DDL/DML 等非只读语句时,必须显式设为 true"`
MaxRowsPerResult int `json:"maxRowsPerResult,omitempty" jsonschema:"每个结果集最多返回多少行。默认 200最大 1000"`
MaxRowsPerResult int `json:"maxRowsPerResult,omitempty" jsonschema:"每个结果集最多返回多少行。默认 50最大 200少量数据探查"`
}
type connectionDescriptor struct {