agent

package
v0.0.0-...-383fcbf Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotionMCPURL = "https://mcp.notion.com/mcp"
)

Variables

This section is empty.

Functions

func ExtractTextResponses

func ExtractTextResponses(res *mcp.CallToolResult) []string

ExtractTextResponses is a helper to convert a CallToolResult’s content to plain text strings when the tool returns textual responses.

Types

type Agent

type Agent struct {
	Config *Config

	EmailProcessor func(email mail.Email)
	SlackProcessor func(event interface{})
	MCPClient      *MCPClient
	// contains filtered or unexported fields
}

func (*Agent) GetCustomConfig

func (a *Agent) GetCustomConfig(customConfig interface{}) error

func (*Agent) GetSlackClient

func (a *Agent) GetSlackClient() *slack.Client

func (*Agent) HasEmail

func (a *Agent) HasEmail() bool

func (*Agent) InitializeSlackClient

func (a *Agent) InitializeSlackClient()

initializeSlackClient creates and starts the Slack client

func (*Agent) LoadConfig

func (a *Agent) LoadConfig(configPath string) error

loadConfig reads and parses the YAML configuration file

func (*Agent) NewLLM

func (a *Agent) NewLLM() *gpt.OpenAI

func (*Agent) ProcessEmails

func (a *Agent) ProcessEmails()

processEmails handles the email processing logic

func (*Agent) SetTestMode

func (a *Agent) SetTestMode(test bool)

func (*Agent) WaitForSignal

func (a *Agent) WaitForSignal()

type Config

type Config struct {
	Slack *struct {
		Token    string `yaml:"token,omitempty"`
		AppToken string `yaml:"app_token,omitempty"`
		Channel  string `yaml:"channel"`
	} `yaml:"slack"`
	GPT *struct {
		Key   string `yaml:"key"`
		Model string `yaml:"model"`
	} `yaml:"gpt"`
	Mail *struct {
		Label     string `yaml:"label"`
		MaxID     string `yaml:"maxid,omitempty"`
		Wait      int    `yaml:"wait,omitempty"`
		Secret    string `yaml:"secret"`
		AuthToken string `yaml:"auth_token,omitempty"`
	} `yaml:"mail"`
	AgentConfig interface{} `yaml:"agent_config,omitempty"`
}

Config represents the YAML configuration structure

type MCPClient

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

MCPClient wraps an MCP client session and provides convenience helpers.

func ConnectMCP

func ConnectMCP(ctx context.Context, opts MCPOptions) (*MCPClient, error)

ConnectMCP connects to an MCP server using the provided options and returns a ready session.

func (*MCPClient) CallTool

func (c *MCPClient) CallTool(ctx context.Context, name string, arguments map[string]any) (*mcp.CallToolResult, error)

CallTool invokes a tool by name with the provided arguments. Arguments should match the tool’s JSON Schema.

func (*MCPClient) Close

func (c *MCPClient) Close() error

Close closes the underlying MCP session and releases resources.

func (*MCPClient) ListTools

func (c *MCPClient) ListTools(ctx context.Context) ([]*mcp.Tool, error)

ListTools retrieves all tools exposed by the connected MCP server. It transparently handles pagination if the server returns a cursor.

type MCPConnectionMethod

type MCPConnectionMethod string

MCPConnectionMethod identifies how to connect to an MCP server.

const (
	// MethodStreamable connects to a remote MCP server using the Streamable HTTP transport.
	MethodStreamable MCPConnectionMethod = "streamable"
	// MethodSSE connects to a remote MCP server using SSE transport.
	MethodSSE MCPConnectionMethod = "sse"
	// MethodSTDIO launches a local MCP server process and connects over stdio.
	MethodSTDIO MCPConnectionMethod = "stdio"
)

type MCPOptions

type MCPOptions struct {
	// Implementation metadata for the MCP client.
	ImplementationName    string
	ImplementationVersion string

	// Method selects the connection approach (remote via npx mcp-remote or stdio).
	Method MCPConnectionMethod

	// Remote URL (used when MethodRemote). Example: https://mcp.notion.com/mcp
	URL string

	// Local command and args (used when MethodSTDIO). Example: command="myserver", args=["--flag"]
	Command    string
	Args       []string
	Env        []string
	HTTPClient *http.Client
}

MCPOptions configures how to connect to an MCP server.

type NotionMCP

type NotionMCP struct {
	NotionKey             string
	ImplementationName    string
	ImplementationVersion string
	URL                   string
}

func (*NotionMCP) STDIO

func (n *NotionMCP) STDIO() (*MCPClient, error)

func (*NotionMCP) STDIOStreamable

func (n *NotionMCP) STDIOStreamable() (*MCPClient, error)

requires npx in the system to work correctly

func (*NotionMCP) Streamable

func (n *NotionMCP) Streamable() (*MCPClient, error)

not clear this is working correctly... still getting 401 errors

Jump to

Keyboard shortcuts

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