Event-driven artificial intelligence context protocol service registration and discovery method

By using new equipment and methods, the problem of service discovery that cannot be solved in existing technologies is solved, event-driven technical means are implemented, and technical applications of service discovery are realized, which are suitable for efficient service discovery and management, and technical means of service discovery are implemented. Millisecond-level state perception is achieved, polling overhead is avoided, and service continuity is ensured through intelligent matching and session recovery.

CN120751002AActive Publication Date: 2025-10-03BEIJING CAPITEK

Patent Information

Application Number
CN202511220734.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-29
Publication Date
2025-10-03
Estimated Expiration
2045-08-29

AI Technical Summary

Technical Problem

Existing service registration and discovery solutions have problems such as delayed state change perception, high network overhead caused by frequent polling, and lack of semantic matching capabilities.

Method used

It adopts an event-driven artificial intelligence context protocol service registration and discovery method. By receiving service instance registration requests, it builds an MCP service registry, performs health checks, monitors state changes and generates events, establishes long connections for real-time push, realizes automatic reconnection and session recovery, and performs capability matching based on semantic understanding.

Benefits of technology

It achieves millisecond-level state change perception, avoids polling delays and resource overhead, realizes intelligent matching of service discovery, ensures high efficiency, reliability and real-time performance of service discovery, and is suitable for efficient and reliable service discovery. It achieves high efficiency, reliability and real-time performance of service discovery, and is suitable for intelligent matching application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120751002A_ABST
    Figure CN120751002A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of protocol services, in particular to an event-driven artificial intelligence context protocol service registration and discovery method. The method comprises the following steps: firstly, receiving a service instance registration request, constructing a service registry, and recording a service address and capability description; obtaining the health state of the instance through heartbeat detection; monitoring the state change and converting the state change into a standard event; the SSE technology is adopted to establish long connection and push the filtered events in real time; client connection is maintained, and automatic reconnection and session recovery during abnormity are realized; service capability is analyzed based on semantic comprehension, and accurate matching of requirements is realized; millisecond-level state perception is realized, polling overhead is avoided, service continuity is ensured through intelligent matching and session recovery, and the method is suitable for high-real-time intelligent agent application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of protocol services, and in particular to an event-driven artificial intelligence context protocol service registration and discovery method. Background Art

[0002] With the rapid development of artificial intelligence (AI), intelligent agent applications based on large language models are becoming increasingly popular. To standardize the interaction between intelligent agents and external tools and ensure interoperability between systems, unified communication standards and service governance mechanisms are necessary. In this context, service registration and discovery have become the core infrastructure of intelligent agent systems.

[0003] Currently, the most commonly used service registration and discovery solutions are based on a polling mechanism, where service instances periodically send heartbeat packets to a registry to report their status. Clients periodically query the registry to obtain a list of available services and select a service instance based on a load balancing strategy.

[0004] However, existing technologies suffer from delayed perception of service status changes, frequent polling that causes a large amount of network overhead, and lack semantic matching capabilities, which needs to be further improved. Summary of the Invention

[0005] To address the issues of state change perception delay, high polling overhead, and lack of semantic matching capabilities in existing service registration and discovery solutions, this application provides an event-driven artificial intelligence context protocol service registration and discovery method, which adopts the following technical solutions: In a first aspect, the present application provides an event-driven artificial intelligence context protocol service registration and discovery method, comprising the following steps: Receive the registration request of the service instance, build the artificial intelligence context protocol service registry, and obtain the service instance information; Perform health checks based on the service instance information to obtain health status information of the service instance; Based on the health status information, monitor the service instance status changes and generate corresponding events to obtain status change information; Based on the status change information, a server-sent event technology is used to establish a persistent connection with the client and perform event filtering to obtain real-time push events related to the client's subscription service; Maintaining the client connection status and implementing automatic reconnection and session recovery based on the real-time push event, and obtaining client connection management information; According to the client connection management information, the capability description of the service instance is analyzed and matched based on semantic understanding to obtain service instance information that meets the client functional requirements.

[0006] By adopting the above technical solution, this application first receives a service instance registration request and builds an MCP service registry to record instance information including service address, capability description, etc.; then performs health checks on the registered service instances, and obtains health status in real time through means such as heartbeat detection; then monitors service instance status changes and converts the changes into a standard event format; then uses SSE technology to establish a long connection with the client that subscribes to the relevant service, and pushes the events in real time after filtering; on this basis, maintains the client connection status, and automatically reconnects and restores the session when a connection abnormality is detected; finally, based on semantic understanding technology, the capability description of the service instance is analyzed to achieve accurate matching of client requirements and service capabilities; millisecond-level state change perception is achieved through an event-driven mechanism, avoiding the delay and resource overhead caused by polling; intelligent matching of service capabilities is achieved through semantic understanding; service continuity is ensured through automatic reconnection and session recovery, which is particularly suitable for intelligent application scenarios with high real-time requirements.

