org.llm4s.mcp

package org.llm4s.mcp

Members list

Type members

Classlikes

case class ClientInfo(name: String, version: String)

Client information sent during MCP protocol initialization. Identifies the client application to the server.

Client information sent during MCP protocol initialization. Identifies the client application to the server.

Value parameters

name

Name of the client application

version

Version of the client application

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ClientInfo

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ClientInfo.type
case class InitializeRequest(protocolVersion: String, capabilities: MCPCapabilities, clientInfo: ClientInfo)

Initialization request sent by client to establish MCP connection. First message in the MCP protocol handshake.

Initialization request sent by client to establish MCP connection. First message in the MCP protocol handshake.

Value parameters

capabilities

Client capabilities being advertised

clientInfo

Information about the client application

protocolVersion

Version of MCP protocol to use

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class InitializeResponse(protocolVersion: String, capabilities: MCPCapabilities, serverInfo: ServerInfo)

Initialization response returned by server during MCP handshake. Completes the protocol negotiation process.

Initialization response returned by server during MCP handshake. Completes the protocol negotiation process.

Value parameters

capabilities

Server capabilities being advertised

protocolVersion

Version of MCP protocol server will use

serverInfo

Information about the server application

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class JsonRpcError(code: Int, message: String, data: Option[Value])

JSON-RPC 2.0 error structure used in failed responses.

JSON-RPC 2.0 error structure used in failed responses.

Value parameters

code

Numeric error code

data

Optional additional error data

message

Human-readable error description

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object JsonRpcError

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class JsonRpcNotification(jsonrpc: String, method: String, params: Option[Value])

JSON-RPC 2.0 notification structure for MCP protocol communication. Notifications are requests without an ID - the client doesn't expect a response. Used for fire-and-forget messages like the "initialized" notification.

JSON-RPC 2.0 notification structure for MCP protocol communication. Notifications are requests without an ID - the client doesn't expect a response. Used for fire-and-forget messages like the "initialized" notification.

Value parameters

jsonrpc

Protocol version, always "2.0"

method

The method name to invoke on the server

params

Optional parameters for the method

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class JsonRpcRequest(jsonrpc: String, id: String, method: String, params: Option[Value])

JSON-RPC 2.0 request structure for MCP protocol communication. Used to send requests to MCP servers.

JSON-RPC 2.0 request structure for MCP protocol communication. Used to send requests to MCP servers.

Value parameters

id

Unique identifier for this request

jsonrpc

Protocol version, always "2.0"

method

The method name to invoke on the server

params

Optional parameters for the method

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class JsonRpcResponse(jsonrpc: String, id: String, result: Option[Value], error: Option[JsonRpcError])

JSON-RPC 2.0 response structure returned by MCP servers. Contains either a result or error, never both.

JSON-RPC 2.0 response structure returned by MCP servers. Contains either a result or error, never both.

Value parameters

error

Optional error information when failed

id

Identifier matching the original request

jsonrpc

Protocol version, always "2.0"

result

Optional result data when successful

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class MCPCapabilities(tools: Option[Value], logging: Option[Value], prompts: Option[Value], resources: Option[Value], roots: Option[Value], sampling: Option[Value])

Capabilities structure defining what features are supported. Used by both client and server during initialization handshake.

Capabilities structure defining what features are supported. Used by both client and server during initialization handshake.

Value parameters

logging

Logging capabilities

prompts

Prompt management capabilities

resources

Resource access capabilities

roots

Root directory access capabilities

sampling

Sampling capabilities

tools

Tool execution capabilities

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
trait MCPClient

MCP clients handle the communication with MCP servers to:

MCP clients handle the communication with MCP servers to:

  • Establish protocol handshake and negotiate capabilities
  • Retrieve available tools from remote servers
  • Execute tools remotely and return results
  • Manage connection lifecycle

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class MCPClientImpl(config: MCPServerConfig) extends MCPClient

Implementation of MCP client that connects to and communicates with MCP servers. Handles JSON-RPC communication, tool discovery, and execution delegation. Supports both 2025-06-18 (Streamable HTTP) and 2024-11-05 (HTTP+SSE) transports.

Implementation of MCP client that connects to and communicates with MCP servers. Handles JSON-RPC communication, tool discovery, and execution delegation. Supports both 2025-06-18 (Streamable HTTP) and 2024-11-05 (HTTP+SSE) transports.

Attributes

Companion
object
Supertypes
trait MCPClient
class Object
trait Matchable
class Any
object MCPClientImpl

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
case class MCPContent(`type`: String, text: Option[String], resource: Option[ResourceReference], annotations: Option[Value])

