Model context protocol tool selection method and device and related equipment
Patent Information
- Application Number
- CN202511590717.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-03
- Publication Date
- 2026-01-30
Smart Images

Figure CN121436104A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, in particular to a model context protocol tool method, device and related equipment. BACKGROUND
[0002] Model Context Protocol (MCP) aims to unify the communication protocol between large language models and external data sources and functional interfaces. MCP also has great application prospects in wireless edge cloud agents. In the construction and intelligent management of wireless edge cloud platforms, MCP not only provides unified resource encapsulation and service interfaces, but also provides strong basic support for agent collaboration. Wireless edge cloud platforms usually integrate large language models (LLM) as core reasoning modules and interact with the external world through standardized protocol MCP to realize the perception of environmental state, understanding of task requirements and effective calling of external resources.
[0003] Currently, one MCP client (Client) maintains one-to-one connection with multiple MCP servers (Server), and when interacting with LLM, all tool information registered in the connected MCP Server is sent together for reasoning and calling, resulting in more token consumption and context occupation of LLM. SUMMARY
[0004] The purpose of the present application is to provide a model context protocol tool selection method, device and related equipment to avoid LLM using more tokens and context occupation.
[0005] To achieve the above purpose, an embodiment of the present application provides a model context protocol tool selection method, which is executed by a first device and includes:
[0006] In the case of receiving a user task request, the similarity score between the user task request and each tool is obtained; wherein the similarity score is used to represent the semantic matching degree between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit allowed by the model context protocol server to be provided to the large language model for calling;
[0007] According to the similarity score and the label confidence, a fusion score is determined; wherein the label confidence is used to represent the relevance of the corresponding tool in a specific field;
[0008] According to the preset threshold and the fusion score, a target tool is determined.
[0009] Optionally, the obtaining the similarity score between the user task request and each tool comprises:
[0010] inputting content of the user task request into the first model to obtain the similarity score output by the first model;
[0011] The first model is configured to obtain a semantic vector of the content of the user task request, compare the semantic vector with a semantic vector of each tool, and generate the similarity score between the user task request and each tool.
[0012] Optionally, the method further comprises:
[0013] obtaining a training and testing data set; wherein the training and testing data set comprises a plurality of input pairs and a similarity score of each input pair, each input pair comprises a user input and a tool, and the similarity score is determined based on a semantic correlation regression standard;
[0014] training the first model according to the training and testing data set.
[0015] Optionally, the determining the fusion score according to the similarity score and the label confidence comprises:
[0016] for a first tool, calculating a first result of a first fusion weight coefficient multiplied by the similarity score corresponding to the first tool, and a second result of a second fusion weight coefficient multiplied by the label confidence corresponding to the first tool;
[0017] adding the first result and the second result to obtain a fusion score corresponding to the first tool;
[0018] The first tool is any tool registered in the first device.
[0019] Optionally, the first fusion weight coefficient and the second fusion weight coefficient are added to equal 1.
[0020] Optionally, the method further comprises:
[0021] in a case where a second device applies for tool registration to the first device, assigning the second device with label information and the label confidence; wherein the label information comprises a category, a field and a use scenario of a model context protocol server.
[0022] Optionally, the determining the target tool according to the preset threshold and the fusion score comprises:
[0023] in a case where a second tool corresponds to a fusion score greater than the preset threshold, determining the second tool as the target tool.
[0024] Optionally, the value of the label confidence of the third tool is greater than the value of the label confidence of other tools except the third tool, the third tool includes a tool applied in a wireless edge cloud scenario, and a tool related to wireless and edge.
[0025] To achieve the above object, embodiments of the present application provide a model context protocol tool selection device, comprising:
[0026] A first processing module is configured to obtain a similarity score between a user task request and each tool when the user task request is received, wherein the similarity score is used to represent the semantic matching degree between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit allowed to be provided by a model context protocol server to a large language model call;
[0027] A second processing module is configured to determine a fusion score according to the similarity score and a label confidence, wherein the label confidence is used to represent the relevance of the corresponding tool in a specific field;
[0028] A third processing module is configured to determine a target tool according to a preset threshold and the fusion score.
[0029] Optionally, the first processing module is specifically configured to:
[0030] input the content of the user task request into the first model to obtain the similarity score output by the first model;
[0031] wherein the first model is used to obtain a semantic vector of the content of the user task request, and compare the semantic vector with the semantic vector of each tool to generate the similarity score between the user task request and each tool.
[0032] Optionally, the device further comprises:
[0033] A fourth processing module is configured to obtain a training and testing data set, wherein the training and testing data set comprises a plurality of input pairs and a similarity score of each input pair, each input pair comprises a user input and a tool, and the similarity score is determined based on a semantic correlation regression standard;
[0034] A model training module is configured to train the first model according to the training and testing data set.
[0035] Optionally, the third processing module is specifically configured to:
[0036] For the first tool, calculate a first result by multiplying the first fusion weight coefficient and the similarity score corresponding to the first tool, and a second result by multiplying the second fusion weight coefficient and the label confidence corresponding to the first tool;
[0037] The first result and the second result are added together to obtain the fusion score corresponding to the first tool;
[0038] The first tool can be any tool registered on the first device.
[0039] Optionally, the first fusion weight coefficient and the second fusion weight coefficient are added together to equal 1.
[0040] Optionally, the device further includes:
[0041] The fifth processing module is used to assign tag information and tag confidence to the second device when the second device applies for tool registration with the first device; wherein the tag information includes the category, domain and usage scenario of the model context protocol server.
[0042] Optionally, the third processing module is specifically used for:
[0043] If the fusion score corresponding to the second tool is greater than the preset threshold, the second tool will be identified as the target tool.
[0044] Optionally, the label confidence value of the third tool is greater than the label confidence value of other tools besides the third tool, the third tool including tools applied in wireless edge cloud scenarios, as well as tools related to wireless and edge.
[0045] To achieve the above objectives, embodiments of this application provide a network device, including a processor, the processor being used for:
[0046] Upon receiving a user task request, a similarity score is obtained between the user task request and each tool; wherein, the similarity score is used to represent the degree of semantic matching between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit that the Model Context Protocol server allows to be called by large language models;
[0047] A fusion score is determined based on the similarity score and the label confidence score; wherein the label confidence score is used to represent the relevance of the corresponding tool in a specific domain.
[0048] The target tool is determined based on the preset threshold and the fusion score.
[0049] To achieve the above objectives, embodiments of this application provide a network device, including a transceiver, a processor, a memory, and a program or instructions stored in the memory and executable on the processor; when the processor executes the program or instructions, it implements the model context protocol tool selection method as described above.
[0050] To achieve the above objectives, embodiments of this application provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps in the model context protocol tool selection method as described above.
[0051] To achieve the above objectives, embodiments of this application provide a computer program product, including computer instructions that, when executed by a processor, implement the steps of the model context protocol tool selection method as described above.
[0052] The beneficial effects of the above technical solution in this application are as follows:
[0053] The method in this application embodiment can, for a received user task request, obtain a similarity score between the request and each tool allowed by the MCPServer to be called by the LLM, then combine the similarity score and label confidence to determine a fusion score, and finally filter out the target tool based on a preset threshold and the fusion score. In this way, by fusing label confidence and semantic regression, the method filters out the target tools necessary for the user task requirements, reducing the transmission of irrelevant content and context occupancy, thereby effectively improving inference real-time performance, reducing resource consumption, and ensuring overall system performance in a wireless edge cloud platform environment. Attached Figure Description
[0054] Figure 1 This is a flowchart of a method according to an embodiment of this application;
[0055] Figure 2 This is a flowchart illustrating the application of the method in an embodiment of this application;
[0056] Figure 3 This is a schematic diagram of the module structure of the device according to an embodiment of this application;
[0057] Figure 4 This is a structural diagram of a network device according to an embodiment of this application;
[0058] Figure 5 This is a structural diagram of a network device according to another embodiment of this application. Detailed Implementation
[0059] To make the technical problems, technical solutions and advantages of this application clearer, a detailed description will be provided below in conjunction with the accompanying drawings and specific embodiments.
[0060] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.
[0061] In the various embodiments of this application, it should be understood that the sequence number of each process described below does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0062] In addition, the terms "system" and "network" are often used interchangeably in this article.
[0063] In the embodiments provided in this application, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined based on A. However, it should also be understood that determining B based on A does not mean that B is determined solely based on A, but can also be determined based on A and / or other information.
[0064] For ease of understanding, the following describes some aspects of the embodiments of this application:
[0065] LLM (Language Learning Model) is a type of deep learning model trained on large-scale data that can understand natural language input and generate natural language output. LLM possesses powerful language understanding, reasoning, and generation capabilities, and is widely used in question answering, dialogue systems, content generation, and intelligent decision-making.
[0066] An agent is an intelligent component with autonomous perception, reasoning, decision-making, and action capabilities, enabling it to dynamically respond based on goals and context in specific environments. In artificial intelligence systems, agents are typically organized around task-driven processes, capable of invoking models, tools, and external interfaces to complete complex processes such as information retrieval, resource scheduling, task orchestration, and feedback optimization.
[0067] MCP is an open standard that enables large language models to call external tools or access external data sources to enhance their reasoning and decision-making capabilities.
[0068] The MCP Client is the client component in the MCP standard, primarily responsible for managing communication with one or more MCP Servers. The MCP Client establishes a one-to-one connection with each MCP Server, obtains information on available tools from each MCP Server, organizes it uniformly, and then interacts with the large language model.
[0069] The MCP Server is the server-side component in the MCP standard. It typically registers and manages a set of tools that can be called by the language model. Each tool consists of a set of function descriptions, parameter definitions, and calling methods, used to support the model in completing specific tasks during inference.
[0070] A function is a functional unit within the MCP Server that is invoked by large language models. It typically includes a function description, input parameters, and return result definitions. By invoking a function, a model can perform specific data processing, service calls, or task execution.
[0071] In wireless edge cloud environments, Agents, as autonomous, task-driven intelligent entities, can dynamically acquire the status of heterogeneous resources based on the MCPserver tool and invoke the tool to perform operations such as deployment, monitoring, and optimization. With the help of MCPServer, Agents can efficiently schedule edge resources such as Graphics Processing Units (GPUs), Field Programmable Gate Arrays (FPGAs), and 5G / 6G network slices, completing a full closed loop from data acquisition and task inference to model collaborative optimization. It is foreseeable that the deep integration of MCP and Agent technologies will become an important direction for the intelligent evolution of future wireless edge clouds, supporting the key requirements of the 6G era for elastic, intelligent, and autonomous networks.
[0072] When there are a large number of MCP Servers, and each server provides a vast number of tools with complex descriptions, sending all tool information to the LLM at once results in extremely high token consumption. A large amount of tool information occupies the model's input context space, increasing the inference load, reducing inference response speed, and potentially causing context overflow issues. Furthermore, redundant transmission of irrelevant tool information also increases the communication burden between the Client and Model, leading to a decrease in overall system resource utilization. This challenge is even more pronounced in the relatively resource-constrained wireless edge cloud.
[0073] Secondly, in wireless edge cloud platform application scenarios, due to the limited computing resources and bandwidth of edge nodes, and the extremely high requirements for real-time response, the mechanism of sending all tool information at once exacerbates inference latency, affecting the rapid decision-making and service quality of the intelligent agent system. Inference tasks in edge environments typically have strict requirements for low latency and high performance; therefore, the token consumption problem is particularly prominent in this scenario, becoming a key obstacle restricting the scale and performance expansion of intelligent system applications.
[0074] like Figure 1As shown, an embodiment of this application provides a method for selecting a model context protocol tool, executed by a first device, comprising:
[0075] Step 101: Upon receiving a user task request, obtain the similarity score between the user task request and each tool; wherein, the similarity score is used to represent the degree of semantic matching between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit that the Model Context Protocol server allows to be called by large language models.
[0076] Step 102: Determine the fusion score based on the similarity score and the label confidence score; wherein the label confidence score is used to represent the relevance of the corresponding tool in a specific domain;
[0077] Step 103: Determine the target tool based on the preset threshold and the fusion score.
[0078] Following the steps described above, the first device can, for a received user task request, obtain its similarity score between the request and each tool allowed by the MCPServer to be called by the LLM. Then, it combines this similarity score with the label confidence score to determine a fusion score. Finally, based on a preset threshold and the fusion score, it filters out the target tool. In this way, by fusing label confidence and semantic regression, it filters out the target tools necessary for the user task requirements, reducing the transmission of irrelevant content and context occupancy. This effectively improves inference real-time performance, reduces resource consumption, and ensures overall system performance in the wireless edge cloud platform environment.
[0079] It should be noted that in this embodiment of the application, the first device can be an MCP client and the second device can be an MCP server.
[0080] Optionally, in this embodiment, obtaining the similarity score between the user task request and each tool includes:
[0081] Input the content of the user task request into the first model to obtain the similarity score output by the first model;
[0082] The first model is used to obtain the semantic vector of the content of the user task request, and compare the semantic vector with the semantic vector of each tool to generate a similarity score between the user task request and each tool.
[0083] That is, by using the first model, the semantic vector of the content of the user task request is obtained, and then the semantic vector is compared with the semantic vector of each tool to generate a similarity score between the user task request and each tool, so as to quickly and accurately determine the degree of semantic matching between the user task request and the functions of each tool.
[0084] The first model can be the SBERT model, which stands for Sentence-BERT. It is a variant of the BERT model. It obtains fixed-length sentence features by extending the pre-trained BERT model and is mainly used for sentence pair classification and calculating the similarity between two sentences.
[0085] Optionally, during the training process of the first model, continuous relevance scores are used as training labels, which can more accurately characterize the semantic distance between user needs and tool functions, as defined below:
[0086] Score Meaning 0.0 Not related at all 0.2 Weakly related 0.5 Vaguely related 0.8 Strongly related 1.0 Perfect match
[0087] Optionally, the method further includes:
[0088] Obtain training and testing datasets; wherein the training and testing datasets include multiple input pairs and a similarity score for each input pair, each input pair includes a user input and a tool, and the similarity score is determined based on a semantic relevance regression standard;
[0089] The first model is trained based on the training and testing datasets.
[0090] The user input can be collected natural language input (queries) from common scenarios in the wireless edge cloud environment. Each user input is paired with multiple MCP Server names, tool names, and tool function descriptions to form a user input and a tool input pair.
[0091] In this process, the similarity scores of each input pair are manually assigned based on semantic relevance regression criteria, thereby constructing high-quality training and testing datasets. The semantic relevance regression criteria include completely unrelated, weakly related, fuzzy, highly related, and perfectly matched.
[0092] For example, the training and testing datasets are shown below:
[0093] User input (Query) MCP Server + Tool description (Tool Text) Correlation score (Label) Notes Query all running Pods on an edge node mcp server: Kubernetes, Tool name: list_running_pods, tool description: List all running Pods on a specified edge node 1.0 Perfect match Monitor network quality of an edge node mcp server: RFMonitor, Tool name: get_rf_link_quality, tool description: Measure the radio frequency link quality between an edge node and a base station 0.8 Very related Check CPU utilization of an edge node mcp server: MetricsServer, Tool name: get_node_memory_usage, tool description: Get memory usage statistics of a specific node 0.5 Vaguely related Configure wireless parameters in an edge cloud mcp server: StorageManager, Tool name: create_storage_volume, tool description: Provide a new storage volume in an edge cloud environment 0.2 Weakly related Query weather conditions near a coffee shop mcp server: Kubernetes, Tool name: list_edge_nodes, tool description: List all registered edge computing nodes in a cluster 0.0 Not related at all
[0094] In this embodiment, the training objective is to enable the model to predict a continuous relevance score based on the semantic relationship between user input and tool description. During training, input pairs are first encoded into semantic vectors using Sentence-BERT; then, the predicted score is calculated using the cosine similarity between the vectors. The model employs cosine similarity loss as the training objective function, updates parameters using the AdamW optimizer, and incorporates appropriately set learning rate and weight decay hyperparameters. The entire training process involves multiple epochs, continuously monitoring performance changes on the validation set until the model converges, ensuring good generalization ability in real-world scenarios such as wireless edge cloud.
[0095] In this way, when applying the model, the first model can convert the functional descriptions of all registered tools and their MCP Server information into semantic vectors. These vectors represent the semantic features of the tools, which helps to reflect the similarity between the tool's functionality and the user's task input. After receiving the content of the user's task request input, the first model converts it into a semantic vector and compares it with the semantic vectors of all tools. At this point, it calculates and outputs the similarity score (SBERT_Score) between the content of the user's task request and each tool description, which is used together with the label confidence score to determine the fusion score, providing a basis for subsequent tool selection.
[0096] Optionally, in this embodiment, the label confidence value of the third tool is greater than the label confidence value of other tools besides the third tool, the third tool including tools applied in wireless edge cloud scenarios, as well as tools related to wireless and edge.
[0097] In other words, for tools applied in wireless edge cloud scenarios, and for tools related to wireless and edge, the label confidence value is higher than that of other tools.
[0098] Optionally, the method further includes:
[0099] When a second device applies for tool registration with the first device, tag information and tag confidence are assigned to the second device; wherein, the tag information includes the category, domain, and usage scenario of the Model Context Protocol server.
[0100] In other words, when the second device applies for tool registration with the first device, the first device will assign tag information and tag confidence level to the second device.
[0101] For example, on the MCP client side, when each MCP Server registers a tool, in addition to submitting the tool's functional description and parameter definitions, the MCP client also generates a set of tags for each MCP Server. These tags reflect the MCP Server's category, domain, and use case, such as "wireless communication," "data storage," and "K8s." Furthermore, each tag also includes a tag confidence level, which reflects the priority of that MCP Server in a specific domain or scenario.
[0102] Tag confidence reflects the importance of a particular MCP server in the current application. It is assigned to each tag by the MCP Client based on actual business needs and can be manually configured. For example, a higher tag confidence of 1.0 can be set for wireless communication tasks, while a lower tag confidence is set for non-communication tasks. For instance, a tag confidence of 0.7 is set for a Kubernetes MCP server related to wireless communication, while a lower tag confidence of 0.4 is set for some unrelated general-purpose MCP servers. For MCP servers, tag confidence can also be understood as the relevance of the service in a specific domain. Therefore, when users interact with the large model through a wireless edge application that integrates the tag confidence MCP Client, the MCP Client filters suitable tools based on semantic similarity, but simultaneously retains all tools from all MCP servers related to the wireless edge—that is, tools from MCP servers with high tag confidence—and sends them all to the large model. Finally, the large model's capabilities select the most suitable tool for processing.
[0103] Optionally, determining the fusion score based on the similarity score and label confidence includes:
[0104] For the first tool, calculate a first result by multiplying the first fusion weight coefficient and the similarity score corresponding to the first tool, and a second result by multiplying the second fusion weight coefficient and the label confidence corresponding to the first tool;
[0105] The first result and the second result are added together to obtain the fusion score corresponding to the first tool;
[0106] The first tool can be any tool registered on the first device.
[0107] That is, for the first tool, the sum of the first result Q and the second result P is the fusion score (FinalScore) corresponding to the first tool. This can be expressed by the formula: , , α is the first fusion weight coefficient, and β is the second fusion weight coefficient.
[0108] In this embodiment, the SBERT_Score ranges from [0, 1], and the TagConfidence ranges from [0, 1]. Scoring is achieved by balancing the first and second fusion weight coefficients.
[0109] Optionally, the first fusion weight coefficient and the second fusion weight coefficient are added together to equal 1.
[0110] so, α represents the balance between semantic relevance and label confidence. α balances the importance of user task requests and the MCP Server tool itself during the scoring process.
[0111] Optionally, α=0.3 further emphasizes the importance of TagConfidence to the overall score. Of course, the specific value of α can be adjusted according to the actual application scenario.
[0112] Optionally, in this embodiment, determining the target tool based on a preset threshold and the fusion score includes:
[0113] If the fusion score corresponding to the second tool is greater than the preset threshold, the second tool will be identified as the target tool.
[0114] Thus, after setting a preset threshold, the selection of target tools is completed by determining whether the fusion score is greater than the preset threshold. Specifically, the second tool with a fusion score greater than or equal to the preset threshold is determined as the target tool, and the number of tools and the comprehensiveness of tool selection are balanced by controlling the preset threshold.
[0115] For example, with a preset threshold of 0.6, tools with a FinalScore > 0.6 are identified as target tools, and only those with scores higher than 0.6 are accepted during tool filtering. In practical wireless edge cloud application scenarios, this threshold ensures that highly relevant tools are selected.
[0116] Optionally, in this embodiment, after the first device filters out the target tools, it sends the filtered tools to the LLM. For example, such as... Figure 2 As shown, after the MCP Client filters out the target tool, it sends it to the LLM along with the content of the user's task request via message 1. The LLM then directly calls the target tool from the MCP server.
[0117] In summary, the method of this application embodiment performs a post-fusion of semantic relevance and tool type domain bias. Specifically, this application combines the similarity score (semantic similarity score) generated by a fine-tuned Sentence-BERT (SBERT) regression model with manually set label confidence, and obtains the final fusion score (tool selection score) through linear weighted fusion, and then sorts and selects the most relevant tools based on this score. This achieves the following technical effects:
[0118] Reduce token consumption: By filtering out relevant tools and transmitting only a small amount of tool information to the LLM, token consumption is significantly reduced;
[0119] Reduce inference latency: By simplifying tool information and the inference process, ensure rapid response to meet the low latency requirements in wireless edge cloud environments;
[0120] Improve selection accuracy: Combine semantic similarity and label confidence to ensure high relevance and accuracy in tool selection;
[0121] Supports intelligent task scheduling with high concurrency and low latency: adapts to high-concurrency scenarios in edge cloud platforms, can handle a large number of task requests, and ensures real-time performance.
[0122] like Figure 3 As shown, an embodiment of this application provides a model context protocol tool selection device 300, comprising:
[0123] The first processing module 310 is used to obtain a similarity score between the user task request and each tool when a user task request is received; wherein the similarity score is used to represent the degree of semantic matching between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit that the model context protocol server allows to be called by a large language model.
[0124] The second processing module 320 is used to determine a fusion score based on the similarity score and the label confidence score; wherein the label confidence score is used to represent the relevance of the corresponding tool in a specific field;
[0125] The third processing module 330 is used to determine the target tool based on a preset threshold and the fusion score.
[0126] This device can, for a received user task request, obtain a similarity score between the request and each tool allowed by the MCP Server to be called by the LLM, then combine the similarity score and label confidence to determine a fusion score, and finally filter out the target tool based on a preset threshold and the fusion score. In this way, by fusing label confidence and semantic regression, the target tool necessary for the user task requirement is selected, reducing the transmission of irrelevant content and context occupation, thereby effectively improving inference real-time performance, reducing resource consumption, and ensuring overall system performance in the wireless edge cloud platform environment.
[0127] Optionally, the first processing module is specifically used for:
[0128] Input the content of the user task request into the first model to obtain the similarity score output by the first model;
[0129] The first model is used to obtain the semantic vector of the content of the user task request, and compare the semantic vector with the semantic vector of each tool to generate a similarity score between the user task request and each tool.
[0130] Optionally, the device further includes:
[0131] The fourth processing module is used to acquire training and testing datasets; wherein the training and testing datasets include multiple input pairs and a similarity score for each input pair, each input pair includes a user input and a tool, and the similarity score is determined based on a semantic relevance regression standard;
[0132] The model training module is used to train the first model based on the training and testing datasets.
[0133] Optionally, the third processing module is specifically used for:
[0134] For the first tool, calculate a first result by multiplying the first fusion weight coefficient and the similarity score corresponding to the first tool, and a second result by multiplying the second fusion weight coefficient and the label confidence corresponding to the first tool;
[0135] The first result and the second result are added together to obtain the fusion score corresponding to the first tool;
[0136] The first tool can be any tool registered on the first device.
[0137] Optionally, the first fusion weight coefficient and the second fusion weight coefficient are added together to equal 1.
[0138] Optionally, the device further includes:
[0139] The fifth processing module is used to assign tag information and tag confidence to the second device when the second device applies for tool registration with the first device; wherein the tag information includes the category, domain and usage scenario of the model context protocol server.
[0140] Optionally, the third processing module is specifically used for:
[0141] If the fusion score corresponding to the second tool is greater than the preset threshold, the second tool will be identified as the target tool.
[0142] Optionally, the label confidence value of the third tool is greater than the label confidence value of other tools besides the third tool, the third tool including tools applied in wireless edge cloud scenarios, as well as tools related to wireless and edge.
[0143] It should be noted that this device is an apparatus that applies the above-described method, and the implementation of the above-described method embodiments is applicable to this device and can achieve the same technical effect.
[0144] Furthermore, the modules of this device can be implemented as follows:
[0145] MCP Server Tag System Controller: Builds the MCP Server tag system for MCP Server.
[0146] Semantic Similarity Model Controller: Constructs the first model based on the MCP Server and completes the semantic vector encoding of the MCP Server.
[0147] MCP Tool Selection Controller: During the MCP tool selection process, similarity scores are calculated based on user input and label confidence values are obtained. Based on the fusion score (the score obtained by the post-fusion linear scoring mechanism) and preset thresholds, the tool selection is completed and the results are handed over to LLM.
[0148] like Figure 4 As shown, a network device 400 according to an embodiment of this application includes a processor 410 and a transceiver 420, wherein,
[0149] The processor is used for:
[0150] Upon receiving a user task request, a similarity score is obtained between the user task request and each tool; wherein, the similarity score is used to represent the degree of semantic matching between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit that the Model Context Protocol server allows to be called by large language models;
[0151] A fusion score is determined based on the similarity score and the label confidence score; wherein the label confidence score is used to represent the relevance of the corresponding tool in a specific domain.
[0152] The target tool is determined based on the preset threshold and the fusion score.
[0153] This device can, for a received user task request, obtain a similarity score between the request and each tool allowed by the MCP Server to be called by the LLM, then combine this similarity score with the label confidence score to determine a fusion score, and finally filter out the target tool based on a preset threshold and the fusion score. In this way, by fusing label confidence and semantic regression, the target tool necessary for the user task requirement is selected, reducing the transmission of irrelevant content and context occupation, thereby effectively improving inference real-time performance, reducing resource consumption, and ensuring overall system performance in the wireless edge cloud platform environment.
[0154] Optionally, the processor is further configured to:
[0155] Input the content of the user task request into the first model to obtain the similarity score output by the first model;
[0156] The first model is used to obtain the semantic vector of the content of the user task request, and compare the semantic vector with the semantic vector of each tool to generate a similarity score between the user task request and each tool.
[0157] Optionally, the processor is further configured to:
[0158] Obtain training and testing datasets; wherein the training and testing datasets include multiple input pairs and a similarity score for each input pair, each input pair includes a user input and a tool, and the similarity score is determined based on a semantic relevance regression standard;
[0159] The first model is trained based on the training and testing datasets.
[0160] Optionally, the processor is further configured to:
[0161] For the first tool, calculate a first result by multiplying the first fusion weight coefficient and the similarity score corresponding to the first tool, and a second result by multiplying the second fusion weight coefficient and the label confidence corresponding to the first tool;
[0162] The first result and the second result are added together to obtain the fusion score corresponding to the first tool;
[0163] The first tool can be any tool registered on the first device.
[0164] Optionally, the first fusion weight coefficient and the second fusion weight coefficient are added together to equal 1.
[0165] Optionally, the processor is further configured to:
[0166] When a second device applies for tool registration with the first device, tag information and tag confidence are assigned to the second device; wherein, the tag information includes the category, domain, and usage scenario of the Model Context Protocol server.
[0167] Optionally, the processor is further configured to:
[0168] If the fusion score corresponding to the second tool is greater than the preset threshold, the second tool will be identified as the target tool.
[0169] Optionally, the label confidence value of the third tool is greater than the label confidence value of other tools besides the third tool, the third tool including tools applied in wireless edge cloud scenarios, as well as tools related to wireless and edge.
[0170] Another embodiment of this application provides a network device, such as... Figure 5 As shown, it includes a transceiver 510, a processor 500, a memory 520, and a program or instructions stored in the memory 520 and executable on the processor 500; when the processor 500 executes the program or instructions, it implements the above-mentioned Model Context Protocol tool selection.
[0171] The transceiver 510 is used to receive and send data under the control of the processor 500.
[0172] Among them, Figure 5 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits together, represented by one or more processors (processor 500) and memory (memory 520). The bus architecture can also link together various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface. The transceiver 510 can be multiple elements, including transmitters and receivers, providing a unit for communicating with various other devices over a transmission medium.
[0173] The processor 500 is responsible for managing the bus architecture and general processing, while the memory 520 can store the data used by the processor 500 when performing operations.
[0174] This application provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the steps in the model context protocol tool selection method described above and achieve the same technical effect. To avoid repetition, this will not be repeated here.
[0175] The processor is the processor in the network device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0176] This application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the above-described... Figure 1 or Figure 2 The various processes of the method embodiments shown can achieve the same technical effect, and will not be described again here to avoid repetition.
[0177] It should be further noted that the terminals described in this specification include, but are not limited to, smartphones, tablets, etc., and many of the functional components described are referred to as modules in order to emphasize the independence of their implementation.
[0178] In this embodiment, the module can be implemented in software so that it can be executed by various types of processors. For example, an identified executable code module may include one or more physical or logical blocks of computer instructions, which may be constructed as objects, procedures, or functions. Nevertheless, the executable code of the identified module does not need to be physically located together, but may include different instructions stored in different bits, which, when logically combined, constitute the module and achieve the module's intended purpose.
[0179] In practice, an executable code module can be a single instruction or many instructions, and can even be distributed across multiple different code segments, different programs, and across multiple memory devices. Similarly, operational data can be identified within the module and can be implemented in any suitable form and organized within any suitable data structure. This operational data can be collected as a single dataset or distributed across different locations (including different storage devices), and can exist, at least in part, solely as electronic signals within the system or network.
[0180] When a module can be implemented using software, considering the current level of hardware technology, modules that can be implemented in software can be implemented using hardware circuits by those skilled in the art to achieve the corresponding functions, without considering cost. These hardware circuits include conventional very-large-scale integrated circuits (VLSI) or gate arrays, as well as existing semiconductors such as logic chips and transistors, or other discrete components. Modules can also be implemented using programmable hardware devices, such as field-programmable gate arrays, programmable array logic, and programmable logic devices.
[0181] The exemplary embodiments described above are with reference to the accompanying drawings. Many different forms and embodiments are feasible without departing from the spirit and teachings of this application. Therefore, this application should not be construed as limiting the exemplary embodiments set forth herein. Rather, these exemplary embodiments are provided to make this application complete and convey the scope of this application to those skilled in the art. In these drawings, component dimensions and relative dimensions may be exaggerated for clarity. The terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. As used herein, unless clearly indicated otherwise, the singular forms “a,” “an,” and “the” are intended to include all such forms. It will be further understood that the terms “comprising” and / or “including”, when used in this specification, indicate the presence of the stated features, integers, steps, operations, components, and / or elements, but do not exclude the presence or addition of one or more other features, integers, steps, operations, components, and / or groups thereof. Unless otherwise indicated, when stated, a range of values includes the upper and lower limits of the range and any subranges in between.
[0182] The above description is the preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principles described in this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A model context protocol tool selection method, characterized by, The method is performed by a first device, comprising: In the case of receiving a user task request, obtaining a similarity score between the user task request and each tool; wherein the similarity score is used to represent the degree of semantic matching between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit allowed to be provided to a large language model call by a model context protocol server; According to the similarity score and the label confidence, a fusion score is determined; wherein the label confidence is used to represent the relevance of the corresponding tool in a specific field; According to a preset threshold and the fusion score, a target tool is determined.
2. The method of claim 1, wherein, The obtaining of the similarity score between the user task request and each tool comprises: Inputting the content of the user task request into a first model to obtain the similarity score output by the first model; Wherein, the first model is used to obtain the semantic vector of the content of the user task request, and compare the semantic vector with the semantic vector of each tool to generate the similarity score between the user task request and each tool.
3. The method of claim 2, wherein, Further comprising: Obtaining a training and testing data set; wherein the training and testing data set comprises a plurality of input pairs and a similarity score of each input pair, each input pair comprising a user input and a tool, and the similarity score is determined based on a semantic relevance regression standard; Training the first model according to the training and testing data set.
4. The method of claim 1, wherein, The determination of the fusion score according to the similarity score and the label confidence comprises: For a first tool, calculating a first result of a first fusion weight coefficient multiplied by the similarity score corresponding to the first tool, and a second result of a second fusion weight coefficient multiplied by the label confidence corresponding to the first tool; Adding the first result and the second result to obtain the fusion score corresponding to the first tool; Wherein, the first tool is any tool registered in the first device.
5. The method of claim 4, wherein, The sum of the first fusion weight coefficient and the second fusion weight coefficient is equal to 1.
6. The method of claim 4, wherein, Further comprising: In the case that a second device applies for tool registration to the first device, assigning label information and the label confidence to the second device; wherein the label information comprises the category, field and use scenario of the model context protocol server.
7. The method of claim 1, wherein, The determination of the target tool according to the preset threshold and the fusion score comprises: In the case that the fusion score corresponding to a second tool is greater than the preset threshold, the second tool is determined as the target tool.
8. The method of claim 1, wherein, The value of the label confidence of a third tool is greater than the value of the label confidence of other tools except the third tool, the third tool comprises a tool applied in a wireless edge cloud scenario, and a tool related to wireless and edge.
9. A model context protocol tool selection apparatus characterized by, Comprise: A first processing module is configured to, in the case of receiving a user task request, obtain a similarity score between the user task request and each tool; wherein the similarity score is used to represent the degree of semantic matching between the content of the user task request and the function of the corresponding tool, and the tool is a functional unit allowed to be provided to a large language model call by a model context protocol server; The second processing module is configured to determine a fusion score according to the similarity score and a label confidence, wherein the label confidence is used to represent the relevance of the corresponding tool in a specific field. The third processing module is configured to determine a target tool according to a preset threshold and the fusion score.
10. A network device, comprising: The processor is configured to: In a case where a user task request is received, a similarity score between the user task request and each tool is obtained, wherein the similarity score is used to represent a semantic matching degree between content of the user task request and a function of a corresponding tool, and the tool is a functional unit allowed to be provided by a model context protocol server to a large language model call; determine a fusion score according to the similarity score and a label confidence, wherein the label confidence is used to represent the relevance of the corresponding tool in a specific field; determine a target tool according to a preset threshold and the fusion score.
11. A network device comprising: The transceiver, the processor, the memory, and a program or instructions stored on the memory and executable on the processor; and the processor implements the model context protocol tool selection method according to any one of claims 1-8 when executing the program or instructions.
12. A readable storage medium, on which a program or instructions are stored, characterized in that, The program or instructions are executed by the processor to implement the steps in the model context protocol tool selection method according to any one of claims 1-8.
13. A computer program product, characterised in that, The computer instructions are executed by the processor to implement the steps in the model context protocol tool selection method according to any one of claims 1-8.