Method for calling model context protocol (MCP) tool and computing equipment

By introducing a proxy service component into the MCP architecture to filter and optimize parameters for customized MCP tools, the problem of mismatch between MCP tools and business scenarios was solved, and the optimization of model processing capabilities and the improvement of security were achieved.

CN121860049APending Publication Date: 2026-04-14ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

The existing Model Context Protocol (MCP) tools are not compatible with actual business scenarios, resulting in excessive model processing pressure, inaccurate tool selection, and the risk of malicious descriptions.

Method used

By introducing an MCP proxy service component between the MCP client and server, customized MCP tools can be screened and their parameters optimized, generating customized MCP tools that match business scenarios, reducing the number of input and output parameters, and performing security checks on parameters and content to ensure that tool calls meet business requirements.

Benefits of technology

Based on the MCP standard protocol, the problem of mismatch between tools and business scenarios has been solved, the model processing pressure has been reduced, the accuracy and security of tool selection have been improved, and the transmission of invalid or malicious data has been avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121860049A_ABST
    Figure CN121860049A_ABST
Patent Text Reader

Abstract

The invention discloses a method for calling a model context protocol (MCP) tool and computing equipment. The method comprises the steps that a first tool calling request sent by an MCP client side for a target customized MCP tool is received, and the first tool calling request comprises first parameter information of at least part of customized input parameters of the target customized MCP tool; the target customized MCP tool is a tool obtained by customizing a target MCP tool provided by a target MCP server, and the parameter quantity of the customized input parameter is smaller than the parameter quantity of the input parameter of the target MCP tool; based on the first tool calling request, a second tool calling request for the target MCP tool is generated, and the second tool calling request comprises second parameter information of input parameters corresponding to the at least part of customized input parameters; and sending the second tool calling request to the target MCP server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments in this specification belong to the field of artificial intelligence, and in particular relate to a method and computing device for invoking the Model Context Protocol (MCP) tool. Background Technology

[0002] The Model Context Protocol (MCP) is an open protocol designed to standardize the interaction between Large Language Models (LLMs) and external data sources and tools. Simply put, MCP is a "universal socket" or "general language" for LLMs, enabling different LLMs to call external tools, obtain real-time data, and interact with various services in a unified manner.

[0003] MCP consists of three parts: MCP Host, MCP Client, and MCP Server. The MCP Host is the LLM application that initiates the connection. The MCP Client is used to connect to the MCP Server. The MCP Server provides tools, prompts, and resources.

[0004] Currently, MCP primarily utilizes tools. The tools provided by MCP servers are typically general and generic. Therefore, in practical applications, there's a mismatch between the tools provided by the MCP server and the actual business scenario. For example, some MCP tools offer a wealth of parameters and result fields, while practical applications only require business-related parameters and result fields. Too many parameters and result fields place a greater burden on the model's processing capacity, and when an application relies on multiple MCP tools, it may even exceed the model's processing capabilities. Another example is that the tool descriptions may not accurately match the actual business scenario, leading to the model's inability to select the right tool. Furthermore, malicious MCP servers may dynamically provide tool descriptions that contain inaccurate or false information.

[0005] Therefore, there is a need for a technical solution to address the mismatch between MCP tools and actual business scenarios. Summary of the Invention

[0006] The first aspect of this specification provides a method for invoking the Model Context Protocol (MCP) tool, including:

[0007] The system receives a first tool invocation request from an MCP client for a target customized MCP tool. The first tool invocation request includes first parameter information of at least some customized input parameters of the target customized MCP tool. The target customized MCP tool is a tool obtained by customizing a target MCP tool provided by a target MCP server. The number of customized input parameters is less than the number of input parameters of the target MCP tool.

[0008] Based on the first tool invocation request, a second tool invocation request is generated for the target MCP tool, the second tool invocation request including second parameter information of the input parameters corresponding to the at least part of the customized input parameters;

[0009] Send the second tool invocation request to the target MCP server.

[0010] A second aspect of this specification provides a computing device including a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method described in the first aspect.

[0011] According to the method provided in the embodiments of this specification, the MCP client uses a customized MCP tool obtained by customizing the native MCP tool. The number of customized input parameters of the customized MCP tool is less than that of the native MCP tool, thus reducing the pressure on model processing caused by excessive parameters. Furthermore, in response to the first tool invocation request from the MCP client for the target customized MCP tool, a second invocation request for the target MCP tool is sent to the target MCP server that provides the target MCP tool corresponding to the target customized MCP tool. Therefore, the problem of mismatch between MCP tools and actual business scenarios can be solved while adhering to the MCP standard protocol. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of the embodiments in this specification, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a schematic diagram of a conventional MCP architecture in one embodiment;

