Content
# MCP and A2A Client Demo in Kotlin
This project demonstrates the implementation of a Kotlin client that supports both Model Context Protocol (MCP) and A2A (Agent-to-Agent) protocols. It serves as a reference implementation for developers looking to integrate these protocols into their Kotlin applications.
[A2AJava](https://github.com/vishalmysore/a2ajava) is a pure Java implementation designed to support both the Google A2A (Agent-to-Agent) protocol and the MCP (Model Context Protocol), making it a versatile framework for building agentic applications. The A2A protocol standardizes how AI agents communicate and collaborate across different systems, while the MCP protocol focuses on enabling agents to access and trigger a wide range of tools and resources.
Key Features and Benefits of A2AJava (A2A & MCP Support):
Cross-Protocol Support: A2AJava natively supports both A2A and MCP in the same codebase, allowing developers to build applications where agents can communicate with each other (A2A) and also access external tools or services (MCP).
Cross-Platform and Cross-Language: Runs on any operating system with JVM support and is compatible with clients built in JavaScript, Python, and other languages, as well as LLM agents like Claude and Google A2A clients.
Flexible Integration: Can be used with Spring Boot, Quarkus, or pure Java/Kotlin, making it easy to integrate into a variety of enterprise and AI applications.
Automatic Tool and Resource Registration: Uses Java annotations (such as @Agent and @Action) to automatically expose methods as A2A tasks or MCP tools, simplifying agent and tool development.
Lightweight and Extensible: Designed for minimal overhead and maximum flexibility, supporting both local and remote tool execution, JSON-RPC, schema validation, and callback mapping
## Overview
This client implementation showcases how to:
- Connect to MCP servers and interact with their exposed capabilities
- Handle A2A protocol communication between different agents
- Manage protocol-specific message formats and responses
- Implement proper error handling and connection management
## Features
- **MCP Protocol Support**
- Connection handling with MCP servers
- Dynamic capability discovery
- Request/response message handling
- Resource reference support
- Progress updates handling
- **A2A Protocol Support**
- Agent discovery and communication
- Message routing
- State management
- Secure communication channels
## Getting Started
### Prerequisites
- JDK 11 or higher
- Maven for dependency management
- Kotlin 1.5+
### Building the Project
```bash
mvn clean install
```
### Running the Client
```bash
mvn exec:java -Dexec.mainClass="org.example.MainKt"
```
## Configuration
The client can be configured through the `tools4ai.properties` file located in the `src/main/resources` directory. This file contains settings for:
- Server endpoints
- Connection parameters
- Protocol-specific configurations
## Project Structure
```
src/
├── main/
│ ├── kotlin/
│ │ └── Main.kt # Entry point and main client logic
│ └── resources/
│ └── tools4ai.properties # Configuration file
└── test/
└── kotlin/ # Test implementations
```
## Contributing
Feel free to contribute to this project by:
1. Forking the repository
2. Creating your feature branch
3. Committing your changes
4. Creating a pull request
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Related Documentation
- [MCP Protocol Specification](https://github.com/microsoft/model-context-protocol)
- [A2A Protocol Documentation](https://example.com/a2a-protocol)