Documentation
¶
Overview ¶
Package mcp implements a Model Context Protocol server that exposes DevClaw tools, resources, and prompts to MCP-compatible clients (Cursor, VSCode, etc.) via stdio and SSE transports.
Package mcp – sse.go implements the SSE (Server-Sent Events) transport for the MCP server, allowing HTTP-based clients to connect.
Index ¶
Constants ¶
const ( ProtocolVersion = "2024-11-05" ServerName = "devclaw" ServerVersion = "1.0.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentBlock ¶
ContentBlock is a single content item in a tool result.
type HandlerFunc ¶
HandlerFunc handles an MCP JSON-RPC request.
type Prompt ¶
type Prompt struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Arguments []PromptArg `json:"arguments,omitempty"`
}
Prompt describes an MCP prompt template.
type PromptArg ¶
type PromptArg struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
}
PromptArg describes an argument to a prompt template.
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
Resource describes an MCP resource.
type SSETransport ¶
type SSETransport struct {
// contains filtered or unexported fields
}
SSETransport serves MCP over HTTP with SSE for responses.
func NewSSETransport ¶
func NewSSETransport(server *Server, logger *slog.Logger) *SSETransport
NewSSETransport creates a new SSE transport wrapping the MCP server.
func (*SSETransport) Handler ¶
func (t *SSETransport) Handler() http.Handler
Handler returns an http.Handler that serves the MCP SSE endpoints. GET /sse — establishes SSE connection POST /message?sessionId=X — sends JSON-RPC messages
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the MCP JSON-RPC 2.0 protocol.
func (*Server) RegisterHandler ¶
func (s *Server) RegisterHandler(method string, handler HandlerFunc)
RegisterHandler adds a custom method handler.
func (*Server) RegisterTool ¶
func (s *Server) RegisterTool(def ToolDef, handler HandlerFunc)
RegisterTool adds a tool to the server.
type ToolCallResult ¶
type ToolCallResult struct {
Content []ContentBlock `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolCallResult is the result of executing an MCP tool.