[0007] Optionally, based on the health status information, monitoring service instance status changes and generating corresponding events to obtain status change information specifically includes the following steps: Monitoring service instance status changes based on the health status information; Accumulate multiple state change events of the same type and service within a preset time window into batch events; Aggregate multiple service instance state change events identified by the same physical location into region-level events; Identify continuous state change events with temporal correlation as service instance fluctuation events; The batch events, region-level events, and service instance fluctuation events are merged to obtain compressed state change information.

[0008] By adopting the above technical solution, the present application first continuously monitors the state changes of service instances through health detection; then sets a sliding window in the time dimension, accumulates multiple state changes of the same type and the same service that occur during the window period into a batch event, aggregates the state changes of multiple service instances into regional-level events based on physical location identifiers in the spatial dimension, analyzes the temporal correlation of events in the semantic dimension, and identifies continuous state changes reflecting repeated fluctuations of the same service instance as fluctuation events; finally, merges the compression results of these three dimensions to generate the final state change information; multi-dimensional event compression significantly reduces the system overhead of event processing and push, while retaining the core semantic information of the event, avoiding information loss due to excessive compression, and providing an efficient and reliable technical solution for the state management of large-scale service clusters.

[0009] Optionally, performing a health check based on the service instance information to obtain health status information of the service instance specifically includes the following steps: Receive heartbeat requests sent periodically by service instances, and actively detect instances that fail to send heartbeats in a timely manner to obtain health detection data of service instances; Calculating a stability index of the service instance based on the health check data, where the stability index is determined based on a health check success rate and a recent failure weight factor; Dynamically adjust the health check frequency of the service instance according to the stability index to obtain a health check strategy for the service instance; Based on the health detection data and the health detection strategy, the health status of the service instance is divided into multiple levels to obtain the health status information of the service instance.

[0010] By adopting the above technical solution, the present application first obtains basic health data by receiving heartbeat requests sent periodically by service instances, and immediately starts an active detection mechanism for instances that fail to send heartbeats on time, and detects the instance status through multiple network protocols; then, based on the collected health detection data, the stability index of the service instance is calculated. The index comprehensively considers the historical detection success rate and the impact weight of recent failures, so that recent failures can receive more attention; then, the detection frequency is dynamically adjusted according to the stability index, the detection frequency is increased for instances with poor stability in order to discover problems faster, and the detection frequency is appropriately reduced for instances with good stability to reduce system overhead; finally, the health status of the service instance is subdivided into multiple levels, providing a more fine-grained basis for subsequent load balancing and failover decisions; the intelligent health detection mechanism significantly improves the accuracy of health status judgment, avoids service switching oscillations caused by misjudgment, and at the same time, the optimal utilization of system resources is achieved by dynamically adjusting the detection strategy, providing reliable guarantee for the stable operation of the MCP service.

[0011] Optionally, based on the state change information, a server-sent event technology is used to establish a persistent connection with the client and perform event filtering to obtain real-time push events related to the client's subscription service, specifically including the following steps: Associating a version vector with each service instance state, the version vector contains the modification count of each node to the corresponding instance state; Determine the causal relationship of state change events by comparing version vectors, and identify state conflicts caused by concurrent events; Applying predefined resolution rules to the state conflicts, the resolution rules including: prioritizing the unavailable state when there is a state availability conflict, prioritizing field-level merging when there is a metadata change conflict, and prioritizing the configuration with a higher version number when there is a configuration conflict; Based on the resolved status change information, real-time events are pushed to clients subscribed to the corresponding service.

[0012] By adopting the above technical solution, this application first associates a version vector with the state of each service instance, which records the number of times each management node has modified the instance state; then, by comparing the version vectors of different events, the causal relationship between them is determined, thereby identifying state conflicts caused by concurrent operations; then, predefined conflict resolution rules are applied, including giving priority to the unavailable state when the availability state conflicts to ensure system security, adopting a field-level merge strategy to retain the modifications of both parties when the service metadata conflicts, and giving priority to the configuration with a higher version number when the configuration information conflicts to ensure forward compatibility of the configuration; finally, the conflict-resolved state change information is pushed to the client that has subscribed to the corresponding service through the SSE long connection; the final consistency of the service state in a distributed environment is achieved through the version vector mechanism, and the reliability and correctness of the state update are ensured through a fine-grained conflict resolution strategy, providing a strong consistency guarantee for distributed service governance.

[0013] Optionally, according to the client connection management information, the capability description of the service instance is analyzed and matched based on semantic understanding to obtain service instance information that meets the client functional requirements, specifically including the following steps: receiving a functional requirement description of the client according to the client connection management information, and converting the functional requirement description into a standardized capability matching condition based on semantic understanding; Retrieving a service instance with matching capabilities from a service registry according to the capability matching condition; Verify the compatibility of the service instance with the interface requested by the client, and filter out available candidate service instances; Monitor the capability change events of the candidate service instances, dynamically update the matching results, and obtain service instance information that meets the client's functional requirements.

