The invention discloses a method and
system for dynamically calling a
Java statistical analysis interface based on LLM and MCP protocols, belongs to the technical field of
data processing and analysis technology,
artificial intelligence technology and application program interface (API) integration, and aims to solve the technical problem of how to improve the response speed and flexibility of
statistical analysis requirements. In order to reduce the development and maintenance cost of a
statistical analysis function, the adopted technical scheme is as follows: a
Java annotation mechanism is utilized to mark and describe an existing
Java statistical analysis
system, a Java method of which the
annotation is defined is obtained, and the Java method of which the
annotation is defined can be automatically identified by an MCP
server and registered as an MCP tool; the MCP
server follows an MCP protocol and communicates with the LLM serving as an MCP
client, and the LLM dynamically discovers available MCP tools through the MCP protocol; after
natural language query of a user is understood through LLM, one or more appropriate MCP tools are intelligently selected, calling parameters are generated, and an MCP
server is requested to execute through an MCP protocol.