Documentation
¶
Index ¶
- func RegisterDefaultTools(server *MCPServer, executor ToolExecutor)
- func SetClientVersion(v string)
- type HTTPServer
- func (s *HTTPServer) Call(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
- func (s *HTTPServer) CallTool(ctx context.Context, name string, args map[string]interface{}) (string, error)
- func (s *HTTPServer) Close() error
- func (s *HTTPServer) ListTools(ctx context.Context) ([]Tool, error)
- type JSONRPCRequest
- type JSONRPCResponse
- type MCPServer
- type MCPToolHandler
- type RPCError
- type Resource
- type Server
- type ServerInfo
- type Tool
- type ToolExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDefaultTools ¶ added in v0.2.0
func RegisterDefaultTools(server *MCPServer, executor ToolExecutor)
RegisterDefaultTools registers hawk's standard capabilities as MCP tools. If executor is non-nil, tools that delegate to hawk's tool registry will use it for execution; otherwise those tools return a not-configured error.
func SetClientVersion ¶ added in v0.2.0
func SetClientVersion(v string)
SetClientVersion lets main.go propagate the canonical hawk version into this package without creating an import cycle with cmd.
Types ¶
type HTTPServer ¶
type HTTPServer struct {
Name string
URL string
Headers map[string]string
Type string // "http" or "sse"
// contains filtered or unexported fields
}
HTTPServer represents an MCP server connected via HTTP or SSE transport.
func ConnectHTTP ¶
func ConnectHTTP(ctx context.Context, name, url string, headers map[string]string) (*HTTPServer, error)
ConnectHTTP connects to an MCP server via HTTP streamable transport.
func ConnectSSE ¶
func ConnectSSE(ctx context.Context, name, url string, headers map[string]string) (*HTTPServer, error)
ConnectSSE connects to an MCP server via Server-Sent Events transport.
func (*HTTPServer) Call ¶
func (s *HTTPServer) Call(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
Call sends a JSON-RPC request and returns the result.
func (*HTTPServer) CallTool ¶
func (s *HTTPServer) CallTool(ctx context.Context, name string, args map[string]interface{}) (string, error)
CallTool invokes a tool on the HTTP/SSE MCP server.
func (*HTTPServer) Close ¶
func (s *HTTPServer) Close() error
Close is a no-op for HTTP/SSE servers (no persistent connection).
type JSONRPCRequest ¶ added in v0.2.0
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
JSON-RPC 2.0 request from a client.
type JSONRPCResponse ¶ added in v0.2.0
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Result interface{} `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
JSON-RPC 2.0 response to a client.
type MCPServer ¶ added in v0.2.0
type MCPServer struct {
// contains filtered or unexported fields
}
MCPServer exposes hawk's capabilities as an MCP server that external clients (IDEs, agents, CLI tools) can connect to via JSON-RPC 2.0 over stdio.
func NewMCPServer ¶ added in v0.2.0
func NewMCPServer(info ServerInfo) *MCPServer
NewMCPServer creates a new MCP server with the given identity.
func (*MCPServer) RegisterTool ¶ added in v0.2.0
func (s *MCPServer) RegisterTool(handler MCPToolHandler)
RegisterTool adds a tool to the server. If a tool with the same name already exists, it is replaced.
type MCPToolHandler ¶ added in v0.2.0
type MCPToolHandler struct {
Name string
Description string
InputSchema map[string]interface{}
Handler func(ctx context.Context, params json.RawMessage) (string, error)
}
MCPToolHandler defines a tool exposed by the MCP server.
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
MimeType string `json:"mimeType,omitempty"`
Description string `json:"description,omitempty"`
}
Resource is a resource exposed by an MCP server.
type Server ¶
type Server struct {
Name string
Command string
Args []string
// contains filtered or unexported fields
}
Server represents a connected MCP server.
func (*Server) ListResources ¶
ListResources returns resources available on this MCP server.
type ServerInfo ¶ added in v0.2.0
ServerInfo identifies the MCP server to connecting clients.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]interface{} `json:"inputSchema"`
}
Tool is a tool exposed by an MCP server.
type ToolExecutor ¶ added in v0.2.0
ToolExecutor is a function that executes a named tool with JSON input. This avoids importing the tool package (which already imports mcp).