MCP ExplorerExplorer

Spring Ai Mcp Example

@mrjishinon a month ago
1 Apache-2.0
FreeCommunity
AI Systems
A sample implementation of Model Context Protocol (MCP) using Spring AI.

Overview

What is Spring Ai Mcp Example

spring-ai-mcp-example is a sample implementation of the Model Context Protocol (MCP) using Spring AI, showcasing how to integrate AI capabilities into applications.

Use cases

Use cases include developing chatbots, intelligent data retrieval systems, and applications that require contextual understanding of user inputs.

How to use

To use spring-ai-mcp-example, clone the repository, set up a database, build the MCP server, insert sample data, and start both the MCP server and client. Configure the client with your OpenAI API key and access it via a web browser.

Key features

Key features include easy integration with OpenAI’s API, a sample database setup, and a straightforward client-server architecture using Spring framework.

Where to use

spring-ai-mcp-example can be used in fields such as AI application development, data processing, and any domain requiring context-aware AI interactions.

Content

This project demonstrates a sample implementation of Model Context Protocol (MCP) using Spring AI.

Installation

Install Ollama

  • Please install Ollama by referring to the link below.
  https://ollama.com/blog/ollama-is-now-available-as-an-official-docker-image

MCP Server

  • git clone this sources
  git clone https://github.com/mrjishin/spring-ai-mcp-example.git
  • Create a database in mysql (any other database will do, using JPA)
    Refer to spring-ai-mcp-server-example/docs/schema.sql or set it as “spring.jpa.hibernate.ddl-auto: create” in the application.yml file and run it to create the table.
  • Build spring-ai-mcp-server-example (The server source uses QueryDSL, so it must be built first.)
spring:
  jpa:
    hibernate:
      ddl-auto: create
  cd ./spring-ai-mcp-server-example/
  ./gradlew build
  • Insert sample data by referring to the spring-ai-mcp-server-example/docs/data-en.sql file.
  • Start MCP server.
  ./gradlew bootRun

MCP Client

  • In application.yml of the spring-ai-mcp-client-example source, change the values ​​of spring.api.openai.api-key to your openai API key.
spring:
  ai:
    openai:
      api-key: <YOUR_OPENAI_API_KEY>
  • Start MCP Client.
  cd ./spring-ai-mcp-client-example/
  ./gradlew bootRun
  • Now you can test it in a web browser.
  http://localhost:8888/

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers