Documentation
¶
Overview ¶
Package mcpserver implements a JSON-RPC 2.0 MCP stdio server supporting both newline-delimited JSON (NDJSON) and Content-Length header framing.
Index ¶
- Constants
- type HTTPOptions
- type Server
- func (s *Server) HTTPHandler(opts HTTPOptions) http.Handler
- func (s *Server) ListenAndServeHTTP(ctx context.Context, opts HTTPOptions, onBound func(addr string)) error
- func (s *Server) Serve(ctx context.Context, in io.Reader, out io.Writer) error
- func (s *Server) ServeHTTP(ctx context.Context, opts HTTPOptions) error
- type ServerOptions
- type ToolSet
Constants ¶
const ( ServerName = "mcplex" ServerVersion = version.Version DefaultProtocolVersion = "2025-11-25" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPOptions ¶
type HTTPOptions struct {
Addr string // e.g. "127.0.0.1:8787"
Path string // defaults to "/mcp"
Token string // optional Bearer token required on /mcp
AllowOrigin string // optional CORS Access-Control-Allow-Origin value
}
HTTPOptions configures the MCP Streamable HTTP transport.
type Server ¶
type Server struct {
Engine *ptcruntime.Engine
// contains filtered or unexported fields
}
Server speaks MCP JSON-RPC 2.0 over stdio (NDJSON & Content-Length) and Streamable HTTP.
func NewServer ¶
func NewServer(engine *ptcruntime.Engine) *Server
NewServer wraps an Engine in an MCP server with default options.
func NewServerWithOptions ¶
func NewServerWithOptions(engine *ptcruntime.Engine, opts ServerOptions) *Server
NewServerWithOptions wraps an Engine in an MCP server with custom host profile options.
func (*Server) HTTPHandler ¶
func (s *Server) HTTPHandler(opts HTTPOptions) http.Handler
HTTPHandler returns an http.Handler implementing MCP Streamable HTTP over POST /mcp plus a lightweight GET /healthz probe.
func (*Server) ListenAndServeHTTP ¶ added in v0.3.0
func (s *Server) ListenAndServeHTTP(ctx context.Context, opts HTTPOptions, onBound func(addr string)) error
ListenAndServeHTTP binds the TCP listener first (failing fast on port conflicts), invokes onBound with the actual listening address, and serves HTTP until ctx is canceled.
type ServerOptions ¶
type ServerOptions struct {
ServerName string
ServerVersion string // defaults to version.Version
Tools ToolSet // optional standalone tools alongside `exec`
Instructions string // returned in initialize.result.instructions (MCP 2025-03-26+)
ExecDescription string // custom description for the exec tool
DefaultMaxOutBytes int // advertised default inline output cap (0 -> 9600)
SkillResourceURI string // optional MCP resource URI, e.g. "mcplex://skill"
SkillResourceName string
SkillResourceText string
}
ServerOptions customizes server identity, toolset, initialize instructions, exec description, and skill resources.
type ToolSet ¶ added in v0.3.0
type ToolSet struct {
Read bool // expose standalone `read` tool (text ranges, tail, byteOffset, multimodal images)
Tasks bool // expose `spawn` + `task` background process & daemon toolset
}
ToolSet controls which optional MCP tools are exposed alongside the core `exec` tool. Zero value exposes only `exec` (used by host plugins like agy-ptc that already have native read/task tools).