[0014] By adopting the above technical solution, this application first receives the functional requirement description sent by the client, uses natural language processing technology to perform semantic analysis on the requirements, extracts key capability elements and converts them into standardized matching conditions; then, based on these matching conditions, retrieves service instances with corresponding capabilities in the service registry, and finds potential matching instances through semantic similarity calculation; then, verifies the interface compatibility of the matched service instances to ensure that the client can call the service interface normally; finally, continuously monitors the capability change events of candidate service instances, and automatically re-evaluates the matching relationship when the capability of the service instance changes, to ensure that the client can always obtain the service instance that best meets the requirements; the accuracy of service matching is significantly improved through in-depth understanding at the semantic level, and the real-time effectiveness of the matching results is guaranteed through dynamic monitoring and update mechanisms, providing more accurate service discovery capabilities for intelligent applications.

[0015] Optionally, maintaining the client connection status and implementing automatic reconnection and session recovery based on the real-time push event to obtain client connection management information specifically includes the following steps: Record the running status of the current session, including the conversation context, model parameters, and intermediate calculation results; Detecting service instance availability information in the real-time push event, and triggering automatic reconnection when the service instance is unavailable; Select an available instance with the same capabilities from the service registry for reconnection, and migrate the running state to the new instance; Client requests are cached during session migration, and the cached requests are processed in a time sequence after migration is completed to ensure service continuity.

[0016] By adopting the above technical solution, this application first continuously records the complete running status of the current session, including key information such as conversation history, interaction context, model configuration parameters, and intermediate calculation results that have not yet been returned to the client; then monitors the availability status of the service instance in real time, and immediately triggers the automatic reconnection mechanism when it detects that the current service instance is unavailable; then searches for available instances with the same capability description from the service registry, prioritizes the instance with the most similar configuration as the reconnection target, and migrates the previously saved complete running status to the new instance to ensure that the new instance can seamlessly continue the previous session; during the state migration process, the system will temporarily cache new requests sent by the client, and after the migration is completed, process these requests in the original time sequence, thereby ensuring the continuity and correctness of request processing; the intelligent state migration mechanism realizes imperceptible switching when switching service instances, and ensures the integrity of the business process through request caching and replay, providing a high-availability service guarantee mechanism for intelligent applications.

[0017] In a second aspect, the present application provides an event-driven artificial intelligence context protocol service registration and discovery device, the device comprising: The service registration module is used to receive registration requests for service instances, build an artificial intelligence context protocol service registry, and obtain service instance information; A health detection module is used to perform health detection based on the service instance information to obtain health status information of the service instance; An event monitoring module is used to monitor service instance status changes and generate corresponding events based on the health status information to obtain status change information; An event push module is used to establish a persistent connection with the client and perform event filtering based on the state change information using server-sent event technology to obtain real-time push events related to the client's subscription service; A connection management module is used to maintain the client connection status and realize automatic reconnection and session recovery according to the real-time push event, and obtain client connection management information; The capability matching module is used to analyze and match the capability description of the service instance based on the client connection management information and semantic understanding, so as to obtain service instance information that meets the client functional requirements.

[0018] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, the steps of the above-mentioned event-driven artificial intelligence context protocol service registration and discovery method are implemented.

[0019] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned event-driven artificial intelligence context protocol service registration and discovery method.

