Learn how to set up and use ModelContextProtocolClient with WebFlux SSE, Stdio, and BraveSearch transports
ModelContextProtocolServer (MCP Server) is a versatile and standards-based infrastructure designed to facilitate seamless integration of diverse AI applications with specific data sources and tools. It adheres to the Model Context Protocol (MCP), which acts as a universal adapter, ensuring that various AI applications can connect effortlessly to their required resources through standardized endpoints and transport mechanisms.
The core capabilities of MCP Server are centered around its ability to support multiple transport protocols for communication with clients. These protocols include:
Each transport method is designed to cater to different scenarios, ensuring flexibility in deployment and usage based on the requirements of various AI applications.
The architecture of MCP Server is modular, allowing for easy integration of new tools and data sources. It consists of several key components:
The protocol implementation details are crucial for understanding how data flows between client and server. This is depicted in the following diagram:
graph TB
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
This diagram illustrates the flow of data from an AI application, through MCP Client and Protocol to the MCP Server, ultimately reaching external data sources or tools.
To set up and run ModelContextProtocolServer, follow these steps:
Environment Preparation: Create a .env
file in the root directory to store API keys.
BRAVE_SEARCH_API_KEY=your_brave_search_api_key_here
WEATHER_API_KEY=your_weather_api_key_here
Docker Setup:
https://github.com/InnoBridge/ModelContextProtocolServer
docker-compose.yml
to include references to the MCP Client project. modelcontextprotocolclient_application
...
volumes:
- .:/app
- /var/run/docker.sock:/var/run/docker.sock
- ./local/root:/root
- ../{path to ModelContextProtocolServer repo}:/ModelContextProtocolServer
sudo docker compose up
# Run server
sudo docker exec -it modelcontextprotocolserver-application sh
cd /app
./mvnw clean install
./mvnw spring-boot:run
docker exec -it modelcontextprotocolclient-application sh
./mvnw spring-boot:run
ModelContextProtocolServer is particularly valuable for integrating AI applications with various data sources and tools. Here are two realistic use cases:
Weather Data Integration: An AI application can request weather information by sending a POST request to the weather
endpoint of MCP Client, which will forward this request through MCP Server to an external weather API.
curl -X POST "http://localhost:8080/stdio/weather?location=San%20Francisco&format=celsius"
Tool-Based Calculations: A complex financial application can perform calculations by using the calculate
endpoint of MCP Client via MCP Server to a dedicated calculation tool.
curl -X POST "http://localhost:8080/webflux/calculate?operation=add&a=5&b=3"
MCP Server supports integration with multiple AI applications and tools, ensuring broad compatibility and flexibility. The following table demonstrates the current MCP Client compatibility:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
MCP Server is designed to operate seamlessly across various environments, ensuring robust performance and compatibility with different configurations. The server supports a wide range of data sources and tools through its flexible architecture.
The following diagram provides a high-level overview of the implementation details:
graph TD
A[AI Application] --> B[MCP Client] --> C[MCP Protocol] --> D[MCP Server]
E[Data Source/Tool] <|-- C[MCP Server] --> D[MCP Server] --> E[Data Source/Tool]
style A fill:#e1f5fe
style B fill:#fbceec
style C fill:#f4ecd6
style D fill:#d7eff2
style E fill:#b3f0ff
This diagram illustrates the bidirectional flow of data from AI Application to Data Source/Tool through MCP Client and Server, ensuring seamless integration.
To configure MCP Client for different endpoints or protocols, ensure that relevant environment variables are set in your .env
file. Here’s a sample configuration snippet:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Q: Can MCP Server handle multiple transport protocols simultaneously?
Q: How do I test the connection between MCP Client and Server?
curl -X POST "http://localhost:8080/webflux/calculate?operation=add&a=5&b=3"
.Q: Is there a limit to the number of MCP Clients that can connect simultaneously?
Q: Can I integrate my custom data source with MCP Server?
docker-compose.yml
file and setting up appropriate handlers within the server code.Q: What is the difference between WebFlux and Stdio transports in terms of performance?
Contributions to MCP Server are welcome and can significantly enhance its capabilities and usability. The following guidelines should be followed:
https://github.com/InnoBridge/ModelContextProtocolServer
git checkout -b my-feature-branch
.MCP Server is part of a larger ecosystem that includes tools, libraries, and documentation designed to support developers building AI applications. Key resources include:
By leveraging ModelContextProtocolServer, developers can significantly streamline the process of integrating various AI applications with external resources, enhancing functionality and efficiency in a wide range of domains.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration