mcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientCaps

type ClientCaps struct{}

ClientCaps describes the client's capabilities (minimal for now).

type ClientInfo

type ClientInfo struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

ClientInfo identifies the client.

type ContentBlock

type ContentBlock struct {
	Type string `json:"type"` // "text"
	Text string `json:"text"`
}

ContentBlock is a single content item in a tool result.

type InitializeParams

type InitializeParams struct {
	ProtocolVersion string      `json:"protocolVersion"`
	Capabilities    ClientCaps  `json:"capabilities"`
	ClientInfo      *ClientInfo `json:"clientInfo,omitempty"`
}

InitializeParams contains the parameters for the initialize request.

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string     `json:"protocolVersion"`
	Capabilities    ServerCaps `json:"capabilities"`
	ServerInfo      ServerInfo `json:"serverInfo"`
}

InitializeResult is the response to the initialize request.

type PromptArgument

type PromptArgument struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
}

PromptArgument describes a single argument for a prompt template.

type PromptDefinition

type PromptDefinition struct {
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Arguments   []PromptArgument `json:"arguments,omitempty"`
}

PromptDefinition describes a prompt template available on the server.

type PromptGetParams

type PromptGetParams struct {
	Name      string            `json:"name"`
	Arguments map[string]string `json:"arguments,omitempty"`
}

PromptGetParams contains the parameters for prompts/get.

type PromptGetResult

type PromptGetResult struct {
	Description string          `json:"description,omitempty"`
	Messages    []PromptMessage `json:"messages"`
}

PromptGetResult is the result of prompts/get.

type PromptMessage

type PromptMessage struct {
	Role    string       `json:"role"`
	Content ContentBlock `json:"content"`
}

PromptMessage is a single message in a prompt result.

type PromptsCap

type PromptsCap struct{}

PromptsCap indicates the server supports prompts.

type PromptsListResult

type PromptsListResult struct {
	Prompts []PromptDefinition `json:"prompts"`
}

PromptsListResult is the result of prompts/list.

type RPCError

type RPCError = jsonrpc.Error

JSON-RPC 2.0 types — aliases to the shared jsonrpc package.

type Request

type Request = jsonrpc.Request

JSON-RPC 2.0 types — aliases to the shared jsonrpc package.

type ResourceContent

type ResourceContent struct {
	URI      string `json:"uri"`
	MimeType string `json:"mimeType,omitempty"`
	Text     string `json:"text,omitempty"`
}

ResourceContent is the content of a single resource.

type ResourceDefinition

type ResourceDefinition struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	MimeType    string `json:"mimeType,omitempty"`
}

ResourceDefinition describes a resource available on the server.

type ResourceReadParams

type ResourceReadParams struct {
	URI string `json:"uri"`
}

ResourceReadParams contains the parameters for resources/read.

type ResourceReadResult

type ResourceReadResult struct {
	Contents []ResourceContent `json:"contents"`
}

ResourceReadResult is the result of resources/read.

type ResourcesCap

type ResourcesCap struct{}

ResourcesCap indicates the server supports resources.

type ResourcesListResult

type ResourcesListResult struct {
	Resources []ResourceDefinition `json:"resources"`
}

ResourcesListResult is the result of resources/list.

type Response

type Response = jsonrpc.Response

JSON-RPC 2.0 types — aliases to the shared jsonrpc package.

type Server

type Server struct {

	// Verbose gates informational log output.
	Verbose bool
	// contains filtered or unexported fields
}

Server implements an MCP server over stdio using JSON-RPC 2.0.

func NewServer

func NewServer(reader *bufio.Reader, writer io.Writer) *Server

NewServer creates a new MCP server reading from reader and writing to writer.

func (*Server) Run

func (s *Server) Run()

Run reads and dispatches MCP messages until EOF or exit.

func (*Server) SetLogger

func (s *Server) SetLogger(l logger.Logger)

SetLogger overrides the default Logger. Intended for tests to inject logger.NewCapture so emitted records are observable.

type ServerCaps

type ServerCaps struct {
	Tools     *ToolsCap     `json:"tools,omitempty"`
	Resources *ResourcesCap `json:"resources,omitempty"`
	Prompts   *PromptsCap   `json:"prompts,omitempty"`
}

ServerCaps describes the server's capabilities.

type ServerInfo

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

ServerInfo contains information about the server.

type ToolCallParams

type ToolCallParams struct {
	Name      string          `json:"name"`
	Arguments json.RawMessage `json:"arguments"`
}

ToolCallParams contains the parameters for tools/call.

type ToolDefinition

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

ToolDefinition describes a tool available on the server.

type ToolResult

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

ToolResult is the result of a tool call.

type ToolsCap

type ToolsCap struct{}

ToolsCap indicates the server supports tools.

type ToolsListResult

type ToolsListResult struct {
	Tools []ToolDefinition `json:"tools"`
}

ToolsListResult is the result of tools/list.

Jump to

Keyboard shortcuts

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