auto -client
基于Spring AI 封装了 mcp-client 服务,目的使web网页智能体也能通过 stdio 和 HTTP SSE(Server-Sent Events) 与 MCP Server 进行交互。项目实现了自动化的连接管理机制,包括自动初始化连接、健康检查、超时关闭以及链接复用等功能
claude mcp add --transport stdio down-to-earth1994-auto-mcp-client java -jar auto-mcp-client.jar \ --env JAVA_OPTS="Default JVM options if needed" \ --env NACOS_NAMESPACE="your-namespace-id" \ --env NACOS_CONFIG_CENTER="nacos-config-center-url" \ --env OPENAI_API_KEY_PLACEHOLDER="your-openai-api-key" \ --env OPENAI_BASE_URL_PLACEHOLDER="https://your-openai-base-url"
How to use
This MCP server is a Java-based client wrapper that connects to an MCP Server using both stdio and HTTP Server-Sent Events (SSE). It wraps the mcp-client service and provides automated connection management, including automatic initialization at startup, periodic health checks, timeouts for idle connections, and connection reuse within a configured window. Once running, you can interact with the MCP Server either through standard input/output streams or via HTTP SSE endpoints exposed by the client, enabling real-time bidirectional communication with the server for prompts, responses, and streaming data. The included configuration supports isolation for multiple agents connected to the same MCP Server, ensuring that concurrent sessions do not interfere with each other while sharing underlying resources where appropriate.
How to install
Prerequisites:
- Java 17 or newer installed
- Maven or Gradle for building the project
- Access to the MCP Server and any required private model keys or endpoints
Installation steps:
-
Clone the repository: git clone <repository-url> cd <repository-directory>
-
Build the project (example with Maven): mvn -DskipTests package
This will produce auto-mcp-client.jar in the target directory (path may vary depending on project setup)
-
Prepare configuration:
- Ensure bootstrap.yml is configured with the correct NACOS config center and namespace
- Import mcp-client-dev.yml into NACOS as described in the project docs
- Update default-mcp-registry.json with your own API keys or MCP server entries
- Ensure the node service path (if applicable) is configured so the stdio protocol can detect the node service availability
-
Run the server: java -jar target/auto-mcp-client.jar
-
Verify startup logs for successful MCP Server initialization and readiness for stdio or SSE interaction
Additional notes
Tips and common issues:
- Ensure JDK 17+ is used; some features rely on newer language/runtime features.
- If using NACOS for configuration, make sure the bootstrap.yml points to the correct config center and namespace, and that mcp-client-dev.yml is present and valid in NACOS.
- When using private OpenAI-compatible models, update the ai.openai configuration in your secret/config files with your API key and base URL as shown in the private model example.
- The system supports multiple agents connected to the same MCP Server with isolation between them. If you experience connection timeouts, consider adjusting idle timeout and health-check intervals in your configuration.
- For stdio interactions, ensure the process feeding stdin/stdout is properly synchronized with the MCP Server's messaging protocol to avoid deadlocks.
- Environment variables like OPENAI_API_KEY and OPENAI_BASE_URL should be kept confidential and injected securely in production.
Related MCP Servers
mcp-for-beginners
This open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
xiaozhi-esp32 -java
小智ESP32的Java企业级管理平台,提供设备监控、音色定制、角色切换和对话记录管理的前后端及服务端一体化解决方案
api2mcp4j
This is a revolutionary AI MCP plugin with excellent pluggable and encapsulated features. With just a few lines of configuration, it can easily integrate into your Spring boot web program and give it MCP capabilities,inheriting the powerful engineering capabilities of the Spring series framework
ncp
Natural Context Provider (NCP). Your MCPs, supercharged. Find any tool instantly, load on demand, run on schedule, ready for any client. Smart loading saves tokens and energy.
springboot-ai -example
Example Spring AI Model Context Protocol (MCP)
AIFoundry Connector-FabricGraphQL
MCP Client and Server apps to demo integration of Azure OpenAI-based AI agent with a Data Warehouse, exposed through GraphQL in Microsoft Fabric.