Skip to main content

plugin-llm

A plugin that provides an MCP (Model Context Protocol) Streamable HTTP client. It sends prompts to LLM services (default: quarkus-chat-ui-claude) and retrieves responses.

What is MCP (Model Context Protocol)?

MCP is a protocol that standardizes communication with LLM services. It uses JSON-RPC over HTTP to invoke tools and send prompts.

plugin-llm implements MCP's "Streamable HTTP Transport" (protocol version 2025-03-26).

Usage

Basic Prompt Sending

# Usage example in workflow YAML
states:
ask-llm:
code:
- action: setUrl
args: ["http://192.168.5.15:8090"]
- action: prompt
args: ["Please write a script to check this server's status"]

@Action Methods

ActionArgumentsDescription
setUrl"http://host:port"Set the MCP server base URL. Changing this resets the session
prompt"prompt text"Send a prompt and return the LLM response
statusnoneGet MCP server status
listToolsnoneGet list of available MCP tools

Argument Formats

Arguments accept the following formats:

  • Quoted string: "http://localhost:8090"
  • JSON array: ["http://localhost:8090"]
  • Bare string: http://localhost:8090

Internal Operation

Session Management

  1. MCP session is initialized on the first prompt call
  2. Session ID is obtained via initialize request (response header Mcp-Session-Id)
  3. Subsequent requests include the session ID
  4. Session is reset when URL is changed via setUrl

Communication Flow

LlmActor                         MCP Server
| |
|-- initialize (JSON-RPC) -------->|
|<-- session-id (header) ----------|
| |
|-- notifications/initialized ---->|
| |
|-- tools/call: sendPrompt ------->|
|<-- result: {content: [{text}]} --|

HTTP Configuration

SettingValue
Connection timeout10 seconds
Request timeout5 minutes
Content-Typeapplication/json
Acceptapplication/json, text/event-stream

Response Extraction

Extracts entries with type: "text" from the result.content array in the MCP response and concatenates the text to return.

{
"result": {
"content": [
{"type": "text", "text": "Here is the script..."}
]
}
}

Real-time Output

When an output listener is set, callbacks are invoked in real-time upon response reception.

llmActor.setOutputListener(text -> System.out.println("[LLM] " + text));

Default Settings

SettingDefault Value
Base URLhttp://localhost:8090/mcp
Protocol version2025-03-26
MCP version1.0

Library Dependencies

  • JDK java.net.http.HttpClient (built-in) - No external HTTP dependencies
  • No dependencies on other plugins