Panel For Example Panel For Example Panel For Example

Gitee Repository Assistant with Java and MCP

Author : Adrian October 29, 2025

Gitee MCP

With rapid advances in artificial intelligence, developer tools are evolving. Gitee, a leading code hosting platform in China, has released MCP (Model Control Protocol), allowing developers to manage repositories via AI assistants.

Overview: mcp-gitee

mcp-gitee is Gitee's Model Control Protocol (MCP) server implementation. It provides a set of tools that interact with the Gitee API and enables AI assistants to manage repositories, issues, pull requests, and more.

Gitee open-source MCP Server enables AI to operate repositories

Although the official Gitee release currently provides Go language implementations and various graphical configuration options, Java developers can also integrate MCP.

This article uses LangChain4j as a technical foundation to present an MCP integration approach for experienced Java developers. By leveraging the Java ecosystem, we will build an enterprise-grade AI repository assistant from scratch and show how to enable a Spring Boot application to use Gitee repository management features through MCP.

What is MCP?

MCP (Model Control Protocol) is a protocol that allows AI models to interact with external tools and services. Through MCP, an AI assistant can perform actions such as creating repositories, committing code, managing issues and pull requests, and more, making development workflows more intelligent and automated.

Key advantages of MCP:

  • Provides a standard interface for AI models to interact with external systems
  • Supports multiple transport modes to adapt to different scenarios
  • Enables AI to perform real operations rather than only offering suggestions

Preparation

Download Gitee MCP

First, download the MCP Gitee Server for your operating system from the Gitee MCP releases page.

The author used a Mac. After downloading and extracting, set the executable permission:

chmod+x mcp-gitee

Build the MCP Java client

For example, add the following dependencies to the root Maven project:

dev.langchain4jlangchain4j-mcp1.0.0-beta2dev.langchain4jlangchain4j-open-ai-spring-boot-starter1.0.0-beta2

Configuration file

Add AI model configuration in application.yml:

langchain4j:  open-ai:    chat-model:      api-key:sk-      base-url:https://api.deepseek.com/v1      model-name:deepseek-chat      log-requests:true

MCP transport modes

MCP supports multiple transport modes, mainly stdio and SSE. The following sections introduce each mode.

Mode 1: MCP stdio mode

stdio mode concept

stdio (standard input/output) mode is a basic MCP transport method that communicates with the MCP server via standard I/O streams. In this mode:

  • The MCP client starts the MCP server as a subprocess
  • Requests are sent to the server via standard input (stdin)
  • Responses are received via standard output (stdout)
  • Suitable for local development environments without extra network configuration

Advantages: simple setup and no additional network configuration. Disadvantage: only suitable for local use and not recommended for distributed environments.

Implementation code

@Autowiredprivate ChatLanguageModel chatLanguageModel;@SneakyThrows@Testvoid contextLoads() {    // Create stdio transport mode    McpTransport transport = new StdioMcpTransport.Builder()        .command(List.of("/Users/lengleng/Downloads/mcp-gitee-darwin-arm64/mcp-gitee", "-token", "GITEE-TOKEN"))        .logEvents(true) // Optional: show communication in logs        .build();    // Create MCP client    @Cleanup McpClient mcpClient = new DefaultMcpClient.Builder()        .transport(transport)        .build();    // Create tool provider    ToolProvider toolProvider = McpToolProvider.builder()        .mcpClients(List.of(mcpClient))        .build();    // Build Gitee AI service    GiteeAiService giteeAiService = AiServices.builder(GiteeAiService.class)        .chatLanguageModel(chatLanguageModel)        .toolProvider(toolProvider)        .build();    // Use AI service to query Gitee information    String result = giteeAiService.chat("获取 log4j/pig 开启的 issue 列表");    log.info("gitee mcp result: {}", result);}

Mode 2: MCP Server SSE mode

SSE mode concept

SSE (Server-Sent Events) mode is an HTTP-based one-way communication mechanism that allows the server to push data to clients. In MCP using SSE:

  • The MCP server runs as a separate process and listens for HTTP requests
  • Clients connect to the server via HTTP
  • The server can continuously push events and data to clients
  • Suitable for distributed environments and supports multiple client connections

Advantages: supports distributed deployment and multiple clients. Disadvantage: configuration is more complex and requires network setup.

Implementation steps

First, start the Gitee MCP server in SSE mode:

mcp-gitee -transport sse -token GITEE-TOKEN

Then use SSE transport mode in Java code:

@Autowiredprivate ChatLanguageModel chatLanguageModel;@SneakyThrows@Testvoid contextLoads() {    // Create SSE transport mode    McpTransport sseTransport = new HttpMcpTransport.Builder()        .sseUrl("http://localhost:8000/sse")        .logRequests(true) // Optional: log requests        .logResponses(true) // Optional: log responses        .build();    // Create MCP client    @Cleanup McpClient mcpClient = new DefaultMcpClient.Builder()        .transport(sseTransport)        .build();    // Create tool provider    ToolProvider toolProvider = McpToolProvider.builder()        .mcpClients(List.of(mcpClient))        .build();    // Build Gitee AI service    GiteeAiService giteeAiService = AiServices.builder(GiteeAiService.class)        .chatLanguageModel(chatLanguageModel)        .toolProvider(toolProvider)        .build();    // Use AI service to query Gitee information    String result = giteeAiService.chat("获取 log4j/pig 开启的 issue 列表");    log.info("gitee mcp result: {}", result);}

Sample output

2025-03-16T2351.211+08:00  INFO 67659 --- [      main] com.example.demo.DemoApplicationTests  : gitee mcp result: The log4j/pig repository currently has the following open issues:

Summary

By integrating Java with MCP, you can create a capable Gitee repository assistant that brings intelligence and automation to code management. This can improve developer efficiency and reduce repetitive work, allowing developers to focus on more creative tasks.

MCP provides two transport modes to meet different needs:

  • stdio mode is suitable for local development and testing
  • SSE mode is suitable for distributed environments and multiple client access

As AI technology evolves, MCP protocol features are likely to expand and provide more possibilities. This article aims to help you understand how to use Java with MCP to build your own AI-driven Gitee repository assistant.

Recommended Reading