mcp

package
v1.788.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxScanHosts = 1024
)

Variables

This section is empty.

Functions

func CallTool

func CallTool(url, token, toolName string, arguments map[string]interface{}) (string, error)

CallTool opens a short-lived MCP connection to url, calls toolName with the supplied arguments, and returns the JSON-marshalled result content.

func GetIdFromServerNameAndToolName

func GetIdFromServerNameAndToolName(serverName, toolName string) string

func GetServerNameAndToolNameFromId

func GetServerNameAndToolNameFromId(id string) (string, string)

func GetToolsFromURL

func GetToolsFromURL(url, token string) ([]*protocol.Tool, error)

GetToolsFromURL connects to an HTTP-based MCP server and returns its tool list. Always uses StreamableHTTP transport (the current MCP standard); when token is non-empty it is sent as a Bearer Authorization header.

func NewClient

func NewClient(url, token string) (*client.Client, error)

NewClient opens a persistent MCP connection to the given URL using StreamableHTTP transport. token is sent as a Bearer Authorization header when non-empty. The caller is responsible for closing the returned client.

Types

type InnerMcpServer

type InnerMcpServer struct {
	Host string `json:"host"`
	Port int    `json:"port"`
	Path string `json:"path"`
	Url  string `json:"url"`
}

type ScanIntranetResult

type ScanIntranetResult struct {
	CIDR         []string          `json:"cidr"`
	ScannedHosts int               `json:"scannedHosts"`
	OnlineHosts  []string          `json:"onlineHosts"`
	Servers      []*InnerMcpServer `json:"servers"`
}

func ScanIntranetServers

func ScanIntranetServers(cidr, ports, paths []string) (*ScanIntranetResult, error)

ScanIntranetServers probes all IPv4 hosts in cidr for active MCP endpoints. ports and paths may be empty, in which case defaults are used.

type ServerConfig

type ServerConfig struct {
	// Stdio config
	Command string            `json:"command"`
	Args    []string          `json:"args"`
	Env     map[string]string `json:"env"`

	// SSE / StreamableHTTP config
	URL string `json:"url"`

	// Transport type: "sse", "stdio", "streamablehttp"
	// Auto-detected from URL when omitted: URL set → streamablehttp, else → stdio.
	Type string `json:"type,omitempty"`
}

type ToolSet

type ToolSet struct {
	// Connections maps server name → open MCP connection (closed after the conversation).
	Connections map[string]*client.Client
	// Tools is the protocol-level tool list passed to the AI model.
	Tools []*protocol.Tool
	// BuiltinTools is the registry of server-side builtin tools.
	BuiltinTools     *tool.ToolRegistry
	WebSearchEnabled bool
}

ToolSet holds everything needed to execute MCP and builtin tool calls during a model conversation: the open connections, the tool list for the AI, and the builtin tool registry.

Jump to

Keyboard shortcuts

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