[0014] Figure 2 This is a schematic diagram of the MCP architecture in one embodiment of this specification;

[0015] Figure 3This is a schematic diagram of an MCP management system in one embodiment of this specification;

[0016] Figure 4 This is a flowchart of a method for customizing the MCP tool in one embodiment of this specification;

[0017] Figure 5 This is a flowchart of a method for calling a custom MCP tool in one embodiment of this specification. Detailed Implementation

[0018] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.

[0019] Figure 1 This is a schematic diagram of a conventional MCP architecture in one embodiment.

[0020] See Figure 1 In a typical MCP architecture, the MCP client within the MCP host connects to the MCP server. The basic process of using MCP tools on an MCP host can be summarized as follows.

[0021] First, the MCP host sends a `tools / list` command to the MCP server via the MCP client to retrieve a list of tools provided by the MCP server. This list includes the names of all tools provided by the MCP server, descriptions of their functions, and definitions of their parameters. The MCP host then combines this tool list with the original question to form a prompt, which is sent to the LLM. The LLM then uses reasoning to determine which tool to use and the parameters to pass. Based on the LLM's output, the MCP client sends a `tools / call` command to the specified MCP server. Upon receiving the `tools / call` command, the MCP server uses the parameters provided by the MCP client to invoke the corresponding tool and sends the tool's execution result back to the MCP client. After the MCP client receives the tool's execution result, the MCP host can combine the result and the original question again to form a new prompt, which is then sent to the LLM for reasoning to obtain the final answer to the original question, which is then provided to the user.

[0022] Most MCP servers are built by third parties independent of the application. The tool lists provided by these third-party MCP servers may contain tools that don't match the actual business scenario. However, the MCP standard protocol doesn't distinguish between tools matching the actual business scenario; instead, it responds to the MCP client's `tools / list` command by sending all tools provided by the MCP server to the MCP client. This expands the range of tools available for the model and increases the model's processing load.

[0023] Some MCP tools offer a wealth of input parameters and result fields (i.e., output parameters), while practical applications only require business-relevant input parameters and result fields. However, the MCP standard protocol does not distinguish between business-relevant input parameters and result fields; instead, it responds to the MCP client's `tools / list` command by sending all input parameters of the tool to the MCP client, or responds to the MCP client's `tools / list` command by sending all returned result fields to the MCP client. An excessive number of input parameters and result fields undoubtedly places greater pressure on model processing.

[0024] Some MCP tools' tool descriptions and / or parameter descriptions may not accurately reflect the actual business scenario and the relationship between the tool and / or parameters and the business. Some MCP tools' tool descriptions and / or parameter descriptions may also contain malicious descriptions that are inconsistent with reality. All of these factors can cause the model to fail to correctly select tools and / or correctly populate parameters.

[0025] In summary, conventional MCP architecture cannot solve the problem of mismatch between MCP tools and actual business scenarios. This mismatch will interfere with the model's calling of MCP tools, and in severe cases, it will exceed the model's processing capacity, making the model unable to call the tool or unable to call the correct tool.

[0026] Therefore, the embodiments in this specification aim to propose an improved MCP application scheme based on the MCP standard protocol, in order to solve the problem of mismatch between MCP tools and actual business scenarios.

[0027] Figure 2 This is a schematic diagram of the MCP architecture in one embodiment of this specification.

[0028] See Figure 2 ,and Figure 1 The difference between the conventional MCP architecture shown is that this embodiment adds an MCP proxy service component between the MCP client and the MCP server.

[0029] On one hand, the MCP proxy service component acts as a customized MCP server, providing MCP clients with customized MCP tools tailored to their specific business needs. These customized MCP tools are derived by modifying the existing MCP server-side tools. For example... Figure 2 As shown, the MCP server provides tools A, B, and C. First, users can filter all tools provided by the MCP server, selecting tools A and B that are relevant to the actual business scenario, while discarding tool C, which is irrelevant. Next, users can customize the tool names, descriptions, and parameters of the selected tools A and B. Details related to customization will be described below. The customized tool A can be denoted as tool A', and the customized tool B can be denoted as tool B'. Both tool A' and tool B' are customized MCP tools.

[0030] A custom MCP tool can be considered a "virtual" tool; it doesn't possess any actual functions that can be called. Calling a custom MCP tool requires translating into a call to the native MCP tool behind it. In other words, when calling a custom MCP tool, it's still necessary to access the MCP server that provides the corresponding MCP tool. Therefore, the custom MCP server providing the custom MCP tool can be considered a "virtual" MCP server. The custom MCP server only provides a list of tools related to the custom MCP tool; it doesn't have the ability to call those tools itself.