[0020] In summary, this application includes at least one of the following beneficial technical effects: This application first receives service instance registration requests and builds a service registry, recording service addresses and capability descriptions; obtains instance health status through heartbeat detection; monitors state changes and converts them into standard events; uses SSE technology to establish long connections and push filtered events in real time; maintains client connections and implements automatic reconnection and session recovery in the event of anomalies; analyzes service capabilities based on semantic understanding to achieve precise demand matching; achieves millisecond-level state perception, avoids polling overhead, and ensures service continuity through intelligent matching and session recovery, making it suitable for high-real-time intelligent agent application scenarios; This application monitors the status of service instances through health checks. It uses a sliding window to accumulate similar state changes into batch events in the time dimension, aggregates them into regional events based on physical location in the spatial dimension, and identifies continuously fluctuating states in the semantic dimension. Finally, it combines the three-dimensional compression results to generate state change information. This reduces system overhead while preserving core semantics and avoiding information loss, providing an efficient state management solution for large-scale service clusters. This application obtains instance health data by receiving heartbeat requests and active detection; calculates a stability index based on historical success rates and recent failure weights; dynamically adjusts the detection frequency according to the index, encrypts detection for unstable instances, and reduces the frequency for stable instances; subdivides health status into multiple levels for load balancing decisions; improves the accuracy of health status determination, avoids service switching shocks caused by misjudgment, optimizes resource utilization through dynamic detection strategies, and ensures stable service operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is a flow chart of an event-driven artificial intelligence context protocol service registration and discovery method according to an embodiment of the present application; Figure 2 This is a diagram of the MCP server registration center system architecture in an embodiment of the present application; Figure 3 This is a flow chart of step S200 in the event-driven artificial intelligence context protocol service registration and discovery method according to an embodiment of the present application; Figure 4 This is a flow chart of step S300 in the event-driven artificial intelligence context protocol service registration and discovery method according to an embodiment of the present application; Figure 5 This is a flow chart of step S400 in the event-driven artificial intelligence context protocol service registration and discovery method according to an embodiment of the present application; Figure 6 This is a flow chart of step S500 in the event-driven artificial intelligence context protocol service registration and discovery method according to an embodiment of the present application; Figure 7 This is a flow chart of step S600 in the event-driven artificial intelligence context protocol service registration and discovery method according to an embodiment of the present application; Figure 8 This is a module diagram of an event-driven artificial intelligence context protocol service registration and discovery device according to an embodiment of the present application; Figure 9 This is a diagram of the internal structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0022] The terms used in the following examples of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification and appended claims of this application, the singular expressions "a," "an," "said," "above," "the," and "this" are intended to include plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in this application refers to any or all possible combinations comprising one or more of the listed items.

[0023] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.

[0024] The embodiments of the present application are described in further detail below with reference to the accompanying drawings.

[0025] In the first aspect, the present application provides an event-driven artificial intelligence context protocol service registration and discovery method, referring to Figure 1 , including the following steps: S100. Receive a registration request for a service instance, build an artificial intelligence context protocol service registry, and obtain service instance information.

[0026] In this embodiment, the Artificial Intelligence Context Protocol (MCP) service registry is a distributed data storage structure used to record the basic information of service instances. After the MCP service instance is started, it sends a registration request to the registration center, which contains information such as the service name, network address, capability description, and metadata. The registration center verifies the validity of the request, generates a globally unique instance ID, and stores the service instance information in the service registry. The registration center generates an INSTANCE_ADDED event and pushes the event to all clients subscribed to the corresponding service through the event push engine. The service instance begins to send heartbeat requests regularly to maintain its active status in the registration center.

[0027] S200: Perform health detection based on the service instance information to obtain health status information of the service instance.

[0028] In this embodiment, health checks are performed on registered service instances, and their health status is obtained in real time through heartbeat detection and other means. This embodiment uses a two-way health check mechanism, in which service instances periodically (5 seconds by default) send heartbeats to the registration center, and the registration center actively detects the service health status periodically (10 seconds by default). If three consecutive checks fail, the instance is marked as unavailable.

[0029] S300: Monitor service instance status changes based on health status information and generate corresponding events to obtain status change information.

[0030] In this embodiment, when a service status changes (such as a new instance registration or instance decommissioning), the registry generates corresponding events. For example, when all instances of a service are unavailable, a SERVICE_EMPTY event is generated; when a new instance of a service that previously had all instances unavailable comes online, a SERVICE_RESTORED event is generated.

[0031] S400: Based on the status change information, a server-sent event technology is used to establish a long connection with the client and perform event filtering to obtain real-time push events related to the client's subscription service.

[0032] In this embodiment, Server Sent Events (SSE) technology is a one-way communication protocol based on HTTP, used for the server to push data streams to the client. The event push engine pushes events to the relevant clients through the established SSE connection based on the subscription relationship.

[0033] S500: Maintain the client connection status and implement automatic reconnection and session recovery based on the real-time push event, and obtain client connection management information.

[0034] In this embodiment, based on real-time push events, the client connection status is maintained, and a client connection management, monitoring and recovery mechanism is implemented, including heartbeat detection, automatic reconnection and session recovery.

[0035] S600: Analyze and match the capability description of the service instance based on semantic understanding according to the client connection management information to obtain service instance information that meets the client functional requirements.

[0036] In this embodiment, the system adopts a service capability matching algorithm based on semantic understanding, supports fuzzy query and similarity matching, and the client only needs to describe the required function without precisely specifying the service name. The capability description of the service instance can then be analyzed and matched to obtain service instance information that meets the client's functional requirements.

