Logo di MCP Mediator

MCP Mediator

Community
makbn

Automatically generate an MCP Server from existing source code, service classes, helper methods, and external MCP tools. The MCP Mediator aggregates various sources and tools into a unified system, enabling seamless automatic generation of a complete MCP Server.

Autoremakbn
Repositorymcp_mediator
LinguaJava
Fork
3
Stelle
12
Strumenti disponibili
0
Tipo di trasportostdio
Categorie
LicenzaGPL-3.0
Link
  • Collega gli strumenti ai flussi di lavoro IA

    MCP Mediator mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    12 stelle e 3 fork nel repository collegato.

MCP Mediator – Automatic MCP Server Generation

A Java-based implementation of a Model Context Protocol (MCP) mediator that automatically generates an MCP Server from existing source code, service classes, helper methods, and external MCP tools. The MCP Mediator aggregates these diverse components into a unified MCP Server, streamlining communication between MCP clients and servers through a single point.

By eliminating the need to manually maintain multiple MCP Servers, this tool simplifies integration and execution within the MCP ecosystem and make it possible to generate MCP Servers without altering the existing code bases and tools that are planned to be MCP compatible.

MCP Mediator High Level Diagram MCP Mediator High Level Diagram

Overview

The MCP Mediator implements the Model Context Protocol specification, providing a robust framework for:

  • Handling MCP requests and responses
  • Managing tool execution
  • Supporting various transport mechanisms
  • Integrating with Spring Framework and Spring Boot

For more information, visit the project's wiki: MCP Mediator Wiki. Wiki page is organized as follows:

Features

:white_check_mark: Ready:

  • Support for stdio/sse transport
  • Extensible request handling system
  • Configurable server capabilities
  • Support for multiple tool implementations
  • Support for proxying multiple MCP servers
  • Automatically generating MCP Server Tools for the existing methods and services

:hourglass_flowing_sand: Work In Progress:

  • Spring Framework and Spring Boot integration (Done)
  • Comprehensive error handling (Done)
  • Docker Implementation (Done)
  • Dropbox Implementation (Done)

:baby_bottle: Planned:

  • Generate MCP Server for existing Spring Controllers and mediate request between MCP client and controllers (Done)
  • Generate MCP Server for existing OpenAPI specification and generate MCP Tool for the APIs and delegate the requests (Done)

Modules

  • mcp-mediator-api: Core API interfaces and contracts
  • mcp-mediator-core: Core implementation and common functionality
  • mcp-mediator-commons: Reusable components to make implementation easier
  • mcp-mediator-example: Example shows how to use and extend the mediator framework
  • mcp-mediator-spring: Spring Framework and Spring AI integration
  • mcp-mediator-spring-boot-starter: Spring Boot autoconfiguration to generate MCP server automatically for the available endpoints
  • Implementation modules for various services:
    • mcp-mediator-implementation-docker: Docker service integration Read More
    • mcp-mediator-implementation-dropbox: Dropbox service integration (WIP)
    • mcp-mediator-implementation-query: Query services with public APIs: List of all Query MCP Servers

Getting Started

Prerequisites

  • Java 17 or later
  • Maven 3.6 or later
  • Spring Boot 3.2.2 or later (for Spring Boot integration)

All the examples are available under mcp-mediator-exmple module. It's still a work in progress and the examples will be added.

Default MCP Mediator

To create a MCP Mediator with STDIO transport:

java
DefaultMcpMediator mediator = new DefaultMcpMediator(McpMediatorConfigurationBuilder.builder()
          .createDefault()
          .serverName(MY_EXAMPLE_MCP_SERVER_STDIO)
          .build());
mediator.registerHandler(new WikipediaQueryRequestHandler());
mediator.initialize();

To run the examples as Claude Desktop MCP Server:

yaml
{
  "mcpServers": {
    "my_java_mcp_server": {
      "command": "[path to]/run.sh",
      "args": [
        "DefaultMcpMediatorStdioExample"
      ]
    }
  }
}

This config runs DefaultMcpMediatorStdioExample sa STDIO MCP server. Make sure to make run.sh executable and add mvn command to your path.

bash
 ./run.sh ClassName [arg1 arg2 ...]

This mediator runs a STDIO MCP server with handlers and delegates requests from MCP client (e.g. Claude Desktop) to the registered handlers.

Convert Existing Code to MCP Server

Convert the existing code, service, helper class, or method automatically to an MCP server using @McpService:

java
DefaultMcpMediator mediator = new DefaultMcpMediator(McpMediatorConfigurationBuilder.builder()
                .createDefault()
                .serverName(MY_EXAMPLE_MCP_SERVER_STDIO)
                .serverVersion("1.0.0.0")
                .build());
