mcphttp

package
v0.3.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package mcphttp contains remote Streamable HTTP and legacy SSE MCP clients.

The core mcp package only speaks stdio; this adapts an HTTP/JSON-RPC MCP server to the same tool.CoreTool shape (mcp__server__tool) WITHOUT touching the SDK. It implements the MCP "Streamable HTTP" transport: JSON-RPC over HTTP POST, with the server free to answer either as application/json or a text/event-stream (SSE) carrying the response. Custom headers (e.g. Authorization) come from the MCP row's env map, so a bearer token is configured as {"Authorization":"Bearer …"}.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolName

func ToolName(server, name string) string

ToolName mirrors mcp.ToolName so remote tools share the mcp__server__tool scheme.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a connection to one remote MCP server. New uses Streamable HTTP; NewSSE uses the legacy GET /sse + POST /message transport.

func New

func New(ctx context.Context, server, url string, headers map[string]string, insecure bool) (*Client, error)

New connects to a remote MCP endpoint and performs the initialize handshake. headers are sent on every request (Authorization, custom API keys, …). When insecure is true, TLS certificate verification is skipped so servers that present a self-signed certificate can still be reached (issue #108).

func NewSSE

func NewSSE(ctx context.Context, server, sseURL string, headers map[string]string, insecure bool) (*Client, error)

NewSSE connects to the legacy MCP SSE transport: a long-lived GET /sse announces a per-session POST /message endpoint, while JSON-RPC responses are delivered asynchronously as SSE message events.

func (*Client) Call

func (c *Client) Call(ctx context.Context, tool string, args any) (string, error)

Call invokes one tool and returns the concatenated text of its content blocks (ScopeSentry answers with a single JSON text block). Unlike the CoreTool wrapper from Tools(), this bypasses the agent permission (AskUser) layer — it is meant for backend batch jobs (e.g. asset sync) that call MCP tools programmatically.

func (*Client) Close

func (c *Client) Close() error

Close terminates the MCP session best-effort (DELETE with the session id, per the Streamable HTTP spec). Servers that don't track sessions simply ignore it.

func (*Client) Tools

func (c *Client) Tools(ctx context.Context) ([]actool.CoreTool, error)

Tools lists the server's tools and adapts them to CoreTools.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL