mcpclient

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolResultJSON

func ToolResultJSON(res *mcp.CallToolResult) ([]byte, error)

ToolResultJSON extracts structured content as JSON bytes from a CallToolResult.

func ToolResultText

func ToolResultText(res *mcp.CallToolResult) string

ToolResultText extracts the text content from a CallToolResult.

Types

type Session

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

Session wraps an MCP client session with connection metadata.

func ConnectInProcess

func ConnectInProcess(ctx context.Context, root *redant.Command) (*Session, error)

ConnectInProcess creates an in-process MCP client session connected to the given redant command tree. The server runs in a goroutine.

func ConnectStdio

func ConnectStdio(ctx context.Context, command string, args ...string) (*Session, error)

ConnectStdio creates an MCP client session connected to an external command via stdio transport.

func (*Session) CallTool

func (s *Session) CallTool(ctx context.Context, name string, args map[string]any) (*mcp.CallToolResult, error)

CallTool invokes a tool by name with the given arguments.

func (*Session) Close

func (s *Session) Close() error

Close shuts down the session and underlying transport.

func (*Session) GetPrompt

func (s *Session) GetPrompt(ctx context.Context, name string, args map[string]string) (*mcp.GetPromptResult, error)

GetPrompt gets a prompt by name with arguments.

func (*Session) ListPrompts

func (s *Session) ListPrompts(ctx context.Context) ([]*mcp.Prompt, error)

ListPrompts returns all prompts exposed by the server.

func (*Session) ListResources

func (s *Session) ListResources(ctx context.Context) ([]*mcp.Resource, error)

ListResources returns all resources exposed by the server.

func (*Session) ListTools

func (s *Session) ListTools(ctx context.Context) ([]*mcp.Tool, error)

ListTools returns all tools exposed by the server.

func (*Session) ReadResource

func (s *Session) ReadResource(ctx context.Context, uri string) (*mcp.ReadResourceResult, error)

ReadResource reads a resource by URI.

func (*Session) ServerInfo

func (s *Session) ServerInfo() *mcp.Implementation

ServerInfo returns the server implementation info from initialization.

Jump to

Keyboard shortcuts

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