Springing into AI - Part 18: MCP Client - Playground

About

In our previous posts, we have been using MCP Inspector as means to test out various capabilities of our developed Hobbits Inc MCP Server such as Elicitation, Sampling, Progress Notifications, Server Side Resources, Prompts. In this post we look at replacing Mcp Inspector with a MCP Client developed using Spring AI that would open it up for integration in real world applications.  

Project

For the purpose of our playground, users would be interacting with our application via terminal. This is purely done to keep things simple from playground perspective (but can be easily extended to a shiny front end). In here, the terminal would be interacting with a MCP Client to carry out the user requests. The configured LLM in the MCP Client would be making decisions whether to invoke a particular tool or not based on the confidence in the correlation of user request recieved and the description of each tool that it is aware of. The LLM knows of these tools, as the Chat Client that interacts with it would be configured for tools during the registration via  ToolCallbackProvider. Figure below presents a high level architecture overview.



Setup

Our project setup encompasses the following:
  • LLM:                                mistral-nemo:latest (Running locally using ollama)
  • MCP Client:
    • Java:                        17
    • Spring AI:               1.1.2
    • Spring Boot:           4.0.3
    • Spring Shell:           3.3.0
    • Source Code:          can be viewed here
  • MCP Server:
    • Java:                        17
    • Spring AI:               1.1.2
    • Spring Boot:           4.0.3
    • Source Code:          can be viewed here
  • Demo:
    • Prompts:                 demo video can be seen here
      • About: demonstrates both static and dynamic prompts from the MCP Server.
      • Static Prompt: The static prompt in the demo provides a generic welcome greeting about Hobbits Inc to the user. 
      • Dynamic Prompt: This provides a list of supported hobbits that are obtained from the MCP Server for a particular dynamic prompt. Once selected, the content of that prompt is then displayed. One can see in the demo content the dynamic URI that is used. Coupled with user selection and the URI, the MCP Server obtains this and renders the prompt response.
    • Resources:              demo video can be seen here
      • About: demonstrates both static and dynamic resources from the MCP Server.
        • Static Resource: The static prompt in the demo provides a Base64 encoded of a sample pdf content. This can be copied and decoded using an online Base64 decode tool that can render the decoded content.
        • Dynamic Resource: This provides a list of supported hobbits that are obtained from the MCP Server for a particular dynamic resource. For playground, both hobbit mugshots (binary image data), and hobbit profile (textual data) is obtained. The binary image data is a Base64 encoded value that can be copied and decoded using an online tool. The textual content of the profile for a chosen hobbit can be seen as is obtained from MCP Server. 
      • Chatbot:                 demo video can be seen here
        • About: demonstrats various tool capabilities that were prevoiusly developed in previous psots. 
        • Elicitation: is demonstrated through means of a hobbit travel planner. In this, the MCP Server requests the hobbit which route they would prefer to take. This makes the user experience more engaging and interactive while the MCP Server then obtains the request and processes the task towards completion.
        • Sampling: is demonstrated through means of a hobbit recipe food analyzer. Here, the MCP Server sends a prompt from the server to the client requesting LLM to process a particular request is may require to complete the task before returning the final response back to the user. 
        • Progress Notifications: is demonstrated through means of hobbit party planner. This is a useful capability of the server, as often tasks can take longer to complete, so providing progress updates is a means to keep the user engaged and updated about the task as it reaches completion. For the demo, we periodically emulate progress at regular intervals.

    Comments

    Popular posts from this blog

    Springing into AI - Part 4: LLM - Machine Setup

    Springing into AI - Part 1: 1000 feet overview

    Springing into AI - Part 2: Generative AI