[0037] Specifically, refer to Figure 2 , Figure 2This is the system architecture diagram of the MCP server registration center, which is built around service registration and discovery, health management and client interaction, and is divided into three main bodies: service consumers (clients), service registration centers, and service providers (servers): consumers obtain and update the service list from the registration center through "initial service discovery" and "SSE event subscription", and rely on "local service cache", "dynamic list update", "load balancer" and "failover logic" to achieve efficient calling and fault tolerance; the registration center manages the instance life cycle through the "service instance registry" and "health check manager", and provides registration query and event notification with the help of "RESTAPI interface" and "SSE push engine", and ensures security and accurate matching through "security authentication module" and "capability mapping engine"; providers maintain the active status of services through "automatic registration mechanism", "heartbeat sender" and "health check endpoint", and support service delivery with "capability declaration metadata", "service function implementation" and "graceful shutdown processing". The three parties collaborate through HTTP / HTTPS and SSE protocols to achieve dynamic service governance, real-time communication and high-availability calling.

[0038] In one embodiment, referring to Figure 3 In step S200, a health check is performed based on the service instance information to obtain the health status information of the service instance, which specifically includes the following steps: S210: Receive heartbeat requests sent periodically by service instances, and actively detect instances that fail to send heartbeats in a timely manner to obtain health detection data of the service instances.

[0039] In this embodiment, health check data includes four dimensions: heartbeat records, probe records, response indicators, and resource status. Heartbeat records include reception timestamps and sequence numbers, probe records include probe results and response times, response indicators include request success rates and average latency, and resource status includes CPU load and memory usage.

[0040] Specifically, a dual-channel detection system is constructed. The first channel is the heartbeat receiving service, which uses Redis as the heartbeat data cache and sets the expiration time of the heartbeat record to 15 seconds. The system writes the received heartbeat data into the heartbeat record table and uses the Bloom filter to quickly determine whether the service instance is alive. The second channel is the active detection service, which maintains the detection task priority queue. When it is found that the service instance has not sent a heartbeat for three consecutive times, the instance is added to the detection queue. Active detection uses the HTTP health check interface to record the detection results and response time. For example, when the sentiment analysis service instance does not send a heartbeat for more than 15 seconds, the system will actively initiate a health check request to verify the service status.

[0041] S220. Calculate the stability index of the service instance based on the health check data. The stability index is determined based on the health check success rate and the recent failure weight factor.

[0042] In this embodiment, the stability index is calculated using a percentage system and consists of a base score and a penalty factor. The base score is calculated based on the number of successful checks and ranges from 0 to 100. The penalty factor is calculated based on the time since the most recent failure and is divided into four time intervals: 0.8 within one hour, 0.5 within four hours, 0.2 within one day, and 0 for more than one day.

[0043] Specifically, this step implements a stability calculator. First, a test result storage table is established, and the time series database is used to record the data of the last 100 tests. The system counts the number of successful tests through a sliding window and calculates a basic score. At the same time, a failure record index table is maintained to record the specific time of the last failure. The stability index is calculated as: basic score × (1-penalty factor). For example, if a service instance succeeded 90 times out of the last 100 tests and the last failure occurred 2 hours ago, its stability index is 90 × (1-0.5) = 45 points.

[0044] S230. Dynamically adjust the health detection frequency of the service instance according to the stability index to obtain a health detection strategy for the service instance.

[0045] In this embodiment, the health check strategy includes four configuration items: check interval, timeout threshold, retry mechanism, and detection mode. The check interval defines the time difference between two checks, the timeout threshold specifies the maximum waiting time for a single check, the retry mechanism sets the retry rules after failure, and the detection mode selects heartbeat reception or active detection.

[0046] Specifically, this step establishes a policy adjuster and determines the detection parameters through a mapping table. The system presets four stability intervals: 0-25 minutes uses a 2-second detection interval, 26-50 minutes uses a 5-second interval, 51-75 minutes uses a 10-second interval, and 76-100 minutes uses a 20-second interval. At the same time, the system load table is maintained to record the current resource usage. When the system load is high, the global detection frequency is appropriately reduced. For example, when the stability index of a service instance is 45 points, the basic detection interval is 5 seconds, which is adjusted to 7.5 seconds under high system load conditions.

[0047] S240 : Based on the health detection data and the health detection strategy, the health status of the service instance is divided into multiple levels to obtain health status information of the service instance.

[0048] In this embodiment, the health status is divided into four levels: healthy (normal response, sufficient resources), sub-healthy (delayed response, tight resources), abnormal (unstable response), and offline (completely unavailable). Each status level has clear judgment criteria and transition rules.

[0049] Specifically, this step builds a status assessment engine and uses a rules engine to determine status. The system maintains a status determination rule table, which includes three dimensions: response time threshold, resource usage threshold, and failure rate threshold. A state transition matrix is ​​also established, specifying the transition conditions and cool-down periods between states. For example, if the response time of a service instance exceeds 500ms but does not reach 1000ms, it is determined to be in a sub-healthy state, and the performance optimization process is initiated.

[0050] In one embodiment, referring to Figure 4 In step S300, based on the health status information, the service instance status change is monitored and corresponding events are generated to obtain status change information, which specifically includes the following steps: S310: Monitor service instance status changes based on health status information.

