mcpclient

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mcpclient provides an MCP client wrapper for CLI commands.

Index

Constants

View Source
const (
	DefaultMCPURL = "http://127.0.0.1:9119/mcp"
	ClientTimeout = 25 * time.Minute // exceeds 20m long-poll max
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the MCP client for CLI usage.

func Connect

func Connect(ctx context.Context, url string) (*Client, error)

Connect returns a connected MCP client. Uses DefaultMCPURL if url is empty.

func New

func New(ctx context.Context, mcpURL string) (*Client, error)

New creates a new MCP client and connects to the server. It automatically calls the workflow tool with "cli" task if available.

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, name string, args map[string]interface{}) (*mcp.CallToolResult, error)

CallTool calls an MCP tool and returns the raw result.

func (*Client) CallToolJSON

func (c *Client) CallToolJSON(ctx context.Context, name string, args map[string]interface{}, dest interface{}) error

CallToolJSON calls an MCP tool and unmarshals the JSON result into dest.

func (*Client) CallToolText

func (c *Client) CallToolText(ctx context.Context, name string, args map[string]interface{}) (string, error)

CallToolText calls an MCP tool and returns the text result.

func (*Client) Close

func (c *Client) Close() error

Close closes the MCP client connection.

func (*Client) CrawlCreate

func (c *Client) CrawlCreate(ctx context.Context, opts CrawlCreateOpts) (*protocol.CrawlCreateResponse, error)

CrawlCreate calls crawl_create and returns the session.

func (*Client) CrawlGet

func (c *Client) CrawlGet(ctx context.Context, flowID string) (*protocol.CrawlGetResponse, error)

CrawlGet calls crawl_get and returns full flow data.

func (*Client) CrawlPoll

func (c *Client) CrawlPoll(ctx context.Context, sessionID string, opts CrawlPollOpts) (*protocol.CrawlPollResponse, error)

CrawlPoll calls crawl_poll and returns summary, flows, forms, or errors.

func (*Client) CrawlSeed

func (c *Client) CrawlSeed(ctx context.Context, sessionID string, seedURLs, seedFlows string) (*protocol.CrawlSeedResponse, error)

CrawlSeed calls crawl_seed to add seeds to a session.

func (*Client) CrawlSessions

func (c *Client) CrawlSessions(ctx context.Context, limit int) (*protocol.CrawlSessionsResponse, error)

CrawlSessions calls crawl_sessions and returns all sessions.

func (*Client) CrawlStatus

func (c *Client) CrawlStatus(ctx context.Context, sessionID string) (*protocol.CrawlStatusResponse, error)

CrawlStatus calls crawl_status and returns session status.

func (*Client) CrawlStop

func (c *Client) CrawlStop(ctx context.Context, sessionID string) error

CrawlStop calls crawl_stop to stop a session.

func (*Client) OastCreate

func (c *Client) OastCreate(ctx context.Context, label string) (*protocol.OastCreateResponse, error)

OastCreate calls oast_create and returns the session.

func (*Client) OastDelete

func (c *Client) OastDelete(ctx context.Context, oastID string) error

OastDelete calls oast_delete.

func (*Client) OastGet

func (c *Client) OastGet(ctx context.Context, oastID, eventID string) (*protocol.OastGetResponse, error)

OastGet calls oast_get and returns full event data.

func (*Client) OastList

func (c *Client) OastList(ctx context.Context, limit int) (*protocol.OastListResponse, error)

OastList calls oast_list and returns sessions.

func (*Client) OastPoll

func (c *Client) OastPoll(ctx context.Context, oastID string, opts OastPollOpts) (*protocol.OastPollResponse, error)

OastPoll calls oast_poll and returns summary or list of events.

func (*Client) ProxyGet

func (c *Client) ProxyGet(ctx context.Context, flowID string) (*protocol.ProxyGetResponse, error)

ProxyGet calls proxy_get and returns full request/response data.

func (*Client) ProxyPoll

func (c *Client) ProxyPoll(ctx context.Context, opts ProxyPollOpts) (*protocol.ProxyPollResponse, error)

ProxyPoll calls proxy_poll and returns summary or list of flows.