[0031] Therefore, on the other hand, after receiving a call request for a customized MCP tool from an MCP client in the MCP host, the MCP proxy service component also acts as an "MCP client," sending a call request for the native MCP tool corresponding to the customized MCP tool to the corresponding MCP server, and converting the call result of the native MCP tool into the call result of the customized MCP tool, which is then sent to the MCP client. The specific call process will be described below.

[0032] With the aforementioned two functions of the MCP proxy service component, the problem of mismatch between MCP tools and actual business scenarios can be solved without modifying the MCP client and MCP server, while adhering to the MCP standard protocol.

[0033] The above section explained the basic principles of the technical solution proposed in this specification to address the mismatch between MCP tools and actual business scenarios from the perspective of MCP architecture. The following section describes the details of the technical solution provided in this specification, using specific embodiments.

[0034] Figure 3 This is a schematic diagram of an MCP management system in one embodiment of this specification.

[0035] The MCP management system can be used on various large-scale model application platforms to improve the usability and security of MCP tools within these platforms. See also... Figure 3 The MCP management system mainly includes the MCP development system, the MCP metadata service component, and the MCP agent service component. Optionally, the MCP service system may also include the extended service components shown in the dashed box in the diagram. These extended service components can provide any one or more combinations of the following services: permission checking service, content moderation service, and content processing service.

[0036] The MCP development system provides services for customizing MCP tools. For example, the MCP development system can be geared towards developers of LLM applications. Developers can customize one or more MCP tools provided by the MCP server based on the actual business scenario of their LLM application. The following is an illustrative example of the customization process.

[0037] Figure 4 This is a flowchart of a method for customizing the MCP tool in one embodiment of this specification. Figure 4 Steps S101 to S109 shown can all be executed by the MCP development system.

[0038] See Figure 4 In step S101, obtain the MCP Server access information.

[0039] MCP Server access information includes the information required to connect to the MCP Server to be customized. There can be one or more MCP Servers to be customized. MCP Server access information may include, but is not limited to, the MCP Server's access address and authentication information. Both the MCP Server to be customized and its access information can be configured by the developers.

[0040] In step S103, a request to obtain a third tool is sent to the MCP server.

[0041] A third-party tool retrieval request is used to request the MCP server to return all available MCP tools. For example, a third-party tool retrieval request could be the `tools / list` command in the MCP protocol used to discover available tools.

[0042] In step S105, the tool list sent by the MCP server is received.

[0043] The tool list contains tool information for all MCP tools provided by the MCP server. Tool information includes, but is not limited to, tool name, tool description, input parameter name, and input parameter description. In some exemplary embodiments, information related to the output parameters of the MCP tools can also be obtained through other means (e.g., through the official documentation of the MCP server). Information related to the output parameters of the MCP tools may include, but is not limited to, output parameter name and output parameter description.

[0044] In step S107, output the tool list.

[0045] Once the tools list is obtained, it can be visualized to facilitate customization by developers. For example, information related to the output parameters of the MCP tool can also be output to allow for customization of those parameters.

[0046] This manual supports multi-dimensional customization of the MCP tool.

[0047] In some embodiments, a list of all MCP tools obtained from one or more MCP servers can be displayed, allowing developers to filter the list based on actual business scenarios, retaining only the business-related MCP tools. The filtered MCP tools can be called customized MCP tools. By filtering MCP tools, tools irrelevant to the business can be filtered out, narrowing the tool selection range for models (such as LLM) and reducing the model processing load.

[0048] In some embodiments, tool descriptions of MCP tools (such as customized MCP tools selected through screening) can be displayed, allowing developers to configure these descriptions to obtain customized tool descriptions that better suit actual business scenarios or model capabilities. For example, developers can modify tool descriptions to be more relevant to the business scenario, thereby improving the accuracy of tool selection based on the customized tool descriptions. Furthermore, if a tool description is too long, developers can shorten it to obtain a shorter customized tool description, thus avoiding exceeding the LLM processing token limit. In addition, configuring tool descriptions can also address the issue that malicious MCP servers may dynamically provide tool descriptions that do not conform to the facts.

[0049] In some embodiments, the tool names of MCP tools (such as customized MCP tools selected through screening) can be displayed so that developers can configure the tool names according to the actual business scenario, resulting in customized tool names that better suit the actual business scenario. Using customized tool names can improve the accuracy of tool selection for the model.

[0050] In some embodiments, all input parameters of the MCP tool (such as a customized MCP tool obtained through filtering) can be displayed, allowing developers to filter the input parameters based on the actual business scenario of the LLM application, retaining only those relevant to the business. The filtered input parameters can be called customized input parameters. The number of customized input parameters is less than the number of input parameters of the MCP tool. By filtering the input parameters, tool input parameters irrelevant to the business can be filtered out, narrowing the range of parameters to be selected for the model and reducing the processing load on the model.