[0051] Specifically, a state change listener is built to implement real-time monitoring. The system maintains a state change log table and uses a time-series database to store state change history. When a state change is detected, the system generates a state change event and writes the event to a message queue. To improve processing efficiency, a multi-level cache is used to store recent state data, and differences between the old and new states are detected through comparison. For example, in large-scale MCP service environments, event storms may occur, where a large number of events are generated in a short period of time in scenarios such as cluster rolling upgrades and network partition recovery.

[0052] Furthermore, differentiated monitoring strategies are adopted according to different health status levels. For service instances in a healthy state, low-frequency routine monitoring is adopted, focusing on the stability of core indicators; for instances in a sub-healthy state, the system increases the monitoring frequency, focusing on tracking the changing trends of specific indicators that lead to status degradation, and at the same time starts performance bottleneck analysis; for instances that enter an abnormal state, the system starts a full range of in-depth monitoring, including system log analysis, call chain tracking, and resource usage details, and maintains a short sampling interval; for instances in an offline state, in addition to maintaining basic availability detection, the system also monitors the status recovery of its dependent services. This differentiated monitoring mechanism based on health status level not only ensures the accuracy of monitoring, but also avoids excessive consumption of resources. Especially in a large-scale service environment, it can automatically adjust the allocation of monitoring resources for instances in each state to ensure efficient operation of the system.

[0053] S320: Accumulate multiple state change events of the same type and service within a preset time window into batch events.

[0054] Specifically, a sliding window algorithm is used to process the event stream. The system establishes an event buffer to temporarily store events received within 500 milliseconds. Events are categorized using a hash table, where the key is a combination of the service ID and the event type, and the value is a list of events. When the time window ends, the system traverses the hash table and merges similar events into batch events. For example, multiple INSTANCE_ADDED events are merged into a BATCH_INSTANCE_ADDED event, which contains information about all newly added instances.

[0055] S330: Aggregate multiple service instance state change events identified by the same physical location into a region-level event.

[0056] Specifically, service instances are grouped and aggregated based on their physical locations (data centers, availability zones, etc.). When multiple instances in the same region change their status simultaneously, a region-level aggregation event is generated.

[0057] S340: Identify the continuous state change events with time sequence association as service instance fluctuation events.

[0058] Specifically, we analyze the semantic patterns of event sequences to identify and merge event sequences with specific patterns. For example, we can identify the sequence of instances going offline and back online within a short period of time as service instance fluctuation events, thus reducing unnecessary state switch notifications.

[0059] S350: Merge batch events, regional level events, and service instance fluctuation events to obtain compressed state change information.

[0060] Specifically, this step builds an event consolidation processor that manages different types of aggregated events through a priority queue. The system maintains an event priority table and determines the order of processing based on the scope and urgency of the event. When receiving batch events, regional events, and fluctuating events, the system consolidates them according to predefined rules, ensuring information integrity while maximizing compression.

[0061] In one embodiment, referring to Figure 5 In step S400, based on the status change information, a server-sent event technology is used to establish a persistent connection with the client and filter events to obtain real-time push events related to the client's subscription service. Specifically, the steps include: S410: Associate a version vector with each service instance state, where the version vector includes a count of modifications made by each node to the corresponding instance state.

[0062] Specifically, a version manager is built, using distributed key-value storage to maintain version information. The system establishes a version vector table, using a multidimensional array structure to store modification counts for each node. When a node modifies the state of a service instance, it first obtains the current version vector, increments the counter at the corresponding position, and updates the timestamp and update type. For example, when node A marks a service instance as unavailable, the count of node A in its version vector is incremented by one, recording the update time and state change type.

[0063] S420: Determine the causal relationship of the state change events by comparing version vectors, and identify state conflicts caused by concurrent events.

[0064] In this embodiment, version vector comparisons are performed using matrix operations. The system maintains a causal relationship graph, recording the dependencies between events. When a new state change event is received, its version vector is compared with the existing version, and the causal order is determined based on the magnitude of the counters. If the version vectors do not overlap, the event is marked as concurrent. For example, if two nodes simultaneously modify the configuration information of a service instance, the system will detect this as a concurrent update through version vector comparison, requiring conflict resolution.

[0065] S430. Apply predefined resolution rules to the state conflicts. The resolution rules include: giving priority to the unavailable state when there is a state availability conflict, using field-level merging when there is a metadata change conflict, and giving priority to the configuration with a higher version number when there is a configuration conflict.

[0066] S440: Push real-time events to clients subscribed to the corresponding service based on the resolved status change information.

[0067] In this embodiment, real-time events are pushed to clients subscribed to the corresponding service based on the resolved state change information, ensuring that the client can ultimately obtain a consistent MCP service view even in a complex network environment, while avoiding the performance bottleneck caused by the traditional locking mechanism.

