Spring AI Alibaba Examples

repository·main·Indexed 25 days ago

https://github.com/spring-ai-alibaba/examples

A collection of example modules demonstrating use cases for Spring AI and Spring AI Alibaba, including basic chat, image generation, Retrieval-Augmented Generation (RAG), and Model Context Protocol (MCP) implementations. The repository includes Docker Compose configurations for AI services such as Ollama, Mem0, pgvector, and Nacos 3.x, as well as a Python-based A2A Agent example for Agent-to-Agent protocol demonstration.

Tokens
156.2K
Snippets
413
Records
768
Agent score
84%

What's inside spring-ai-alibaba-examples

  1. Overview of the Model Context Protocol (MCP) Java SDK

    main
    The MCP Java SDK is a Java implementation of the Model Context Protocol specification. It allows developers to build both synchronous and asynchronous clients to interact with MCP servers. The SDK is designed with reactive programming support using Project Reactor and utilizes a stdio-based server transport mechanism.
  2. Overview of Structured Output Converters

    main

    Spring AI provides Structured Output converters to transform LLM responses from raw Strings into structured data types like JSON, XML, or Java classes. The converter works by appending format instructions to the prompt and then parsing the model's response into the target type.

    Available converter implementations include:

    • BeanOutputConverter<T>: Instructs the model to generate a JSON response matching a specific Java class (Bean) or ParameterizedTypeReference, then deserializes it using ObjectMapper.
    • MapOutputConverter: Instructs the model to generate an RFC8259 compliant JSON response and converts it into a java.util.Map<String, Object>.
    • ListOutputConverter: Instructs the model to generate comma-separated values and converts the output into a java.util.List.
  3. Overview of Spring AI MCP Auth Web Server

    main
    The Spring AI MCP Auth Web Server is an example implementation of a Model Context Protocol (MCP) server that includes an authentication mechanism. It demonstrates how to protect MCP services by using Spring WebFlux HTTP filters to ensure only authenticated clients can access the server. The project uses a reactive, non-blocking architecture to handle requests asynchronously.
  4. Overview of JManus Agent Platform

    main

    JManus is a general-purpose AI Agent platform and development environment built on Spring AI Alibaba. It is designed to help users build vertical-domain agents with low cost and high efficiency.

    Key capabilities include:

    • OpenManus Implementation: Supports automatic planning and execution via a UI.
    • MCP (Model Context Protocol) Integration: Seamlessly connects agents to external services, APIs, and databases.
    • PLAN-ACT Mode: Enables complex reasoning, step-by-step execution, and dynamic adjustment.
    • UI-based Configuration: Allows users to adjust agent parameters, models, tools, and task planning through a web interface without changing code.
    • Automated Engineering: Supports converting natural language plans into concrete Spring AI Alibaba agent projects.
  5. Overview of DeepResearch Agent

    main

    DeepResearch is a specialized multi-agent application built using Spring AI Alibaba Graph. It is designed to assist users in generating in-depth research reports by combining LLM capabilities with specialized tools.

    Supported tools include:

    • Web Search: For querying online information.
    • Crawling: For extracting content from web pages.
    • Python Script Engine: For executing computational tasks.
  6. Overview of LangGraph Custom RAG Example

    main

    This module implements a custom Retrieval-Augmented Generation (RAG) workflow using Spring AI Alibaba, following the LangGraph pattern. It features a Self-Correction capability through the following workflow:

    1. Generate Query: Generates a query optimized for retrieval based on the user's original question.
    2. Grade Documents: Retrieves relevant documents and evaluates their relevance to the query.
    3. Rewrite: If retrieved documents are insufficient or irrelevant, the system automatically reconstructs the query and restarts the retrieval process.
    4. Generate Answer: Produces the final answer based on high-quality, relevant documents.
  7. Overview of Nacos MCP Gateway

    main

    The Nacos MCP Gateway acts as an aggregator for multiple Model Context Protocol (MCP) Servers. It automatically discovers MCP Servers registered in Nacos, aggregates their tools into a single unified list, and exposes them as a single MCP Server to AI clients.

    Key Features:

    • Automatic Tool Discovery: Discovers configured MCP Servers from the Nacos registry.
    • Tool Aggregation: Combines tools from multiple servers into one list.
    • Dynamic Updates: Polls Nacos every 30 seconds to detect and incrementally update tool changes (additions, deletions, or modifications).
    • Multi-protocol Support: Supports HTTP, HTTPS, MCP-SSE, and MCP-Streamable.
    • Unified Exposure: The gateway itself functions as an MCP Server for external clients.
  8. Overview of Spring AI Alibaba MCP Nacos Integration

    main

    This project demonstrates the integration of Spring AI Alibaba with the Model Context Protocol (MCP) and Nacos to achieve service discovery and registration. It showcases a complete MCP ecosystem through the following capabilities:

    • Registration: MCP services are registered into Nacos.
    • Distributed Deployment: MCP server services are deployed in a distributed manner via Nacos, allowing MCP clients to perform load-balanced calls to MCP servers.
    • Gateway: Existing RESTful interface applications are transformed into MCP server services using Nacos.
    • Routing: Control of tool routing for MCP client calls (feature pending).

    Dependency Requirement: Requires spring-ai-extensions version 1.1.0.0-M4 or higher.

  9. Overview of Spring AI MCP Client Example

    main

    This project is a client-side example demonstrating how to use the Model Context Protocol (MCP) within the Spring AI framework. It allows you to build applications that communicate with MCP servers to perform model calls and tool function calls (e.g., weather queries).

    Key Features:

    • Communication via MCP protocol.
    • Support for STDIO-based connections.
    • Basic chat functionality.
    • Integration with Alibaba Cloud DashScope API as the LLM provider.