Enhanced content item within a tool response (PR #371 - Structured Tool Output). Supports text, resource links, and structured annotations.

Enhanced content item within a tool response (PR #371 - Structured Tool Output). Supports text, resource links, and structured annotations.

Value parameters

`type`

Content type: "text", "resource", "image", etc.

annotations

Optional structured metadata

resource

Resource reference (for resource type)

text

The actual content text (for text type)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object MCPContent

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
MCPContent.type
object MCPErrorCodes

Standard JSON-RPC and MCP-specific error codes.

Standard JSON-RPC and MCP-specific error codes.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class MCPServerConfig(name: String, transport: MCPTransport, timeout: Duration)

Configuration for MCP (Model Context Protocol) servers. Defines how to connect to and communicate with an MCP server.

Configuration for MCP (Model Context Protocol) servers. Defines how to connect to and communicate with an MCP server.

Value parameters

name

Unique identifier for this server configuration

timeout

Maximum time to wait for server responses

transport

Transport mechanism (stdio, SSE, or Streamable HTTP) for communication

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class MCPSession(sessionId: String, lastEventId: Option[String])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class MCPTool(name: String, description: String, inputSchema: Value)

Tool definition structure as provided by MCP servers. Describes a tool that can be executed remotely.

Tool definition structure as provided by MCP servers. Describes a tool that can be executed remotely.

Value parameters

description

Human-readable tool description

inputSchema

JSON Schema defining expected parameters

name

Unique tool identifier

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object MCPTool

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
MCPTool.type
class MCPToolRegistry(mcpServers: Seq[MCPServerConfig], localTools: Seq[ToolFunction[_, _]], cacheTTL: Duration, initializeOnStartup: Boolean) extends ToolRegistry, AutoCloseable

Attributes

Companion
object
Supertypes
trait AutoCloseable
class ToolRegistry
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait MCPTransport

Base trait for MCP transport mechanism configurations.

Base trait for MCP transport mechanism configurations.

Defines how to connect to an MCP server. Each transport type specifies the connection parameters and protocol to use.

Attributes

See also

StdioTransport for subprocess communication

SSETransport for legacy HTTP/SSE transport

StreamableHTTPTransport for modern HTTP transport

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object MCPTransport

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Base trait for transport implementations.

Base trait for transport implementations.

Provides the interface for sending JSON-RPC requests and notifications to an MCP server and managing the connection lifecycle.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class ResourceReference(uri: String, `type`: Option[String])

Reference to an MCP resource (PR #603 - Resource links in tool results).

Reference to an MCP resource (PR #603 - Resource links in tool results).

Value parameters

`type`

Optional MIME type or resource type

uri

URI of the referenced resource

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class SSETransport(url: String, name: String) extends MCPTransport

Server-Sent Events transport configuration using HTTP (MCP 2024-11-05 spec).

Server-Sent Events transport configuration using HTTP (MCP 2024-11-05 spec).

Connects to server via HTTP with SSE for streaming responses. This is the legacy transport protocol for backwards compatibility.

Value parameters

name

Unique identifier for this transport instance

url

HTTP URL of the SSE endpoint

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MCPTransport
class Object
trait Matchable
class Any
Show all
class SSETransportImpl(url: String, val name: String, timeout: Duration) extends MCPTransportImpl

Attributes

Supertypes
class Object
trait Matchable
class Any
case class ServerInfo(name: String, version: String)

Server information returned during MCP protocol initialization. Identifies the server application to the client.

Server information returned during MCP protocol initialization. Identifies the server application to the client.

Value parameters

name

Name of the server application

version

Version of the server application

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ServerInfo

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ServerInfo.type
case class StdioTransport(command: Seq[String], name: String) extends MCPTransport

Stdio transport configuration using subprocess communication.

Stdio transport configuration using subprocess communication.

Launches the MCP server as a subprocess and communicates via stdin/stdout. Suitable for local MCP servers and development environments.

Value parameters

command

Command line to launch the server process (e.g., Seq("npx", "@playwright/mcp@latest"))

name

Unique identifier for this transport instance

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MCPTransport
class Object
trait Matchable
class Any
Show all
class StdioTransportImpl(command: Seq[String], val name: String) extends MCPTransportImpl

Attributes

Supertypes
class Object
trait Matchable
class Any
case class StreamableHTTPTransport(url: String, name: String) extends MCPTransport

Streamable HTTP transport configuration (MCP 2025-03-26 spec).

Streamable HTTP transport configuration (MCP 2025-03-26 spec).

Connects to server via HTTP with support for streaming responses. This is the modern transport protocol supporting single-endpoint design.

Value parameters

name

Unique identifier for this transport instance

url

HTTP URL of the MCP endpoint

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MCPTransport
class Object
trait Matchable
class Any
Show all
class StreamableHTTPTransportImpl(url: String, val name: String, timeout: Duration) extends MCPTransportImpl

Attributes

Supertypes
class Object
trait Matchable
class Any
case class ToolsCallRequest(name: String, arguments: Option[Value])

Request structure for executing a tool via tools/call.

Request structure for executing a tool via tools/call.

Value parameters

arguments

Optional arguments to pass to the tool

name

Name of the tool to execute

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ToolsCallResponse(content: Seq[MCPContent], isError: Option[Boolean])

Response from tool execution containing the results.

Response from tool execution containing the results.

Value parameters

content

Array of content items returned by the tool

isError

Optional flag indicating if this represents an error

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ToolsListResponse(tools: Seq[MCPTool])

Response from tools/list request containing available tools.

Response from tools/list request containing available tools.

Value parameters

tools

Sequence of tool definitions available on the server

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type