[0051] In some embodiments, parameter descriptions of the input parameters of the MCP tool (such as customized input parameters obtained through filtering) can be displayed so that developers can configure the parameter descriptions according to the actual business scenario, thereby obtaining customized parameter descriptions that are more in line with the actual business scenario and easier for the model to understand, and improving the accuracy of the model filling parameters.

[0052] In some embodiments, the input parameter names of the MCP tool (such as customized input parameters obtained through filtering) can be displayed so that developers can configure the input parameter names according to the actual business scenario, thereby obtaining customized input parameter names that are more in line with the actual business scenario and easier for the model to understand, thus improving the accuracy of the model filling parameters.

[0053] In some embodiments, all output parameters of an MCP tool (such as a customized MCP tool obtained through filtering) can be displayed, allowing developers to filter the output parameters according to the actual business scenario, retaining only those relevant to the business. The filtered output parameters can be called customized output parameters. This allows for filtering of result fields irrelevant to the business when the tool is invoked, reducing the processing load on the model.

[0054] In some embodiments, the output parameter names of the MCP tool (such as customized output parameters obtained through filtering) can be displayed so that developers can configure the output parameter names according to the actual business scenario, thereby obtaining customized output parameter names that are more in line with the actual business scenario and easier for the model to understand, and improving the accuracy of the model's inference based on the tool call results.

[0055] In some embodiments, developers can configure the range and / or format of custom input parameters to obtain a first constraint. This first constraint can be used to perform constraint checks on tool input parameters during tool invocation, preventing invalid tool input parameters from causing MCP tool invocation failure. See the description below for details on constraint checks.

[0056] In some embodiments, developers can configure the value range and / or value format of customized output parameters according to actual business scenarios to obtain a second constraint that matches the actual business environment. The second constraint can be used to perform constraint checks on the tool's output parameters when the tool is invoked, avoiding invalid output parameters from reducing the usability of the results obtained from model processing.

[0057] In some embodiments, developers can set default values ​​for certain customized input parameters based on actual business scenarios, thereby obtaining default values ​​that match the actual business scenario. By setting default values, the range of parameters to be filled in the model can be narrowed, the processing pressure on the model can be reduced, and input parameter values ​​that match the business can be obtained.

[0058] In some embodiments, developers can configure the mapping relationship between custom input parameters and the input parameters of the native MCP tool, and / or, developers can also configure the mapping relationship between custom output parameters and the output parameters of the native MCP tool. Based on the mapping relationship configuration information, it is easy to map the input of the custom MCP tool to the input of the native MCP tool, and to map the output of the native MCP tool back to the output of the custom MCP tool. For example, the mapping relationship configuration information may include, but is not limited to: the mapping relationship between custom input parameter names and original input parameter names, the mapping relationship between custom output parameter names and original output parameter names, and the mapping relationship between custom tool names and original tool names. The mapping relationship configuration information may use, but is not limited to, a "key-value pair" data structure to represent the above mapping relationships.

[0059] In some embodiments, developers are supported in configuring content checks on custom input parameters to obtain first content check configuration information. This first content check configuration information may include option information for whether to check the content of the custom input parameters. If content checks on the custom input parameters are selected, the first content check configuration information may also include content check rules set for the custom input parameters. These content check rules may include, for example, rules for determining whether the content is safe. By supporting developers in configuring content checks on custom input parameters, insecure content such as sensitive data and content with compliance risks can be prevented from entering the MCP Server, thereby improving the security of content flowing into the MCP Server.

[0060] In some embodiments, developers are supported in configuring content inspection settings for customized output parameters, resulting in second content inspection configuration information. This second content inspection configuration information may include option information for whether to inspect the content of the customized output parameters. If content inspection of the customized output parameters is selected, the second content inspection configuration information may also include content inspection rules set for the customized output parameters. By supporting developers in configuring content inspection settings for customized output parameters, sensitive data, malicious injections, and compliance risks can be prevented from leaking from the MCP Server results and infiltrating subsequent processing in the LLM application, thereby improving the security of content flowing into the LLM application.

[0061] In some embodiments, developers are supported in configuring processing settings for tool call results to obtain content processing configuration information. This content processing configuration information may include option information for whether to configure processing settings for the tool call results. If the option to configure processing settings for the tool call results is selected, the content processing configuration information may also include descriptions of processing rules for one or more content processing methods (e.g., summarizing excessively long content, or formatting complex content). By supporting developers in configuring processing settings for tool call results, the subsequently processed tool call results are made more suitable for model processing.

[0062] In some embodiments, developers are supported in configuring permission checks for customized MCP tools to obtain permission check configuration information. This permission check configuration information may include clients with usage permissions for the customized MCP tool.

