- Explore MCP Servers
- mcp-agent-example
Mcp Agent Example
What is Mcp Agent Example
mcp-agent-example is a Java-based project that serves as a sample implementation of an AI agent interacting with MCP tools. It can perform tasks such as querying weather information, calculations, and reasoning.
Use cases
Use cases include querying real-time weather data, performing mathematical calculations, and providing reasoning capabilities in AI-driven applications.
How to use
To use mcp-agent-example, clone the repository, navigate to the project directory, build the project using Maven, configure the application.yml file, and start the application using the command ‘mvn spring-boot:run’. Access the server at http://localhost:5678.
Key features
Key features include integration with MCP tools for weather information and calculations, AI bridge support for reasoning and natural language processing, configurable settings via application.yml, and graceful resource management.
Where to use
mcp-agent-example can be used in various fields such as weather forecasting applications, educational tools for teaching AI concepts, and any application requiring interaction with MCP tools for data retrieval and processing.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Agent Example
mcp-agent-example is a Java-based project that serves as a sample implementation of an AI agent interacting with MCP tools. It can perform tasks such as querying weather information, calculations, and reasoning.
Use cases
Use cases include querying real-time weather data, performing mathematical calculations, and providing reasoning capabilities in AI-driven applications.
How to use
To use mcp-agent-example, clone the repository, navigate to the project directory, build the project using Maven, configure the application.yml file, and start the application using the command ‘mvn spring-boot:run’. Access the server at http://localhost:5678.
Key features
Key features include integration with MCP tools for weather information and calculations, AI bridge support for reasoning and natural language processing, configurable settings via application.yml, and graceful resource management.
Where to use
mcp-agent-example can be used in various fields such as weather forecasting applications, educational tools for teaching AI concepts, and any application requiring interaction with MCP tools for data retrieval and processing.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Here is a basic README.md
for the mcp-agent-example
project:
MCP Agent Example
Overview
mcp-agent-example
is a Java-based project built with Maven and Spring Boot. It serves as an example implementation of an agent that interacts with MCP (Multi-Client Platform) tools and AI bridges to perform various tasks such as querying weather information, performing calculations, and handling reasoning steps.
Features
- Integration with MCP tools for weather information and calculations.
- AI bridge support for reasoning and natural language processing.
- Configurable via
application.yml
. - Graceful resource management with
closeGracefully()
.
Requirements
- Java: JDK 11 or higher
- Maven: 3.6 or higher
- Spring Boot: 2.x or higher
Installation
-
Clone the repository:
git clone https://github.com/your-repo/mcp-agent-example.git
-
Navigate to the project directory:
cd mcp-agent-example
-
Build the project:
mvn clean install
Configuration
Edit the application.yml
file located in src/main/resources
to configure the server and tools:
server:
port: 5678
address: 0.0.0.0
spring:
application:
name: agent-sample-with-mcp
ai:
bridge:
zhipu:
api_key: your_key
mcp:
getRealWeatherInfo:
tool-name: getRealWeatherInfo
base-url: http://localhost:8080
api-key: your_key
calculate:
tool-name: calculate
base-url: http://localhost:8080
api-key: your_key
queryAllValidWeatherLocation:
tool-name: queryAllValidWeatherLocation
base-url: http://localhost:8080
api-key: your_key
Replace your_key
and http://localhost:8080
with your actual API keys and MCP server URL.
Usage
-
Start the application:
mvn spring-boot:run
-
Access the server at:
http://localhost:5678
-
Example HTTP request:
GET http://localhost:5678/server?从杭州到广州怎么样
Project Structure
src/main/java
: Contains the Java source code.common
: Includes core classes likeReasoningStep
.llm
: Handles AI bridge interactions.mcp
: Manages MCP tool selection and execution.
src/main/resources
: Contains configuration files likeapplication.yml
.
Key Classes
ReasoningStep
Handles reasoning logic, including appending prompts, interacting with tools, and managing context.
Tool
Represents an MCP tool with caching capabilities.
Contributing
Contributions are welcome! Please submit a pull request or open an issue for any improvements or bug fixes.
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.