func (*Client) ProxyRuleAdd

func (c *Client) ProxyRuleAdd(ctx context.Context, opts RuleAddOpts) (*protocol.RuleEntry, error)

ProxyRuleAdd calls proxy_rule_add and returns the created rule.

func (*Client) ProxyRuleDelete

func (c *Client) ProxyRuleDelete(ctx context.Context, ruleID string) error

ProxyRuleDelete calls proxy_rule_delete.

func (*Client) ProxyRuleList

func (c *Client) ProxyRuleList(ctx context.Context, typeFilter string, limit int) (*protocol.RuleListResponse, error)

ProxyRuleList calls proxy_rule_list and returns rules.

func (*Client) ProxyRuleUpdate

func (c *Client) ProxyRuleUpdate(ctx context.Context, ruleID string, opts RuleUpdateOpts) (*protocol.RuleEntry, error)

ProxyRuleUpdate calls proxy_rule_update and returns the updated rule.

func (*Client) ReplayGet

func (c *Client) ReplayGet(ctx context.Context, replayID string) (*protocol.ReplayGetResponse, error)

ReplayGet calls replay_get and returns full response data.

func (*Client) ReplaySend

func (c *Client) ReplaySend(ctx context.Context, opts ReplaySendOpts) (*protocol.ReplaySendResponse, error)

ReplaySend calls replay_send and returns the result.

func (*Client) RequestSend

func (c *Client) RequestSend(ctx context.Context, opts RequestSendOpts) (*protocol.ReplaySendResponse, error)

RequestSend calls request_send and returns the result.

type CrawlCreateOpts

type CrawlCreateOpts struct {
	Label        string
	SeedURLs     string
	SeedFlows    string
	Domains      string
	Headers      map[string]string
	MaxDepth     int
	MaxRequests  int
	Delay        string
	Parallelism  int
	SubmitForms  bool
	IgnoreRobots bool
}

CrawlCreateOpts are options for CrawlCreate.

type CrawlPollOpts

type CrawlPollOpts struct {
	OutputMode   string // "summary", "flows", "forms", "errors"
	Host         string
	Path         string
	Method       string
	Status       string
	Contains     string
	ContainsBody string
	ExcludeHost  string
	ExcludePath  string
	Since        string // flows mode
	Limit        int
	Offset       int
}

CrawlPollOpts are options for CrawlPoll.

type OastPollOpts

type OastPollOpts struct {
	OutputMode string // "summary" or "events"
	Since      string
	EventType  string
	Wait       string
	Limit      int
}

OastPollOpts are options for OastPoll.

type ProxyPollOpts

type ProxyPollOpts struct {
	OutputMode   string // "summary" or "flows"
	Source       string // "proxy", "replay", or empty for both
	Host         string
	Path         string
	Method       string
	Status       string
	Contains     string
	ContainsBody string
	Since        string // list mode
	ExcludeHost  string
	ExcludePath  string
	Limit        int // list mode
	Offset       int // list mode
}

ProxyPollOpts are options for ProxyPoll.

type ReplaySendOpts

type ReplaySendOpts struct {
	FlowID          string
	Method          string
	Body            string
	Target          string
	AddHeaders      []string
	RemoveHeaders   []string
	Path            string
	Query           string
	SetQuery        []string
	RemoveQuery     []string
	SetJSON         map[string]interface{}
	RemoveJSON      []string
	FollowRedirects bool
	Force           bool
}

ReplaySendOpts are options for ReplaySend.

type RequestSendOpts

type RequestSendOpts struct {
	URL             string
	Method          string
	Headers         map[string]string
	Body            string
	FollowRedirects bool
}

RequestSendOpts are options for RequestSend.

type RuleAddOpts

type RuleAddOpts struct {
	Type    string
	Match   string
	Replace string
	Label   string
	IsRegex bool
}

RuleAddOpts are options for ProxyRuleAdd.

type RuleUpdateOpts

type RuleUpdateOpts struct {
	Match   string
	Replace string
	Label   string
	IsRegex *bool // nil = preserve existing, non-nil = set to value
}

RuleUpdateOpts are options for ProxyRuleUpdate.

Jump to

Keyboard shortcuts

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