[0063] In step S109, obtain the customization information.

[0064] Customization information may include, but is not limited to, the following: the selected customized MCP tool; the description of the customized MCP tool; the name of the customized MCP tool; the selected customized input parameters; the description of the customized input parameters; the name of the customized input parameters; the selected customized output parameters; the name of the customized output parameters; the first constraint; the second constraint; the default value; the first content check configuration information; the second content check configuration information; and the content processing configuration information.

[0065] After customizing one or more native MCP tools provided by the MCP server, the MCP development system can send the customized MCP tools and related customization information as metadata to the MCP metadata service for management and subsequent use.

[0066] The MCP proxy service component provides customized MCP tool invocation services for MCP clients. It includes a service interface component, an MCP tool information retrieval component, an MCP tool invocation component, and an MCP client component. Figure 5 This is a flowchart illustrating a method for calling a custom MCP tool in one embodiment of this specification. The following describes how to use the custom MCP tool.

[0067] See Figure 5 In step S201, the service interface component may receive the first tool acquisition request sent by the MCP client.

[0068] The service interface component acts as a custom MCP server, providing customized MCP tools and offering an access interface compliant with the MCP protocol. MCP clients can establish a connection with the service interface component according to the MCP protocol and send a first tool retrieval request. This first tool retrieval request could be, for example, the `tools / list` command.

[0069] In step S202, the service interface component may send the first tool information of at least a portion of the customized MCP tools in the customized MCP toolset to the MCP client. Upon receiving the first tool retrieval request, the service interface component can retrieve the first tool information of the at least a portion of the customized MCP tools from the MCP metadata service component via the MCP tool information retrieval component.

[0070] Customizing an MCP toolset can be done according to the above. Figure 3 The method shown illustrates a tool set obtained by customizing a set of MCP tools provided by one or more MCP servers. Customized MCP tools are those selected from the existing MCP tools to be relevant to the actual business scenario. Therefore, the number of customized MCP tools in the customized MCP tool set is less than the number of MCP tools in the existing MCP tool set.

[0071] In some embodiments, at least a portion of the customized MCP tools in the customized MCP toolset can be made available for a fee. Users of the MCP client can obtain access to these customized MCP tools by paying a fee. Therefore, when sending available customized MCP tools to the MCP client, the customized MCP tools that the MCP client has access to can be selected from the customized MCP toolset, thus obtaining the at least a portion of the customized MCP tools. Alternatively, all customized MCP tools in the customized MCP toolset can be sent to the MCP client, and the permission review stage in the pre-processing described below can be used to check whether the MCP client has access to the target customized MCP tool to be invoked.

[0072] The first tool information may include customized input parameter information for the customized MCP tool. As mentioned above, customized input parameters are business-related input parameters obtained by filtering the input parameters of the MCP tool. Therefore, the number of customized input parameters for the customized MCP tool is less than the number of input parameters for the corresponding MCP tool.

[0073] In some embodiments, the customized parameter information may include, but is not limited to, the customized parameter description and / or customized input parameter name mentioned above. The first tool information may also include, but is not limited to, the customized tool description and / or customized tool name mentioned above.

[0074] The tool information sent to the MCP client is the tool information directly used by the model and is crucial for improving the model's tool selection effectiveness. By returning the first tool information of customized MCP tools based on business requirements, tools and tool input parameters irrelevant to the business can be filtered out. Furthermore, the first tool information includes the optimized tool name (i.e., customized tool name), tool description (i.e., customized tool description), input parameter name (i.e., customized input parameter name), and input parameter description (i.e., customized parameter description) based on business customization. By returning the first tool information involving numerous customization details, the model's tool selection processing capabilities can be adapted, improving the business accuracy of the model's tool selection decisions and avoiding issues such as the original MCP Tools' input / output parameter structure being too complex for the model to handle, or the MCP Tools' input / output parameters and descriptions being too long and exceeding the model's processing token limit.

[0075] In step S203, the service interface component may receive a first tool invocation request from the MCP client for a target-customized MCP tool. After the MCP client receives the first tool information, the MCP host can concatenate the first tool information (or the result of format conversion of the first tool information) with the problem to be solved by the model to form a prompt, which is then input into the model. The model, through inference, determines the target-customized MCP tool to be invoked and the first parameter information to be transmitted. The first parameter information includes the parameter names and input parameter values ​​of at least some of the customized input parameters of the target-customized tool.

[0076] After determining the target customized MCP tool and the first parameter information to be transmitted, a first tool invocation request for the target customized MCP tool can be sent to the service interface component in the MCP proxy service component. The first tool invocation request includes the first parameter information. The first tool invocation request can be, for example, the tools / call (invoke tool) command in the MCP protocol. The target customized MCP tool is a tool obtained by customizing the target MCP tool provided by the target MCP server.