// DockerClientService is an existing service class to interact with the installed Docker Client
        mediator.registerHandler(McpServiceFactory.create(new DockerClientService(dockerClient))
                .createForNonAnnotatedMethods(false)
                .build());
        mediator.initialize();

DockerClientService:

java
@McpService(name = "docker_mcp_server",  description = "provides common docker command as mcp tools")
public class DockerClientService {

    DockerClient internalClient;

    @McpTool(name = "docker_start_container",
            description = "start an existing docker container using its containerId! containerId is required and " +
                    "can't be null or empty! if successful, returns true.")
    public boolean startContainerCmd(@NonNull String containerId) {
        internalClient.startContainerCmd(containerId)
                .exec();
        return true;
    }
    // ...
}

Checkout mcp-mediator-implementation-docker for more details.

Proxy MCP Mediator

To create a proxy server:

java
 // as an example ~/sdk/jdk/jdk-17.0.14+7/Contents/Home/bin/java
String command = args[0];
// e.g., -jar ~/mcp-mediator-example.jar
List<String> remoteServerArgs = List.of(Arrays.copyOfRange(args, 1, args.length));

ProxyMcpMediator mediator = new ProxyMcpMediator(McpMediatorConfigurationBuilder.builder()
       .creatProxy()
       .serializer(new ObjectMapper())
       .tools(true)
       .addRemoteServer(McpMediatorProxyConfiguration.McpMediatorRemoteMcpServerConfiguration.builder()
               .remoteTransportType(McpTransportType.STDIO)
               .remoteServerAddress(command)
               .remoteServerArgs(remoteServerArgs)
               .build())
       .serverName(MY_EXAMPLE_MCP_SERVER_STDIO)
       .serverVersion("1.0.0.0")
       .build());

mediator.initialize();

This mediator creates a Proxy MCP server and connects to all the given remote servers and works as a proxy between the client and the remote servers. The mediator will advertise all the available Tools to the clients during the initialization process. It is also expandable by registering request handlers using ProxyMcpMediator#registerHandler() same as DefaultMcpMediator.

Implemented Query MCP Servers

Query MCP servers are MCP servers that receive a query from the user and search a source for the content related to the input query. All the queries are part of mcp-mediator-implementation-query module and are defined using MCP Mediator Request Handlers. So far, these queries are implemented:

  • Wikipedia MCP Server: Search Wikipedia with an input query
  • Stackoverflow MCP Server: Search Stackoverflow website
  • GitHub MCP Server: Search for GitHub projects

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Read this first!

License

This project is licensed under the GPL3 License - see the LICENSE file for details.

Security & Authorization

MCP Mediator supports native integration with authorization frameworks, including Spring Security. Since MCP requests (especially over STDIO) rely purely on JSON payloads, you can use the McpMediatorInterceptor to extract tokens from the arguments payload and bridge them into your security context.

We provide two dedicated modules for this:

  • mcp-mediator-security: Generic security context and thread propagation for non-Spring projects.
  • mcp-mediator-spring-security: Bridges the mediator seamlessly into Spring Security's native SecurityContextHolder.

For complete implementation details and code examples, please check out the Security Integration Guide in the Wiki, or refer to GenericSecurityExample and SpringSecurityExample in the mcp-mediator-example module.

Observability & Error Handling Examples

The mcp-mediator-example module includes dedicated examples demonstrating how to fully instrument the Mediator:

  • ObservabilityExample: Shows how to programmatically inject an OpenTelemetry instance to export traces (via OTLP for Datadog or LoggingSpanExporter for standard SLF4J logs).
  • CustomErrorHandlerExample: Demonstrates customizing the McpMediatorExceptionHandler to intercept execution errors, route them through an SLF4J logger, and return safe, obfuscated fallback strings to the client without exposing internal Java stack traces.

Installazione

TypingMind
{
  "mcpServers": {
    "mcp-mediator": {
      "command": "java",
      "args": [
        "-jar",
        "path/to/your/mcp-mediator-example.jar",
        "{{config.ADDITIONAL_ARGS}}"
      ]
    }
  }
}

Usa MCP MCP Mediator con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso MCP Mediator, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi MCP Mediator come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di MCP Mediator.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "mcp-mediator": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di MCP Mediator, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di MCP Mediator.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare MCP Mediator per aiutarmi con questa attività?
MCP Mediator
Certo. Ho letto.
Ecco cosa ho trovato con MCP Mediator.

Domande frequenti

A cosa serve il server MCP MCP Mediator?

MCP Mediator è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare MCP Mediator MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare MCP Mediator con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP MCP Mediator con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando MCP Mediator, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego MCP Mediator MCP a TypingMind?

MCP Mediator funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre MCP Mediator MCP in TypingMind?

MCP Mediator mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare MCP Mediator MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se MCP Mediator richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