Token导航 LogoToken导航TokenDH.com
Local Reflect MCP logo
AI代理未说明官方级别未说明来源级核验

Local Reflect MCP

MCP Server

一个简单的工具,用于在多层工具调用中反射服务器端工具调用,使模型能够正确调用客户端和服务器端工具。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
AI代理JavaScript服务器工具

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

stanley2058

提供方

stanley2058

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

本地反映mcp

这是一个简单的工具,用于反映多层工具调用的服务器端工具调用。

如果你和我一样,有以下要求:

  1. 你有一个带工具的服务器。
  2. 你的客户也有工具。
  3. 您希望能够同时调用客户端和服务器工具,而不会影响其中任何一个。

在您的服务器上,您可以用实际的工具名称替换反射工具调用,使模型认为它正在调用正确的工具。使用AI-SDK的示例代码:

type ReflectIOShape = {
  id: string;
  name: string;
  input: unknown;
  output: unknown;
};
function convertServerSideToolCallsWithReflection(
  messages: ModelMessage[],
  reflectionToolName: string,
) {
  const toolResultMap = new Map();
  const output = structuredClone(messages);
  for (let i = 0; i < output.length; i++) {
    const message = output[i]!;
    if (message.role === "assistant") {
      if (typeof message.content === "string") continue;
      for (let j = 0; j < message.content.length; j++) {
        const content = message.content[j]!;
        if (content.type === "tool-call") {
          if (content.toolName !== reflectionToolName) continue;
          const payload = content.input as ReflectIOShape;
          toolResultMap.set(payload.id, payload);

          content.toolName = payload.name;
          content.input = payload.input;
        }
        if (content.type === "tool-result") {
          if (content.output.type !== "text") continue;
          if (content.toolName !== reflectionToolName) continue;

          const payload = toolResultMap.get(content.toolCallId);
          if (!payload) continue;

          content.toolName = payload.name;
          content.output = {
            type: "text",
            value: JSON.stringify(payload.output),
          };
        }
      }
    }

    if (message.role === "tool") {
      for (let j = 0; j < message.content.length; j++) {
        const content = message.content[j]!;

        if (content.output.type !== "text") continue;
        if (content.toolName !== reflectionToolName) continue;
        const payload = toolResultMap.get(content.toolCallId);
        if (!payload) continue;
        content.toolName = payload.name;
        content.output = {
          type: "text",
          value: JSON.stringify(payload.output),
        };
      }
    }
  }
  return output;
}

目录标签

目录标签

AI代理JavaScript服务器工具工具调用本地部署反射工具多层调用客户端工具

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP