Documentation
¶
Overview ¶
Package server provides a wrapper around the MCP SDK server that captures tool metadata at registration time, enabling runtime filtering by read-only status, whitelists, and blacklists.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTool ¶
AddTool registers a typed tool on the server and records its metadata. This is a free generic function because Go does not allow generic methods on types — the same pattern the MCP SDK uses for mcp.AddTool.
func BoolPtr ¶
BoolPtr returns a pointer to a bool value. Useful for MCP ToolAnnotations fields like DestructiveHint and OpenWorldHint which are *bool.
func RegisterAccountsListTool ¶
RegisterAccountsListTool registers the list_accounts tool on the given server. This tool is shared across all servers (Gmail, Drive, Calendar).
func RegisterLocalFSTools ¶
func RegisterLocalFSTools(s *Server)
RegisterLocalFSTools registers the list_local_files and read_local_file tools on the server. These are convenience tools that give the LLM visibility into the allowed local directories. This is a no-op if the server has no LocalFS configured.
Types ¶
type Server ¶
Server wraps an mcp.Server to capture tool metadata at registration time. Use AddTool to register tools; it records each tool's name and read-only status automatically. After all tools are registered, call ApplyFilter to remove tools that don't match the desired filter.
func NewServer ¶
func NewServer(impl *mcp.Implementation, opts *mcp.ServerOptions) *Server
NewServer creates a new Server wrapper around an mcp.Server.
func (*Server) ApplyFilter ¶
func (s *Server) ApplyFilter(filter ToolFilter) error
ApplyFilter removes tools from the server based on the filter configuration. Returns an error if the filter is invalid (e.g. enable and disable both set, or referencing unknown tool names).
func (*Server) ReadDirsDescription ¶
ReadDirsDescription returns a description snippet listing all configured directories (both read-only and read-write), suitable for appending to a tool description. Returns an empty string if no local filesystem is configured.
func (*Server) SetLocalFS ¶
SetLocalFS sets the local filesystem access for the server. Tools can use LocalFS() to read/write local files within allowed directories.
func (*Server) WriteDirsDescription ¶
WriteDirsDescription returns a description snippet listing the configured write-enabled directories, suitable for appending to a tool description. Returns an empty string if no local filesystem is configured or there are no write directories.
type ToolFilter ¶
type ToolFilter struct {
// ReadOnly limits the server to read-only tools.
ReadOnly bool
// Enable is a whitelist of tool names to expose. Mutually exclusive with Disable.
Enable []string
// Disable is a blacklist of tool names to hide. Mutually exclusive with Enable.
Disable []string
}
ToolFilter configures which tools are exposed by an MCP server.