chore: initialize qiming workspace repository
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>com.xspaceagi</groupId>
|
||||
<artifactId>app-platform-mcp</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>app-platform-mcp-sdk</artifactId>
|
||||
<name>app-platform-mcp-sdk</name>
|
||||
</project>
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xspaceagi.mcp.sdk;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.dto.McpDto;
|
||||
import com.xspaceagi.mcp.sdk.dto.McpExecuteOutput;
|
||||
import com.xspaceagi.mcp.sdk.dto.McpExecuteRequest;
|
||||
import com.xspaceagi.system.sdk.service.dto.UserAccessKeyDto;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
public interface IMcpApiService {
|
||||
|
||||
/**
|
||||
* 获取已部署的MCP详情
|
||||
*
|
||||
* @param id
|
||||
* @param spaceId 可不传,传了会根据空间过滤
|
||||
* @return
|
||||
*/
|
||||
McpDto getDeployedMcp(Long id, Long spaceId);
|
||||
|
||||
Flux<McpExecuteOutput> execute(McpExecuteRequest mcpExecuteRequestDto);
|
||||
|
||||
Long addAndDeployMcp(Long userId, Long spaceId, McpDto mcpDto);
|
||||
|
||||
|
||||
//生态市场使用
|
||||
Long deployOfficialMcp(McpDto mcpDto);
|
||||
|
||||
void stopOfficialMcp(Long id);
|
||||
|
||||
Long deployProxyMcp(McpDto mcpDto);
|
||||
|
||||
String getExportMcpServerConfig(Long userId, Long mcpId, UserAccessKeyDto.UserAccessKeyConfig userAccessKeyConfig);
|
||||
|
||||
/**
|
||||
* 统计 MCP 总数
|
||||
*
|
||||
* @return MCP 总数
|
||||
*/
|
||||
Long countTotalMcps();
|
||||
|
||||
/**
|
||||
* 管理端查询MCP列表
|
||||
*
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 每页大小
|
||||
* @param name 名称模糊搜索
|
||||
* @param creatorIds 创建人ID列表
|
||||
* @param spaceId 空间ID
|
||||
* @return MCP分页数据
|
||||
*/
|
||||
com.baomidou.mybatisplus.core.metadata.IPage<McpDto> queryListForManage(Integer pageNo, Integer pageSize, String name, java.util.List<Long> creatorIds, Long spaceId);
|
||||
|
||||
/**
|
||||
* 管理端删除MCP
|
||||
*
|
||||
* @param id MCP ID
|
||||
*/
|
||||
void deleteForManage(Long id);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CreatorDto {
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户名")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "昵称")
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "头像")
|
||||
private String avatar;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpDataTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class McpArgDto {
|
||||
|
||||
@Schema(description = "参数key,唯一标识,不需要前端传递,后台根据配置自动生成")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数名称,符合函数命名规则")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数详细描述信息")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "数据类型")
|
||||
private McpDataTypeEnum dataType;
|
||||
|
||||
@Schema(description = "是否必须")
|
||||
private boolean require;
|
||||
|
||||
@Schema(description = "下级参数")
|
||||
private List<McpArgDto> subArgs;
|
||||
|
||||
@Schema(description = "绑定值,默认值")
|
||||
private String bindValue;
|
||||
|
||||
@Schema(description = "可选枚举范围")
|
||||
private List<String> enums;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpComponentTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class McpComponentDto {
|
||||
|
||||
@Schema(description = "组件名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "组件图标")
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "组件描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "组件类型")
|
||||
private McpComponentTypeEnum type;
|
||||
|
||||
@Schema(description = "关联的组件ID")
|
||||
private Long targetId; // 关联的组件ID
|
||||
|
||||
@Schema(description = "组件原始配置")
|
||||
private String targetConfig; // 组件原始配置
|
||||
|
||||
@Schema(description = "对于通用智能体参数绑定配置")
|
||||
private String targetBindConfig; // 组件原始配置
|
||||
|
||||
@Schema(description = "工具名称", hidden = true)
|
||||
private String toolName;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class McpConfigDto {
|
||||
|
||||
@Schema(description = "MCP服务配置,installType为npx、uvx、sse时有效")
|
||||
private String serverConfig;
|
||||
|
||||
@Schema(description = "MCP组件配置,installType为component时有效")
|
||||
private List<McpComponentDto> components;
|
||||
|
||||
@Schema(description = "MCP工具列表,无需前端传递")
|
||||
private List<McpToolDto> tools;
|
||||
|
||||
@Schema(description = "MCP资源列表,无需前端传递")
|
||||
private List<McpResourceDto> resources;
|
||||
|
||||
@Schema(description = "MCP提示词列表,无需前端传递")
|
||||
private List<McpPromptDto> prompts;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpContentTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class McpContent implements Serializable {
|
||||
private String data;
|
||||
private McpContentTypeEnum type;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.DeployStatusEnum;
|
||||
import com.xspaceagi.mcp.sdk.enums.InstallTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class McpDto {
|
||||
|
||||
@Schema(description = "MCP ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "空间ID")
|
||||
private Long spaceId;
|
||||
|
||||
@Schema(description = "创建者ID")
|
||||
private Long creatorId;
|
||||
|
||||
@Schema(description = "MCP唯一标识")
|
||||
private String uid;
|
||||
|
||||
@Schema(description = "MCP名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "MCP Server英文名称", hidden = true)
|
||||
private String serverName;
|
||||
|
||||
@Schema(description = "MCP描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "MCP图标")
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "MCP分类,例如 Other")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "MCP安装方式")
|
||||
private InstallTypeEnum installType;
|
||||
|
||||
@Schema(description = "MCP部署状态")
|
||||
private DeployStatusEnum deployStatus;
|
||||
|
||||
@Schema(description = "MCP配置信息")
|
||||
private McpConfigDto mcpConfig;
|
||||
|
||||
@Schema(description = "MCP已部署配置信息", hidden = true)
|
||||
private McpConfigDto deployedConfig;
|
||||
|
||||
@Schema(description = "MCP部署时间")
|
||||
private Date deployed;
|
||||
|
||||
@Schema(description = "MCP修改时间")
|
||||
private Date modified;
|
||||
|
||||
@Schema(description = "MCP创建时间")
|
||||
private Date created;
|
||||
|
||||
@Schema(description = "MCP创建者信息")
|
||||
private CreatorDto creator;
|
||||
|
||||
private List<String> permissions;
|
||||
|
||||
private boolean isPlatformMcp;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class McpExecuteOutput {
|
||||
|
||||
@Schema(description = "执行结果状态")
|
||||
private boolean success;
|
||||
|
||||
private String message;
|
||||
|
||||
private List<McpContent> result;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.system.sdk.common.TraceContext;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class McpExecuteRequest implements Serializable {
|
||||
|
||||
private String requestId;
|
||||
|
||||
@Schema(description = "会话ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String sessionId;
|
||||
|
||||
@Schema(description = "用户信息UserDto", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Object user;
|
||||
|
||||
@Schema(description = "MCP详细信息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private McpDto mcpDto;
|
||||
|
||||
@Schema(description = "执行类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private ExecuteTypeEnum executeType;
|
||||
|
||||
@Schema(description = "MCP工具/资源/提示词名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数")
|
||||
private Map<String, Object> params;
|
||||
|
||||
@Schema(description = "是否保持会话,保持会话时需要显示调用结束")
|
||||
private boolean keepAlive;
|
||||
|
||||
private TraceContext traceContext;
|
||||
|
||||
public enum ExecuteTypeEnum {
|
||||
TOOL,
|
||||
RESOURCE,
|
||||
PROMPT
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpContentTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class McpImageContent extends McpContent {
|
||||
|
||||
private List<String> audience;
|
||||
private Double priority;
|
||||
private String mimeType;
|
||||
|
||||
@Override
|
||||
public McpContentTypeEnum getType() {
|
||||
return McpContentTypeEnum.IMAGE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpContentTypeEnum;
|
||||
|
||||
public class McpLogContent extends McpContent {
|
||||
|
||||
@Override
|
||||
public McpContentTypeEnum getType() {
|
||||
return McpContentTypeEnum.TEXT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpContentTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class McpPromptContent extends McpContent {
|
||||
private String role;
|
||||
private McpContent content;
|
||||
|
||||
@Override
|
||||
public McpContentTypeEnum getType() {
|
||||
return McpContentTypeEnum.PROMPT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class McpPromptDto {
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "输入参数")
|
||||
private List<McpArgDto> inputArgs;
|
||||
|
||||
@Schema(description = "输出参数")
|
||||
private List<McpArgDto> outputArgs;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpContentTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class McpResourceContent extends McpContent {
|
||||
private String uri;
|
||||
private String mimeType;
|
||||
private String blob;
|
||||
private String name;
|
||||
private String description;
|
||||
private Annotations annotations;
|
||||
|
||||
@Override
|
||||
public McpContentTypeEnum getType() {
|
||||
return McpContentTypeEnum.RESOURCE;
|
||||
}
|
||||
|
||||
public record Annotations(List<String> audience,
|
||||
Double priority) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class McpResourceDto {
|
||||
|
||||
private String uri;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
private String mimeType;
|
||||
private McpResourceContent.Annotations annotations;
|
||||
|
||||
@Schema(description = "工具输入参数")
|
||||
private List<McpArgDto> inputArgs;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import com.xspaceagi.mcp.sdk.enums.McpContentTypeEnum;
|
||||
|
||||
public class McpTextContent extends McpContent {
|
||||
@Override
|
||||
public McpContentTypeEnum getType() {
|
||||
return McpContentTypeEnum.TEXT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xspaceagi.mcp.sdk.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class McpToolDto {
|
||||
|
||||
@Schema(description = "工具名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "工具描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "工具输入参数")
|
||||
private List<McpArgDto> inputArgs;
|
||||
|
||||
@Schema(description = "工具输出参数")
|
||||
private List<McpArgDto> outputArgs;
|
||||
|
||||
@Schema(description = "工具原始的定义", hidden = true)
|
||||
private String jsonSchema;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.xspaceagi.mcp.sdk.enums;
|
||||
|
||||
public enum DeployStatusEnum {
|
||||
//“部署中”、“已部署”、“部署失败”、“已停止”
|
||||
Initialization,
|
||||
Deploying,
|
||||
Deployed,
|
||||
DeployFailed,
|
||||
Stopped
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xspaceagi.mcp.sdk.enums;
|
||||
|
||||
public enum InstallTypeEnum {
|
||||
NPX,
|
||||
UVX,
|
||||
SSE,
|
||||
STREAMABLE_HTTP,
|
||||
COMPONENT;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.xspaceagi.mcp.sdk.enums;
|
||||
|
||||
public enum McpComponentTypeEnum {
|
||||
Plugin, Workflow, Knowledge, Table, Agent
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xspaceagi.mcp.sdk.enums;
|
||||
|
||||
public enum McpContentTypeEnum {
|
||||
|
||||
TEXT("text"),
|
||||
IMAGE("image"),
|
||||
RESOURCE("resource"),
|
||||
PROMPT("prompt");
|
||||
private String value;
|
||||
|
||||
McpContentTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xspaceagi.mcp.sdk.enums;
|
||||
|
||||
public enum McpDataTypeEnum {
|
||||
String, //文本
|
||||
Integer, //整型数字
|
||||
Number, //数字
|
||||
Boolean, //布尔
|
||||
Object, //对象
|
||||
Array_String,//String数组
|
||||
Array_Integer,//Integer数组
|
||||
Array_Number,//Number数组
|
||||
Array_Boolean,//Boolean数组
|
||||
Array_Object,//Object数组
|
||||
}
|
||||
Reference in New Issue
Block a user