Documentation
¶
Overview ¶
Package scriptmcp provides an in-process MCP server exposing a sandboxed JavaScript execution tool for deterministic data transformation/formatting. It follows the same pattern as internal/webmcp and internal/configmcp: no subprocess is spawned; the server runs in-process via mcp.NewInMemoryTransports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSemaphore ¶
func NewSemaphore(n int) chan struct{}
NewSemaphore returns a concurrency semaphore bounding simultaneous VM executions to n. A non-positive n returns nil, meaning unbounded. Construct one per process and share it across every agent's Deps so the cap is global.
Types ¶
type Deps ¶
type Deps struct {
// Enabled gates tool registration. When false, no tool is registered.
Enabled bool
// Timeout is the wall-clock limit for a single snippet. Default applied by caller.
Timeout time.Duration
// MaxOutputChars caps the returned result length.
MaxOutputChars int
// MaxInputBytes caps the accepted input payload size.
MaxInputBytes int
// Sem bounds simultaneous VM executions. It is shared across all per-agent
// Script servers so the cap is process-global, protecting the shared goja
// heap. A nil semaphore means unbounded concurrency. Use NewSemaphore.
Sem chan struct{}
// AgentSem additionally bounds simultaneous VM executions for this one agent,
// so a single agent can't monopolize the global pool. Not shared between
// agents. A nil semaphore means no per-agent limit. Use NewSemaphore.
AgentSem chan struct{}
// PermissionTier returns the current effective tier for the agent.
PermissionTier func() string
Logger *slog.Logger
}
Deps holds the runtime dependencies injected into the Script MCP server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the in-process Script MCP server for a single agent.