v0connect

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MCPInitializeProcedure is the fully-qualified name of the MCP's Initialize RPC.
	MCPInitializeProcedure = "/codefly.mcp.v0.MCP/Initialize"
	// MCPListToolsProcedure is the fully-qualified name of the MCP's ListTools RPC.
	MCPListToolsProcedure = "/codefly.mcp.v0.MCP/ListTools"
	// MCPCallToolProcedure is the fully-qualified name of the MCP's CallTool RPC.
	MCPCallToolProcedure = "/codefly.mcp.v0.MCP/CallTool"
	// MCPListResourcesProcedure is the fully-qualified name of the MCP's ListResources RPC.
	MCPListResourcesProcedure = "/codefly.mcp.v0.MCP/ListResources"
	// MCPReadResourceProcedure is the fully-qualified name of the MCP's ReadResource RPC.
	MCPReadResourceProcedure = "/codefly.mcp.v0.MCP/ReadResource"
)

These constants are the fully-qualified names of the RPCs defined in this package. They're exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.

Note that these are different from the fully-qualified method names used by google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to reflection-formatted method names, remove the leading slash and convert the remaining slash to a period.

View Source
const (
	// MCPName is the fully-qualified name of the MCP service.
	MCPName = "codefly.mcp.v0.MCP"
)

Variables

This section is empty.

Functions

func NewMCPHandler

func NewMCPHandler(svc MCPHandler, opts ...connect.HandlerOption) (string, http.Handler)

NewMCPHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.

By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.

Types

type MCPClient

type MCPClient interface {
	// Initialize performs the MCP protocol handshake.
	Initialize(context.Context, *connect.Request[v0.InitializeRequest]) (*connect.Response[v0.InitializeResponse], error)
	// ListTools returns callable Codefly tools.
	ListTools(context.Context, *connect.Request[v0.ListToolsRequest]) (*connect.Response[v0.ListToolsResponse], error)
	// CallTool invokes a named Codefly tool.
	CallTool(context.Context, *connect.Request[v0.CallToolRequest]) (*connect.Response[v0.CallToolResponse], error)
	// ListResources returns read-only Codefly resources.
	ListResources(context.Context, *connect.Request[v0.ListResourcesRequest]) (*connect.Response[v0.ListResourcesResponse], error)
	// ReadResource returns content for one Codefly resource URI.
	ReadResource(context.Context, *connect.Request[v0.ReadResourceRequest]) (*connect.Response[v0.ReadResourceResponse], error)
}

MCPClient is a client for the codefly.mcp.v0.MCP service.

func NewMCPClient

func NewMCPClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MCPClient

NewMCPClient constructs a client for the codefly.mcp.v0.MCP service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.

The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).

type MCPHandler

type MCPHandler interface {
	// Initialize performs the MCP protocol handshake.
	Initialize(context.Context, *connect.Request[v0.InitializeRequest]) (*connect.Response[v0.InitializeResponse], error)
	// ListTools returns callable Codefly tools.
	ListTools(context.Context, *connect.Request[v0.ListToolsRequest]) (*connect.Response[v0.ListToolsResponse], error)
	// CallTool invokes a named Codefly tool.
	CallTool(context.Context, *connect.Request[v0.CallToolRequest]) (*connect.Response[v0.CallToolResponse], error)
	// ListResources returns read-only Codefly resources.
	ListResources(context.Context, *connect.Request[v0.ListResourcesRequest]) (*connect.Response[v0.ListResourcesResponse], error)
	// ReadResource returns content for one Codefly resource URI.
	ReadResource(context.Context, *connect.Request[v0.ReadResourceRequest]) (*connect.Response[v0.ReadResourceResponse], error)
}

MCPHandler is an implementation of the codefly.mcp.v0.MCP service.

type UnimplementedMCPHandler

type UnimplementedMCPHandler struct{}

UnimplementedMCPHandler returns CodeUnimplemented from all methods.

Jump to

Keyboard shortcuts

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