[0077] In some embodiments, after receiving a first tool invocation request for a target customized MCP tool from an MCP client, a second tool acquisition request can be sent to the target MCP server via the MCP client component. This allows the client to receive second tool information for all available MCP tools sent by the target MCP server, including parameter information for the input parameters of the available MCP tools. Based on this second tool information, it is determined whether the target MCP tool is available, and / or whether the input parameters of the target MCP tool have changed. If the target MCP tool is unavailable, or its input parameters have changed, a fifth prompt message can be sent to the first MCP client. Thus, before invoking the target customized MCP tool, the availability of the target MCP tool behind the target customized MCP tool can be determined by obtaining and comparing the original MCP tool information from the original MCP server, and a prompt (such as an alarm) can be issued if it is unavailable.

[0078] In some embodiments, before executing step S202, a second tool acquisition request can be sent to the target MCP server via the MCP client component to receive second tool information for all available MCP tools sent by the target MCP server. Based on the second tool information, it is determined whether any of the at least some customized MCP tools have an unavailable underlying MCP tool or whose input parameters have changed. Customized MCP tools with unavailable underlying MCP tools or whose input parameters have changed are removed from the at least some customized MCP tools. Thus, by obtaining and comparing the original MCP tool information from the original MCP server before sending customized MCP tools to the MCP client, invalid customized MCP tools can be avoided.

[0079] In step S204, a second tool call request is generated for the target MCP tool based on the first tool call request.

[0080] The second tool invocation request includes second parameter information corresponding to the input parameters corresponding to at least some of the customized input parameters. The second parameter information includes the input parameter name and the input parameter value. The first parameter information includes the parameter name and the input parameter value of at least some of the customized input parameters of the target customized MCP tool. When the parameter name included in the first parameter information is a customized input parameter name obtained by configuring the input parameter name of the target MCP tool, and is different from the input parameter name, it is necessary to map the parameter name in the first parameter information from the customized input parameter name to the corresponding input parameter name to obtain second parameter information that conforms to the interface definition of the target MCP tool. This can be achieved by using the parameter mapping service provided by the pre-processing component in the MCP tool to map the parameter name in the first parameter information from the customized input parameter name to the input parameter name, thus obtaining second parameter information that conforms to the input parameter definition of the target MCP tool. Parameter mapping can be performed based on the mapping relationship configuration information described above.

[0081] In some embodiments, after receiving the first tool invocation request, the pre-processing component may also perform multiple pre-processing operations. These multiple pre-processing operations may include, in addition to parameter mapping, permission checks, constraint checks, content checks, and parameter mapping.

[0082] The permission check in the pre-processing refers to checking whether the MCP client has the necessary permissions to use the target customized MCP tool. For example, a permission check service provided by an extended service component can be used to check whether the MCP client has the required permissions. If the MCP client is found to lack the necessary permissions, a sixth prompt message can be sent to the MCP client, reminding the user to grant permission to use the target customized MCP tool.

[0083] The constraint check in the pre-processing refers to performing basic checks on the input parameter values ​​(i.e., input field values) in the first parameter information of the first tool call request, such as checking for non-emptiness, value range, and value format. For example, the customized information of the target MCP tool includes first constraints obtained by configuring the value range and / or value format of customized input parameters. The system can check whether the format and / or value range of the customized input parameter values ​​conform to the first constraints; if there are input parameter values ​​that do not conform to the first constraints, a first prompt message is sent to the MCP client. Therefore, by performing constraint checks on input parameter values, invalid input parameters can be avoided from causing the native MCP Tool call to fail, thus improving the success rate of MCP Tool calls.

[0084] Content inspection in pre-processing refers to performing security and compliance checks on the content of input parameter values ​​to prevent sensitive data, compliance risks, and other insecure content from entering the MCP Server. For example, the customization information of a target customized MCP tool may also include first content inspection configuration information set for customized input parameters. Based on this first content inspection configuration information, the security of the input parameter values ​​can be checked. If insecure input parameter values ​​are found, a third prompt message is sent to the MCP client. This can be achieved through a content moderation service provided by an extended service component. The content moderation service can utilize a large model to moderate the input parameter values. The first content inspection configuration information may include content inspection rules set for customized input parameters. The large model used to moderate the input parameter values ​​can be a general-purpose large language model. For example, a prompt word can be generated based on the content of the input parameter values ​​(which may also include a preset sensitive word library). This prompt word is then input into the large model, instructing it to moderate the input parameter values.

[0085] In step S205, the MCP client component in the MCP proxy service component can send a second tool invocation request to the target MCP server. The MCP client component acts as an MCP client that establishes a connection with the target MCP server and sends the second tool invocation request to the target MCP server.

