发布 openmcp-sdk

This commit is contained in:
锦恢 2025-05-11 19:26:19 +08:00
parent 1f55126c82
commit d85880ea7a
3 changed files with 30 additions and 3 deletions

View File

@ -50,8 +50,8 @@ export interface IDoConversationResult {
* @description
*/
export class TaskLoop {
private readonly streamingContent;
private readonly streamingToolCalls;
private streamingContent;
private streamingToolCalls;
private readonly taskOptions;
private bridge;
private currentChatId;
@ -61,7 +61,7 @@ export class TaskLoop {
private onEpoch;
private completionUsage;
private llmConfig;
constructor(streamingContent: Ref<string>, streamingToolCalls: Ref<ToolCall[]>, taskOptions?: TaskLoopOptions);
constructor(taskOptions?: TaskLoopOptions);
private handleChunkDeltaContent;
private handleChunkDeltaToolCalls;
private handleChunkUsage;
@ -86,6 +86,7 @@ export class TaskLoop {
*/
setLlmConfig(config: any): void;
getLlmConfig(): any;
bindStreaming(content: Ref<string>, toolCalls: Ref<ToolCall[]>): void;
connectToService(): Promise<void>;
/**
* @description DOM

View File

@ -123,5 +123,21 @@ export class TaskLoopAdapter {
console.error('❌ 连接 mcp 服务器失败:' + res.msg);
}
}
/**
* @description mcp
* @returns
*/
public async listTools() {
const tools = await client?.listTools();
if (tools?.tools) {
return tools.tools.map((tool) => ({
name: tool.name,
description: tool.description,
enabled: true
}));
}
return [];
}
}

View File

@ -38,6 +38,16 @@ export async function connectService(
try {
console.log('ready to connect', option);
// 对于特殊表示的路径,进行特殊的支持
if (option.args) {
option.args = option.args.map(arg => {
if (arg.startsWith('~/')) {
return arg.replace('~', process.env.HOME || '');
}
return arg;
});
}
client = await connect(option);
const connectResult = {
code: 200,