[0068] In one embodiment, referring to Figure 6 In step S500, based on the real-time push event, the client connection status is maintained and automatic reconnection and session recovery are achieved to obtain client connection management information, which specifically includes the following steps: S510: Record the running status of the current session, where the running status includes the conversation context, model parameters, and intermediate calculation results.

[0069] S520: Detect service instance availability information in the real-time push event, and trigger automatic reconnection when the service instance is unavailable; S530: Select an available instance with the same capabilities from the service registry to reconnect, and migrate the running state to the new instance; S540: Cache client requests during session migration, and process cached requests in a time sequence after migration is completed to ensure service continuity.

[0070] In one embodiment, referring to Figure 7 In step S600, based on the client connection management information, the capability description of the service instance is analyzed and matched based on semantic understanding to obtain service instance information that meets the client functional requirements. Specifically, the steps include: S610: Receive a functional requirement description of the client according to the client connection management information, and convert the functional requirement description into a standardized capability matching condition based on semantic understanding.

[0071] In this embodiment, when the client is started for the first time, it obtains the complete list of registered services and instance information through HTTP request, establishes a local cache, stores service instance information, and keeps the cache updated in real time by subscribing to events.

[0072] S620: Retrieve a service instance with matching capabilities from the service registry according to the capability matching condition.

[0073] In this embodiment, when an MCP service needs to be called, the client can directly specify the service name and select a healthy instance from the local cache; provide a functional description, and the capability matching engine will select the most suitable service instance; or specify specific filtering conditions (such as version, region, etc.) to filter out instances that meet the conditions.

[0074] S630: Verify the interface compatibility between the service instance and the client request, and filter out available candidate service instances.

[0075] In this embodiment, the client obtains the network address and interface information of the selected instance, establishes a connection, and initiates a call. If the call fails, the client automatically performs a failover, selects another healthy instance and tries again, and notifies the registry of the possible instance failure.

[0076] S640: Monitor capability change events of candidate service instances, dynamically update matching results, and obtain service instance information that meets the client's functional requirements.

[0077] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean 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.

[0078] On the second aspect, the present application provides an event-driven artificial intelligence context protocol service registration and discovery device. The event-driven artificial intelligence context protocol service registration and discovery device of the present application is described below in combination with the above-mentioned event-driven artificial intelligence context protocol service registration and discovery method.

[0079] Reference Figure 8 , an event-driven artificial intelligence context protocol service registration and discovery device, the device comprising: The service registration module is used to receive registration requests for service instances, build an artificial intelligence context protocol service registry, and obtain service instance information; The health detection module is used to perform health detection based on the service instance information and obtain the health status information of the service instance; The event monitoring module is used to monitor service instance status changes and generate corresponding events based on health status information to obtain status change information; The event push module is used to establish a persistent connection with the client based on status change information using server-sent event technology and perform event filtering to obtain real-time push events related to the client's subscription service; The connection management module is used to maintain the client connection status and implement automatic reconnection and session recovery based on real-time push events, and obtain client connection management information; The capability matching module is used to analyze and match the capability description of the service instance based on the client connection management information and semantic understanding, and obtain the service instance information that meets the client's functional requirements.

[0080] In one embodiment, the present application provides an electronic device, which may be a server, and its internal structure diagram may be as follows: Figure 9 As shown. The electronic device includes a processor, a memory and a network interface connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the electronic device is used to store data. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements an event-driven artificial intelligence context protocol service registration and discovery method.

[0081] Those skilled in the art will understand that Figure 9The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0082] In one embodiment, an electronic device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.

[0083] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The above-described computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the above-described method embodiments. Any reference to memory, storage, database, or other media used in the embodiments provided herein may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0084] The above are all preferred embodiments of the present application, and are not intended to limit the scope of protection of the present application. Therefore, any equivalent changes made based on the structure, shape, and principle of the present application should be included in the scope of protection of the present application.

Claims

1. An event-driven artificial intelligence context protocol service registration and discovery method, characterized in that: The steps include: Receive the registration request of the service instance, build the artificial intelligence context protocol service registry, and obtain the service instance information; Perform health checks based on the service instance information to obtain health status information of the service instance; Based on the health status information, monitor the service instance status changes and generate corresponding events to obtain status change information; Based on the status change information, a server-sent event technology is used to establish a persistent connection with the client and perform event filtering to obtain real-time push events related to the client's subscription service; Maintaining the client connection status and implementing automatic reconnection and session recovery based on the real-time push event, and obtaining client connection management information; According to the client connection management information, the capability description of the service instance is analyzed and matched based on semantic understanding to obtain service instance information that meets the client functional requirements.

