mcpserver

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 18 Imported by: 0

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

View Source
const (
	ServerName             = "agy-ptc"
	ServerVersion          = version.Version
	DefaultProtocolVersion = "2025-03-26"
)

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 agy-ptc 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) Serve

func (s *Server) Serve(ctx context.Context, in io.Reader, out io.Writer) error

Serve reads JSON-RPC messages from in and writes responses to out until EOF or ctx cancellation.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(ctx context.Context, opts HTTPOptions) error

ServeHTTP runs the MCP Streamable HTTP server until ctx is canceled.

type ServerOptions

type ServerOptions struct {
	ServerName         string
	ServerVersion      string // defaults to version.Version
	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, initialize instructions, exec description, and skill resources.

Jump to

Keyboard shortcuts

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