[0086] In step S206, the first tool call result sent by the target MCP server is received.

[0087] In step S207, a second tool call result is generated based on the first tool call result.

[0088] The first tool call result includes third parameter information of at least some of the output parameters obtained by calling the target MCP tool to process the second tool call request. The third parameter information includes the output parameter name and the output parameter value. The second tool call result includes fourth parameter information of the customized output parameters corresponding to the at least some of the output parameters. The fourth parameter information includes the parameter name (e.g., customized output parameter name) and the output parameter value of the customized output parameter.

[0089] Customized output parameters are business-related output parameters obtained by filtering the output parameters. The number of customized output parameters is less than the number of output parameters of the target MCP tool. Therefore, result field values ​​(i.e., output parameter values) that match the customized output parameters can be filtered from the first tool call result (i.e., the third parameter information) to eliminate result field values ​​that are irrelevant to the business from the first tool call result. For the filtered result field values, if the parameter name of the customized output parameter is inconsistent with the output parameter name corresponding to the result field value, the output parameter name corresponding to the result field value can be mapped to the corresponding customized output parameter name. Specifically, the output mapping service provided by the post-processing component in the MCP tool can be used to map the third parameter information to fourth parameter information that conforms to the output parameter definition of the target MCP tool. Output mapping can be performed based on the mapping relationship configuration information mentioned above.

[0090] In some embodiments, after receiving the result of the first tool invocation, the post-processing component may also perform multiple post-processing operations. These multiple post-processing operations may include, in addition to output mapping, constraint checking, content checking, and content processing.

[0091] Constraint checks in post-processing refer to basic checks on output parameter values ​​(i.e., input field values), such as non-emptiness, value range, and value format. For example, the target MCP tool's customization information includes second constraints derived from configuring the value range and / or value format of customized output parameters. These constraints can be used to check whether the format and / or value range of the output parameter values ​​conform to the second constraints. If any output parameter values ​​do not conform to the second constraints, a second prompt message is sent to the MCP client. Therefore, by performing constraint checks on output parameter values, invalid output parameters can be avoided from reducing the usability of the model processing results.

[0092] Content inspection in post-processing refers to performing security and compliance checks on the content of output parameter values ​​to prevent sensitive data, malicious injection, and compliance risks from leaking from the MCP Server results and infiltrating into subsequent processing in the LLM application, thereby improving the security of content flowing into the LLM application. For example, the customization information of the target customized MCP tool also includes second content inspection configuration information for customized output parameters. This second content inspection configuration information can include content inspection rules set for the customized output parameters. Based on the second content inspection configuration information, the security of the output parameter values ​​can be checked. If insecure output parameter values ​​are found, a fourth prompt message is sent to the MCP client. Content moderation services provided by extended service components can check the security of the output parameter values. The content moderation service can utilize a large model to moderate the content of the output parameter values. The large model used to moderate the content of the output parameter values ​​can be a general-purpose large language model. For example, prompt words can be generated based on the content of the output parameter values ​​(which may also include a preset sensitive word library), and the prompt words can be input into the large model to instruct it to moderate the content of the output parameter values. Content processing in post-processing refers to processing the results of the second tool call. Common processing methods include summarizing excessively long content and format conversion of complex content. Processing the results of the second tool call makes them more suitable for model processing. For example, the customization information of the target customized MCP tool also includes content processing configuration information, which may include processing rule descriptions of one or more content processing methods. The results of the second tool call can be processed based on the content processing configuration information. The content processing service provided by the extended service component can process the results of the second tool call. The content processing service can utilize a large model to process the results of the second tool call. For example, when the length of the second tool call result exceeds a threshold, a command model can be generated based on the second tool call result to summarize the result and obtain semantically unchanged prompts with a text length below the threshold. These prompts are then input into the large model, which summarizes the results of the second tool call. During step S208, the processed results of the second tool call can be sent to the MCP client.

[0093] In step S208, the service interface component can send the result of the second tool call to the MCP client.

[0094] After receiving the result of the second tool call, the MCP client can have the MCP host combine the result of the second tool call and the original question into a new prompt and send it to the model for inference to obtain the final answer to the original question, which is then provided to the user.

[0095] Thus, combined Figures 3 to 5 The document provides detailed instructions on customizing and using the MCP tool.

[0096] In the description of this specification, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Therefore, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0097] This specification also provides a computing device in its embodiments, including a memory and a processor. The memory stores computer programs / instructions, and when the processor executes the computer programs / instructions, it implements the methods in the foregoing embodiments.

[0098] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0099] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0100] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude the possibility that, with the future development of computer technology, the computer implementing the functions of the above embodiments can be, for example, a personal computer, a laptop computer, an in-vehicle human-machine interaction device, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0101] While one or more embodiments of this specification provide the operational steps of the methods described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or end product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in the process, method, product, or apparatus that includes the elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any particular order.

