MCP Directory
ServersClientsBlog

xASO - App Store Optimization

AI-powered App Store Optimization platform for mobile apps

Go to xASO
MCP Directory

Model Context Protocol Directory

MKSF LTD
Suite 8805 5 Brayford Square
London, E1 0SG

MCP Directory

  • About
  • Blog
  • Documentation
  • Contact

Menu

  • Servers
  • Clients

© 2025 model-context-protocol.com

The Model Context Protocol (MCP) is an open standard for AI model communication.
Powered by Mert KoseogluSoftware Forge
  1. Home
  2. Clients
  3. mcpx4j

mcpx4j

GitHub
Website

MCPX4J is a Java client library for MCP.RUN, enabling developers to easily integrate and invoke installed tools using a simple API with features like installation caching and customizable JSON decoding.

25
1

MCPX4J

The MCP.RUN client library for Java!

Installation

To use MCPX4J, add the following dependency to your project's pom.xml:

<dependencies>
    <dependency>
       <groupId>com.dylibso.mcpx4j</groupId>
        <artifactId>mcpx4j</artifactId>
        <version>${mcpx4j.version}</version>
    </dependency>
</dependencies>

Quick Start

Create a Mcpx instance using your API key to interact with your installed tools. Refresh installations with refreshInstallations(). Retrieve a servlet and tool by their IDs, then call the tool with a JSON payload.

import com.github.dylibso.mcpx4j.Mcpx;

Mcpx mcpx = Mcpx.forApiKey(apiKey).build();
mcpx.refreshInstallations();
var servlet = mcpx.get("my-servlet-id");
var tool = servlet.get("my-tool-id");
var bytes = servlet.call("""
{
    "method": "tools/call",
    "params": {
        "name": "my-tool-id",
        "arguments": {
            ...
        }  
    }
}
""");

Plugin Updates

Mcpx caches installations, refresh it using refreshInstallations(). Schedule refreshes in a separate thread.

var scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(mcpx::refreshInstallations, 0, 5, TimeUnit.MINUTES);

Configuration

Customize the Mcpx instance with an alternative base URL, JSON decoder, and HTTP client.

var mcpx = Mcpx.forApiKey(apiKey)
    .withBaseUrl(jsonDecoder)
    ...
    .build();

JSON Decoder

Use the default JacksonDecoder or the Jakarta JSON-P implementation. Include the corresponding dependencies.

HTTP Client

Use the default JdkHttpClientAdapter or the lighter HttpUrlConnectionClientAdapter.

Servlet Options

Configure servlet options, such as ChicoryHttpConfig, ChicoryLogger, and AoT (Ahead-of-Time compilation), propagated to the Chicory Extism SDK.

Repository

DY
dylibso

dylibso/mcpx4j

Created

January 7, 2025

Updated

March 27, 2025

Language

Java

Category

Developer Tools