A2A Java Bridge for MCP Server Integration
Expose annotated Java methods as MCP server, A2A-discoverable actions with A2AJava—no boilerplate or service registration required.
Overview
A2A Java Bridge (A2AJava) turns annotated Java methods into a running Model Context Protocol (MCP) server and registers them as A2A-discoverable actions. Instead of writing server boilerplate or manual service registration, you annotate methods, start the bridge, and the library automatically exposes those methods over MCP so agents and other MCP-capable clients can discover and invoke them.
This pattern is useful when you already have business logic implemented as plain Java methods and want to make those methods available to AI agents or other automated “app-to-app” workflows. The bridge handles scanning, wiring, and lightweight HTTP/JSON transport so you can focus on implementing action logic rather than integration plumbing.
Features
- Automatic scanning of annotated Java methods and classes
- Exposes methods as MCP server actions without manual registration
- Simple annotation-driven API to describe action name, inputs, and outputs
- Lightweight runtime with minimal dependencies—works in existing JVM apps
- Discoverable actions for A2A/MCP-capable clients and agents
- Example project and quick-start usage for local development
Installation / Configuration
There are two common ways to get the bridge into your project: use the published JAR (if available) or build from source. Replace group/artifact coordinates with the actual coordinates from the repo if a published package exists.
Add a dependency with Maven (example placeholder coordinates):
com.vishalmysore
a2ajava
0.1.0
Or with Gradle:
implementation 'com.vishalmysore:a2ajava:0.1.0'
Build from source:
# use the produced jar from target/ to include in your app
Basic configuration when starting the bridge typically includes which package(s) to scan and the port to listen on. Example programmatically starting a server:
;
Check the repository README or javadoc for the exact builder/constructor API names.
Quick Annotated Example
Annotate a method to expose it as an action:
;
When the bridge scans the package containing MathActions, the “add” action will be discoverable over MCP.
Available Resources
- GitHub repository (source, examples, issues): https://github.com/vishalmysore/a2ajava
- Example projects and sample actions inside the repo to reference runtime patterns
- Issues and pull requests on GitHub for community support and bug reports
- Inline Javadoc or generated docs (check the repo for /docs or javadoc artifacts)
Use Cases
- AI agent integrations: Expose application-level utilities (data lookups, business operations) as discoverable actions the agent can call during reasoning or planning.
- Rapid prototyping: Turn existing Java utilities into network-accessible actions without creating REST controllers or additional services.
- Internal automation: Allow orchestration systems or chatops bots to invoke tasks (e.g., deploy, build, query) implemented as plain Java methods.
- Testing and simulation: Mock MCP endpoints by exposing simple annotated methods locally for integration tests.
- Microservices bootstrap: Provide a low-friction way to expose functionality before committing to a full HTTP API or RPC contract.
Notes and Best Practices
- Keep annotated methods focused and idempotent when possible; consider input/output JSON structure consistency.
- Validate incoming payloads inside your annotated method to avoid runtime errors.
- Use a dedicated package (for example com.myapp.actions) so the bridge can efficiently scan only relevant classes.
- Remember to secure the MCP endpoint in production (authentication, network controls) if the bridge runs in an exposed environment.
For detailed API usage, configuration options, and operational tips, consult the repository README and example code bundled with the project.