2. The event-driven artificial intelligence context protocol service registration and discovery method according to claim 1, characterized in that: Based on the health status information, monitor the service instance status changes and generate corresponding events to obtain status change information, specifically including the following steps: Monitoring service instance status changes based on the health status information; Accumulate multiple state change events of the same type and service within a preset time window into batch events; Aggregate multiple service instance state change events identified by the same physical location into region-level events; Identify continuous state change events with temporal correlation as service instance fluctuation events; The batch events, region-level events, and service instance fluctuation events are merged to obtain compressed state change information.

3. The event-driven artificial intelligence context protocol service registration and discovery method according to claim 1, characterized in that: Performing a health check based on the service instance information to obtain the health status information of the service instance specifically includes the following steps: Receive heartbeat requests sent periodically by service instances, and actively detect instances that fail to send heartbeats in a timely manner to obtain health detection data of service instances; Calculating a stability index of the service instance based on the health check data, where the stability index is determined based on a health check success rate and a recent failure weight factor; Dynamically adjust the health check frequency of the service instance according to the stability index to obtain a health check strategy for the service instance; Based on the health detection data and the health detection strategy, the health status of the service instance is divided into multiple levels to obtain the health status information of the service instance.

4. The event-driven artificial intelligence context protocol service registration and discovery method according to claim 1, characterized in that: Based on the status change information, a server-sent event technology is used to establish a persistent connection with the client and filter events to obtain real-time push events related to the client's subscription service. Specifically, the following steps are included: Associating a version vector with each service instance state, the version vector contains the modification count of each node to the corresponding instance state; Determine the causal relationship of state change events by comparing version vectors, and identify state conflicts caused by concurrent events; Applying predefined resolution rules to the state conflicts, the resolution rules including: prioritizing the unavailable state when there is a state availability conflict, prioritizing field-level merging when there is a metadata change conflict, and prioritizing the configuration with a higher version number when there is a configuration conflict; Based on the resolved status change information, real-time events are pushed to clients subscribed to the corresponding service.

5. The event-driven artificial intelligence context protocol service registration and discovery method according to claim 1, characterized in that: According to the client connection management information, the capability description of the service instance is analyzed and matched based on semantic understanding to obtain service instance information that meets the client functional requirements, specifically including the following steps: receiving a functional requirement description of the client according to the client connection management information, and converting the functional requirement description into a standardized capability matching condition based on semantic understanding; Retrieving a service instance with matching capabilities from a service registry according to the capability matching condition; Verify the compatibility of the service instance with the interface requested by the client, and filter out available candidate service instances; Monitor the capability change events of the candidate service instances, dynamically update the matching results, and obtain service instance information that meets the client's functional requirements.

6. The event-driven artificial intelligence context protocol service registration and discovery method according to claim 1, characterized in that: Maintaining the client connection status and implementing automatic reconnection and session recovery based on the real-time push event to obtain client connection management information specifically includes the following steps: Record the running status of the current session, including the conversation context, model parameters, and intermediate calculation results; Detecting service instance availability information in the real-time push event, and triggering automatic reconnection when the service instance is unavailable; Select an available instance with the same capabilities from the service registry for reconnection, and migrate the running state to the new instance; Client requests are cached during session migration, and the cached requests are processed in a time sequence after migration is completed to ensure service continuity.

7. An event-driven artificial intelligence context protocol service registration and discovery device, characterized in that: The device comprises: The service registration module is used to receive registration requests for service instances, build an artificial intelligence context protocol service registry, and obtain service instance information; A health detection module is used to perform health detection based on the service instance information to obtain health status information of the service instance; An event monitoring module is used to monitor service instance status changes and generate corresponding events based on the health status information to obtain status change information; An event push module is used to establish a persistent connection with the client and perform event filtering based on the state change information using server-sent event technology to obtain real-time push events related to the client's subscription service; A connection management module is used to maintain the client connection status and realize automatic reconnection and session recovery according to the real-time push event, and obtain client connection management information; The capability matching module is used to analyze and match the capability description of the service instance based on the client connection management information and semantic understanding, so as to obtain service instance information that meets the client functional requirements.

8. An electronic device, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the event-driven artificial intelligence context protocol service registration and discovery method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the event-driven artificial intelligence context protocol service registration and discovery method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Optimized registration method and system based on micro-service architecture

    CN120499260A

  • Automatic guarantee method and device for high-guarantee link, electronic equipment and storage medium

    CN120512354A

  • Data processing method and device based on context protocol, equipment and medium

    CN120542540A

  • System for Electronically Administering Health Services

    US20160224752A1

Cited By

  • Communication system, communication method, routing device, electronic equipment and storage medium

    CN121334225A

  • Three-party routing system and method for warehousing business

    CN121441823A

  • A three-party routing system and method for warehousing business

    CN121441823B

  • Asynchronous task message passing method and device based on MCP protocol, equipment and storage medium

    CN121530945A

  • Service discovery method, service system and storage medium

    CN121585723A