[0102] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in one or more software and / or hardware components, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms.

[0103] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0104] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0105] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0106] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0107] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0108] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0109] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0110] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0111] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, system embodiments are basically similar to method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. In the description of this specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0112] The above description is merely an embodiment of one or more embodiments of this specification and is not intended to limit the scope of these embodiments. Various modifications and variations can be made to these embodiments by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims.

Claims

1. A method for invoking a Model Context Protocol (MCP) tool, comprising: The system receives a first tool invocation request from an MCP client for a target customized MCP tool. The first tool invocation request includes first parameter information of at least some customized input parameters of the target customized MCP tool. The target customized MCP tool is a tool obtained by customizing a target MCP tool provided by a target MCP server. The number of customized input parameters is less than the number of input parameters of the target MCP tool. Based on the first tool invocation request, a second tool invocation request is generated for the target MCP tool, the second tool invocation request including second parameter information of the input parameters corresponding to the at least part of the customized input parameters; Send the second tool invocation request to the target MCP server.

2. The method according to claim 1, further comprising: Receive a first tool call result sent by the target MCP server, wherein the first tool call result includes third parameter information of at least some of the output parameters obtained by calling the target MCP tool to process the second tool call request; Based on the first tool call result, a second tool call result is generated. The second tool call result includes fourth parameter information of customized output parameters corresponding to at least some of the output parameters. The number of parameters of the customized output parameters is less than the number of parameters of the output parameters of the target MCP tool. The result of the second tool call is sent to the MCP client.

3. The method according to claim 2, wherein, The customization information of the target MCP tool includes a first constraint condition obtained by configuring the value range and / or value format of the customized input parameter. The method further includes: checking whether the format and / or value range of the input parameter value of the customized input parameter conforms to the first constraint condition; if there is an input parameter value that does not conform to the first constraint condition, then sending a first prompt message to the MCP client. And / or, The customization information of the target MCP tool includes a second constraint condition obtained by configuring the value range and / or value format of the customized output parameter. The method further includes: checking whether the format and / or value range of the output parameter value conforms to the second constraint condition; if there is an output parameter value that does not conform to the second constraint condition, then sending a second prompt message to the MCP client.

4. The method according to claim 2, wherein, The customization information of the target customized MCP tool also includes first content check configuration information for the customized input parameter settings. The method further includes: checking whether the content of the input parameter value is safe based on the first content check configuration information; if there is an unsafe input parameter value, sending a third prompt message to the MCP client. And / or, The customization information of the target customized MCP tool also includes second content checking configuration information for the customized output parameter settings. The method further includes: checking whether the content of the output parameter value is safe based on the second content checking configuration information; if there is an unsafe output parameter value, then sending a fourth prompt message to the MCP client.

5. The method according to claim 2, wherein, The customization information for the target customized MCP tool also includes content processing configuration information, and the method further includes: Based on the content processing configuration information, the result of the second tool call is processed. Sending the second tool call result to the MCP client includes: sending the processed second tool call result to the MCP client.

6. The method according to claim 1, further comprising: Receive the first tool acquisition request sent by the MCP client; The first tool information of at least a portion of the customized MCP tools in the customized MCP toolset is sent to the MCP client. The customized MCP toolset is a set of tools obtained by customizing the MCP toolset provided by one or more MCP servers. The number of customized MCP tools in the customized MCP toolset is less than the number of MCP tools in the MCP toolset. The first tool information includes customized parameter information of the customized input parameters of the customized MCP tools. The number of customized input parameters is less than the number of input parameters of the MCP tools.

7. The method according to claim 6, further comprising: Select the custom MCP tools that the MCP client has permission to use from the custom MCP tool set to obtain the at least partial custom MCP tools.

8. The method according to claim 6, wherein, The customized parameter information includes: a customized parameter description obtained by configuring the parameter description of the input parameter; and / or, a customized input parameter name obtained by configuring the input parameter name of the input parameter, and / or, The first tool information further includes: a customized tool description obtained by configuring the tool description of the MCP tool; and / or a customized tool name obtained by configuring the tool name of the MCP tool.

9. The method according to claim 1, further comprising: Send a second tool acquisition request to the target MCP server; Receive second tool information of all available MCP tools sent by the target MCP server, the second tool information including parameter information of the input parameters of the available MCP tools; Based on the second tool information, determine whether the target MCP tool corresponding to the target customized MCP tool is available, and / or determine whether the input parameters of the target MCP tool have changed; If the target MCP tool is unavailable or the input parameters of the target MCP tool change, a fifth prompt message is sent to the first MCP client.

10. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-9.