feat: add MCP tool integration
This commit is contained in:
@@ -347,19 +347,35 @@ export type HttpToolDefinition = {
|
||||
};
|
||||
};
|
||||
|
||||
export type McpToolDefinition = {
|
||||
schemaVersion: number;
|
||||
type: "mcp";
|
||||
config: {
|
||||
remoteToolName: string;
|
||||
inputSchema: Record<string, unknown>;
|
||||
schemaHash: string;
|
||||
dynamicVariableAssignments: Record<string, string>;
|
||||
};
|
||||
};
|
||||
|
||||
export type Tool = {
|
||||
id: string;
|
||||
name: string;
|
||||
functionName: string;
|
||||
type: "end_call" | "http";
|
||||
type: "end_call" | "http" | "mcp";
|
||||
description: string;
|
||||
definition: EndCallToolDefinition | HttpToolDefinition;
|
||||
definition: EndCallToolDefinition | HttpToolDefinition | McpToolDefinition;
|
||||
secrets: Record<string, unknown>;
|
||||
status: ToolStatus;
|
||||
mcpServerId?: string | null;
|
||||
remoteToolName?: string | null;
|
||||
updatedAt?: string | null;
|
||||
};
|
||||
|
||||
export type ToolUpsert = Omit<Tool, "id" | "type" | "updatedAt">;
|
||||
export type ToolUpsert = Omit<
|
||||
Tool,
|
||||
"id" | "type" | "remoteToolName" | "updatedAt"
|
||||
>;
|
||||
|
||||
export const toolsApi = {
|
||||
list: () => request<Tool[]>("/api/tools"),
|
||||
@@ -379,6 +395,55 @@ export const toolsApi = {
|
||||
request<Tool>(`/api/tools/${id}/duplicate`, { method: "POST" }),
|
||||
};
|
||||
|
||||
export type McpServer = {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
transport: "streamable_http";
|
||||
url: string;
|
||||
timeoutSeconds: number;
|
||||
headers: Record<string, string>;
|
||||
secretHeaders: Record<string, string>;
|
||||
status: ToolStatus;
|
||||
toolCount: number;
|
||||
lastSyncedAt?: string | null;
|
||||
updatedAt?: string | null;
|
||||
};
|
||||
|
||||
export type McpServerUpsert = Omit<
|
||||
McpServer,
|
||||
"id" | "toolCount" | "lastSyncedAt" | "updatedAt"
|
||||
>;
|
||||
|
||||
export type McpSyncResult = {
|
||||
server: McpServer;
|
||||
created: number;
|
||||
updated: number;
|
||||
tools: Tool[];
|
||||
};
|
||||
|
||||
export const mcpServersApi = {
|
||||
list: () => request<McpServer[]>("/api/mcp-servers"),
|
||||
create: (body: McpServerUpsert) =>
|
||||
request<McpServer>("/api/mcp-servers", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
update: (id: string, body: McpServerUpsert) =>
|
||||
request<McpServer>(`/api/mcp-servers/${id}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
sync: (id: string) =>
|
||||
request<McpSyncResult>(`/api/mcp-servers/${id}/sync`, {
|
||||
method: "POST",
|
||||
}),
|
||||
remove: (id: string) =>
|
||||
request<{ ok: boolean }>(`/api/mcp-servers/${id}`, {
|
||||
method: "DELETE",
|
||||
}),
|
||||
};
|
||||
|
||||
// ---------- 知识库 ----------
|
||||
export type KnowledgeBase = {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user