@thinking-models/mcp-server
Version:
A Model Context Protocol (MCP) server for thinking models
45 lines (44 loc) • 1.09 kB
JavaScript
/**
* 标准化的响应类型 - 统一各工具返回结果的格式
*/
/**
* 将原始模型转换为基础模型信息
* @param model 原始思维模型
* @returns 基础模型信息
*/
export function toBaseModelInfo(model) {
return {
id: model.id,
name: model.name,
definition: model.definition || "",
purpose: model.purpose || "",
category: model.category || "",
subcategories: model.subcategories || []
};
}
/**
* 构造标准API响应
* @param data 响应数据
* @returns 符合MCP格式的响应对象
*/
export function createApiResponse(data) {
return {
content: [{
type: "text",
text: JSON.stringify(data, null, 2)
}]
};
}
/**
* 构造错误响应
* @param message 错误消息
* @returns 符合MCP格式的错误响应对象
*/
export function createErrorResponse(message) {
return {
content: [{
type: "text",
text: JSON.stringify({ error: "服务异常", message }, null, 2)
}]
};
}