mcp

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	CtxKeyTokenType = "mcp.token.type"
	CtxKeyWorkerID  = "mcp.token.worker_id"
)
View Source
const CtxWorkerIDKey ctxKey = CtxKeyWorkerID

CtxWorkerIDKey carries the caller's worker ID through tool dispatch. It uses the same string value as CtxKeyWorkerID (set by auth middleware on gin.Context) so the two stay in sync without a hard import dependency between packages. Exported so tests can construct contexts that simulate worker calls.

Variables

This section is empty.

Functions

func JWTAuthMiddleware added in v0.0.16

func JWTAuthMiddleware(secret string) gin.HandlerFunc

JWTAuthMiddleware validates the MCP JWT and writes claims to gin.Context. Reads the token from X-API-Key header or api_key query param. Returns 401 on missing, invalid, or expired token.

func RequireBee added in v0.0.16

func RequireBee() gin.HandlerFunc

RequireBee aborts with 403 if the token type is not "bee".

func RequireBeeOrWorker added in v0.0.16

func RequireBeeOrWorker() gin.HandlerFunc

RequireBeeOrWorker accepts tokens of either type.

func RequireWorker added in v0.0.16

func RequireWorker() gin.HandlerFunc

RequireWorker aborts with 403 if the token type is not "worker".

func ToolSchemas

func ToolSchemas() []toolSchema

ToolSchemas returns the JSON Schema definitions for all Bee MCP tools. Exported so tests can verify the count and structure.

func WorkerToolSchemas added in v0.0.10

func WorkerToolSchemas() []toolSchema

WorkerToolSchemas returns the JSON Schema definitions for Worker MCP tools.

Types

type ExecutionStopper

type ExecutionStopper interface {
	StopExecution(executionID string) error
}

ExecutionStopper can kill a running worker process by execution ID.

type MCPServer

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

MCPServer manages SSE sessions and dispatches JSON-RPC tool calls.

func NewBeeServer added in v0.0.10

func NewBeeServer(
	ws *store.WorkerStore,
	mgr *worker.Manager,
	ts *store.TaskStore,
	ms *store.MessageStore,
	senders map[string]platform.PlatformSenderAdapter,
	execStopper ExecutionStopper,
	sessionClearer SessionClearer,
	es *store.ExecutionStore,
	memStore *store.MemoryStore,
	sessionStore *store.SessionStore,
) *MCPServer

NewBeeServer creates a Bee MCP Server with all tools.

func NewWorkerServer added in v0.0.10

func NewWorkerServer(
	ts *store.TaskStore,
	ms *store.MessageStore,
	senders map[string]platform.PlatformSenderAdapter,
	memStore *store.MemoryStore,
	ws *store.WorkerStore,
) *MCPServer

NewWorkerServer creates a Worker MCP Server with a restricted tool set.

func (*MCPServer) CallTool

func (s *MCPServer) CallTool(ctx context.Context, name string, args json.RawMessage) (any, error)

CallTool is exported for testing. Production code uses callToolFn via handleToolCall.

func (*MCPServer) HandleCall added in v0.0.16

func (s *MCPServer) HandleCall(c *gin.Context)

Tool errors are returned as 200 {"error": "..."} to match the RPC-over-HTTP convention.

func (*MCPServer) HandleMessages added in v0.0.8

func (s *MCPServer) HandleMessages(c *gin.Context)

handleMessages receives a JSON-RPC request and pushes the response to the SSE channel.

func (*MCPServer) HandleSSE added in v0.0.8

func (s *MCPServer) HandleSSE(c *gin.Context)

HandleSSE establishes the SSE connection, creates a session, and streams responses.

type SessionClearer

type SessionClearer interface {
	ClearSession(sessionKey string)
}

SessionClearer clears dispatcher queues and session contexts for a session.

Jump to

Keyboard shortcuts

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