mcpserve

package module
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 15 Imported by: 0

README

mcpserve

Project Badges

Standalone, decoupled Model Context Protocol (MCP) server for the TinyWasm ecosystem.

Core Features

  • Decoupled Architecture: Domain handlers remain agnostic of MCP types while using shared metadata.
  • Interface-based Discovery: Strict typing via ToolProvider interface.
  • IDE Integration: automated configuration for VS Code & Antigravity (Profiles supported).

Setup

h.mcp = mcpserve.NewHandler(config, toolProviders, tui, exit)
h.mcp.ConfigureIDEs() // Auto-configures IDEs
go h.mcp.Serve()      // Starts HTTP server

Documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryData

type BinaryData struct {
	MimeType string
	Data     []byte
}

BinaryData represents binary response from tools (imported from handlers)

type Config

type Config struct {
	Port          string
	ServerName    string // MCP server name
	ServerVersion string // MCP server version
	AppName       string // Application name (used to generate MCP server ID)
}

Config contains the configuration for Handler

type Handler

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

Handler handles the Model Context Protocol server and configuration

func NewHandler

func NewHandler(config Config, toolHandlers []ToolProvider, tui TuiInterface, exitChan chan bool) *Handler

NewHandler creates a new MCP handler with minimal dependencies

func (*Handler) ConfigureIDEs

func (h *Handler) ConfigureIDEs()

ConfigureIDEs automatically configures supported IDEs with this MCP server

func (*Handler) Name added in v0.0.5

func (h *Handler) Name() string

Name returns the handler name for Loggable interface

func (*Handler) OnUIAction added in v0.0.22

func (h *Handler) OnUIAction(actionFunc func(string))

OnUIAction sets the callback for generic UI actions triggered from TUI or IDE

func (*Handler) PublishLog added in v0.0.22

func (h *Handler) PublishLog(msg string)

PublishLog publishes a log message to SSE

func (*Handler) Serve

func (h *Handler) Serve()

Serve starts the Model Context Protocol server for LLM integration via HTTP

func (*Handler) SetLog added in v0.0.5

func (h *Handler) SetLog(f func(message ...any))

SetLog implements Loggable interface

func (*Handler) Stop added in v0.0.8

func (h *Handler) Stop() error

Stop gracefully shuts down the MCP HTTP server

func (*Handler) URL added in v0.0.20

func (h *Handler) URL() string

URL returns the address where the MCP server is serving. This allows *Handler to satisfy the agent.MCPServer interface via duck typing.

type IDEInfo

type IDEInfo struct {
	ID             string
	Name           string
	GetConfigDir   func() (string, error)
	ConfigFileName string

	// IDE-specific JSON format configuration
	ServersKey   string         // "servers" for VS Code, "mcpServers" for Antigravity
	URLKey       string         // "url" for VS Code, "serverUrl" for Antigravity
	ExtraFields  map[string]any // Additional fields like "type", "autoStart"
	HasInputs    bool           // VS Code has "inputs" array, Antigravity doesn't
	SkipProfiles bool           // true = single config file, no profile scanning
}

IDEInfo represents a supported IDE and its MCP configuration format

type Loggable added in v0.0.5

type Loggable interface {
	Name() string
	SetLog(logger func(message ...any))
}

Loggable defines the interface for handlers that support logging

type ParameterMetadata

type ParameterMetadata struct {
	Name        string
	Description string
	Required    bool
	Type        string // "string", "number", "boolean"
	EnumValues  []string
	Default     any
}

ParameterMetadata describes a tool parameter

type ToolExecutor

type ToolExecutor func(args map[string]any)

ToolExecutor defines how a tool should be executed Handlers implement this to provide execution logic without exposing internals args: map of parameter name to value from MCP request

type ToolMetadata

type ToolMetadata struct {
	Name        string
	Description string
	Parameters  []ParameterMetadata
	Execute     ToolExecutor // Handler provides execution function
}

ToolMetadata provides MCP tool configuration metadata This is the standard interface that all handlers should implement

type ToolProvider added in v0.0.16

type ToolProvider interface {
	GetMCPToolsMetadata() []ToolMetadata
}

ToolProvider defines the interface for handlers that support MCP tools

type TuiInterface

type TuiInterface interface {
	RefreshUI()
}

TuiInterface defines what the MCP handler needs from the TUI

Jump to

Keyboard shortcuts

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