Documentation
¶
Overview ¶
Package mcpclient is a small Model Context Protocol client for the AudD account service: Streamable HTTP transport, JSON-RPC 2.0, tools/list and tools/call. The session ID is cached on disk for a few minutes so back-to-back commands skip the initialize handshake.
Index ¶
Constants ¶
const ProtocolVersion = "2025-06-18"
ProtocolVersion is the MCP revision the client speaks.
const SessionTTL = 10 * time.Minute
SessionTTL is how long a cached session ID is reused.
Variables ¶
var ToolScopes = map[string]string{
"get_profile": "profile:read",
"get_account_status": "account:read",
"get_usage_stats": "usage:read",
"get_api_token": "token:read",
"rotate_api_token": "token:write",
"list_plans": "billing:read",
"get_billing_history": "billing:read",
"get_amount_owed": "billing:read",
"subscribe_to_plan": "billing:pay",
"create_renewal_payment": "billing:pay",
"buy_bonus_requests": "billing:pay",
}
ToolScopes names the OAuth scope each AudD tool needs; used in hints.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one MCP server.
func New ¶
New returns a client for the MCP endpoint baseURL. token returns the current OAuth access token.
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) (structured map[string]any, text string, err error)
CallTool calls a tool. It returns the structured result (nil when the tool returned none) and the text content. A result with isError set is returned as an *output.Error.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client.
func WithRefresh ¶
WithRefresh sets how to get a new access token, whatever its expiry, when the server rejects the current one (revoked early, clock skew). The request is then retried once.
func WithSessionCache ¶
WithSessionCache stores the session ID at path (e.g. CacheDir()/mcp-session-<profile>).