mcp

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package mcp provides a bridge between MCP (Model Context Protocol) servers and ZAP for high-performance tool calling.

This bridge auto-discovers MCP servers and exposes their capabilities via ZAP, providing 10-30x performance improvement over native MCP JSON-RPC.

Index

Constants

View Source
const (
	MsgTypeToolList   uint16 = 100 // List available tools
	MsgTypeToolCall   uint16 = 101 // Call a tool
	MsgTypeToolResult uint16 = 102 // Tool result

	// Field offsets
	FieldToolCount  = 0  // uint32 - number of tools
	FieldToolID     = 0  // uint32 - tool ID
	FieldToolName   = 4  // 64 bytes - tool name
	FieldArgsLen    = 68 // uint32 - arguments JSON length
	FieldArgs       = 72 // bytes - arguments JSON
	FieldResultLen  = 0  // uint32 - result length
	FieldResultData = 4  // bytes - result data
)

Message types for MCP-ZAP bridge

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

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

Bridge manages multiple MCP servers and exposes them via ZAP

func NewBridge

func NewBridge(node *zap.Node) *Bridge

NewBridge creates a new MCP-ZAP bridge

func (*Bridge) AddServer

func (b *Bridge) AddServer(name, command string, args ...string) error

AddServer adds and starts an MCP server

func (*Bridge) AddServerConfig

func (b *Bridge) AddServerConfig(cfg ServerConfig) error

AddServerConfig adds a server from a config

func (*Bridge) CallTool

func (b *Bridge) CallTool(ctx context.Context, toolID uint32, args map[string]interface{}) (interface{}, error)

CallTool calls a tool by ID

func (*Bridge) CallToolByName

func (b *Bridge) CallToolByName(ctx context.Context, name string, args map[string]interface{}) (interface{}, error)

CallToolByName calls a tool by name

func (*Bridge) GetTools

func (b *Bridge) GetTools() []Tool

GetTools returns all registered tools

func (*Bridge) Stop

func (b *Bridge) Stop()

Stop stops all MCP servers

type MCPServer

type MCPServer struct {
	Name    string
	Command string
	Args    []string
	Tools   []Tool
	// contains filtered or unexported fields
}

MCPServer represents a connection to an MCP server

func (*MCPServer) CallTool

func (s *MCPServer) CallTool(name string, args map[string]interface{}) (interface{}, error)

CallTool calls a tool on the MCP server

func (*MCPServer) ListTools

func (s *MCPServer) ListTools() ([]Tool, error)

ListTools discovers available tools from the MCP server

func (*MCPServer) Start

func (s *MCPServer) Start() error

Start starts the MCP server process

func (*MCPServer) Stop

func (s *MCPServer) Stop()

Stop stops the MCP server process

type ServerConfig

type ServerConfig struct {
	Name    string   `json:"name"`
	Command string   `json:"command"`
	Args    []string `json:"args"`
	Env     []string `json:"env,omitempty"`
}

ServerConfig configures an MCP server

type Tool

type Tool struct {
	ID          uint32                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	InputSchema map[string]interface{} `json:"inputSchema"`
}

Tool represents an MCP tool capability

Jump to

Keyboard shortcuts

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