Interface McpClient

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AbstractMcpClient, HttpMcpClient, StdioMcpClient

public interface McpClient extends AutoCloseable
A minimal MCP client speaking JSON-RPC 2.0 to shaft-mcp. Implementations perform the initialize / notifications/initialized handshake lazily on first use.

Two implementations exist: an ephemeral stdio child (one-shot mode) and a persistent streamable-HTTP daemon connection (session mode).

  • Method Summary

    Modifier and Type
    Method
    Description
    callTool(String name, tools.jackson.databind.node.ObjectNode arguments)
    Invokes tools/call for the given tool name and arguments.
    tools.jackson.databind.JsonNode
    callToolRaw(String name, tools.jackson.databind.node.ObjectNode arguments)
    Invokes a tool and returns the raw JSON-RPC result node (for --json).
    void
     
    Performs the initialize handshake if it has not already run.
    Lists the tools advertised by the server via tools/list.
    tools.jackson.databind.JsonNode
     
  • Method Details

    • initialize

      InitializeResult initialize()
      Performs the initialize handshake if it has not already run.
      Returns:
      the negotiated server identity
    • listTools

      List<Tool> listTools()
      Lists the tools advertised by the server via tools/list.
      Returns:
      the advertised tools
    • callTool

      CallToolResult callTool(String name, tools.jackson.databind.node.ObjectNode arguments)
      Invokes tools/call for the given tool name and arguments.
      Parameters:
      name - the tool name
      arguments - the arguments object (may be empty, never null)
      Returns:
      the tool result
    • listToolsRaw

      tools.jackson.databind.JsonNode listToolsRaw()
      Returns:
      the raw JSON-RPC result node of a tools/list call (for --json)
    • callToolRaw

      tools.jackson.databind.JsonNode callToolRaw(String name, tools.jackson.databind.node.ObjectNode arguments)
      Invokes a tool and returns the raw JSON-RPC result node (for --json).
      Parameters:
      name - the tool name
      arguments - the arguments object
      Returns:
      the raw result node
    • close

      void close()
      Specified by:
      close in interface AutoCloseable