mcpserver

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mcpserver provides MCP (Model Context Protocol) server functionality for CLASP. This allows CLASP to be used as an MCP server for tool integration with LLM applications.

Package mcpserver provides MCP tool definitions and execution for CLASP.

Index

Constants

View Source
const (
	ParseError     = -32700
	InvalidRequest = -32600
	MethodNotFound = -32601
	InvalidParams  = -32602
	InternalError  = -32603
)

MCP error codes

View Source
const Version = "0.48.9"

Version is the MCP server version

Variables

This section is empty.

Functions

This section is empty.

Types

type CallToolParams

type CallToolParams struct {
	Name      string          `json:"name"`
	Arguments json.RawMessage `json:"arguments,omitempty"`
}

CallToolParams represents parameters for tools/call

type CallToolResult

type CallToolResult struct {
	Content []Content `json:"content"`
	IsError bool      `json:"isError,omitempty"`
}

CallToolResult represents the result of a tool call

type ClientCapabilities

type ClientCapabilities struct {
	Roots    *RootsCapability    `json:"roots,omitempty"`
	Sampling *SamplingCapability `json:"sampling,omitempty"`
}

ClientCapabilities represents client capabilities

type Content

type Content struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

Content represents content in a tool result

type Implementation

type Implementation struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Implementation represents server implementation details

type InitializeParams

type InitializeParams struct {
	ProtocolVersion string             `json:"protocolVersion"`
	ClientInfo      Implementation     `json:"clientInfo"`
	Capabilities    ClientCapabilities `json:"capabilities"`
}

InitializeParams represents initialization parameters from client

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string             `json:"protocolVersion"`
	ServerInfo      Implementation     `json:"serverInfo"`
	Capabilities    ServerCapabilities `json:"capabilities"`
	Instructions    string             `json:"instructions,omitempty"`
}

InitializeResult represents the initialization response

type JSONRPCError

type JSONRPCError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

JSONRPCError represents a JSON-RPC 2.0 error

type JSONRPCRequest

type JSONRPCRequest struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      interface{}     `json:"id,omitempty"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

JSONRPCRequest represents a JSON-RPC 2.0 request

type JSONRPCResponse

type JSONRPCResponse struct {
	JSONRPC string        `json:"jsonrpc"`
	ID      interface{}   `json:"id,omitempty"`
	Result  interface{}   `json:"result,omitempty"`
	Error   *JSONRPCError `json:"error,omitempty"`
}

JSONRPCResponse represents a JSON-RPC 2.0 response

type ListToolsResult

type ListToolsResult struct {
	Tools []Tool `json:"tools"`
}

ListToolsResult represents the response to tools/list

type PromptCapability

type PromptCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

PromptCapability represents prompt-related capabilities

type ResourceCapability

type ResourceCapability struct {
	Subscribe   bool `json:"subscribe,omitempty"`
	ListChanged bool `json:"listChanged,omitempty"`
}

ResourceCapability represents resource-related capabilities

type RootsCapability

type RootsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

RootsCapability represents roots-related capabilities

type SamplingCapability

type SamplingCapability struct{}

SamplingCapability represents sampling-related capabilities

type Server

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

Server represents the MCP server

func NewServer

func NewServer(name string, cfg *config.Config) *Server

NewServer creates a new MCP server instance

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the MCP server on stdio

func (*Server) RunHTTP

func (s *Server) RunHTTP(ctx context.Context, addr string) error

RunHTTP starts the MCP server on HTTP

func (*Server) SetProxy

func (s *Server) SetProxy(p *proxy.Server)

SetProxy sets the proxy server for API forwarding

type ServerCapabilities

type ServerCapabilities struct {
	Tools     *ToolCapability     `json:"tools,omitempty"`
	Resources *ResourceCapability `json:"resources,omitempty"`
	Prompts   *PromptCapability   `json:"prompts,omitempty"`
}

ServerCapabilities represents the capabilities this server provides

type Session

type Session struct {
	ID        string
	StartedAt time.Time
	Writer    io.Writer
	Reader    io.Reader
}

Session represents an MCP client session

type Tool

type Tool struct {
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	InputSchema interface{} `json:"inputSchema"`
}

Tool represents an MCP tool definition

type ToolCapability

type ToolCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

ToolCapability represents tool-related capabilities

Jump to

Keyboard shortcuts

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