Documentation
¶
Overview ¶
Package mcp exposes the devsys application service over the Model Context Protocol using the official Go SDK (github.com/modelcontextprotocol/go-sdk).
The SDK owns the protocol: framing, lifecycle, version negotiation, tools/list and tools/call shapes, and input validation against the schema inferred from each handler's typed input. This package owns what is ours: which tools a profile exposes, and the error taxonomy shared with the CLI (internal/app) so both surfaces refuse the same way.
Index ¶
- Constants
- func DefaultProfiles() []string
- func DefaultTier() string
- func NewServer(cfg Config) *mcpsdk.Server
- func ParseProfiles(list string) ([]string, error)
- func ParseTier(tier string) (string, error)
- func Run(ctx context.Context, cfg Config, in io.ReadCloser, out io.WriteCloser) error
- func VisibleTools(cfg Config) []string
- type Config
Constants ¶
const ( ProfileSession = "session" ProfileExecutor = "executor" ProfileReviewer = "reviewer" ProfileAdmin = "admin" )
Tool profiles (方案 §8.6). The server exposes the union of the selected profiles' tools; the default is session + executor, and reviewer/admin stay opt-in so dangerous entries are explicit.
const ( TierCore = "core" TierStandard = "standard" )
Tool tiers (#301): core is the daily subset, standard is everything the selected profiles expose. Tiers compose with profiles by conjunction.
const ServerName = "devsys"
ServerName is the fixed identity every devsys MCP surface reports.
Variables ¶
This section is empty.
Functions ¶
func DefaultProfiles ¶
func DefaultProfiles() []string
DefaultProfiles is the profile set an unconfigured server exposes.
func DefaultTier ¶
func DefaultTier() string
DefaultTier is the tier an unconfigured server exposes.
func NewServer ¶
NewServer builds the SDK server with exactly the tools the selected profiles expose. Registration is the profile filter: a tool that is not exposed is never registered, so it cannot be called by name either.
func ParseProfiles ¶
ParseProfiles parses a comma-separated profile list. Empty input selects the defaults; unknown names are rejected so a typo cannot silently widen or narrow the tool surface.
func ParseTier ¶
ParseTier parses the --tier flag. Unknown names are rejected so a typo cannot silently widen or narrow the tool surface.
func Run ¶
func Run(ctx context.Context, cfg Config, in io.ReadCloser, out io.WriteCloser) error
Run serves the protocol over the given streams until the client closes them. Nil streams mean the process standard streams (stdio transport).
func VisibleTools ¶
VisibleTools lists the tool names NewServer would register for cfg — the same profile∧tier conjunction — so the CLI can refuse to start a server whose filter leaves nothing to serve instead of spinning a silent no-op.
Types ¶
type Config ¶
type Config struct {
// Root is the absolute project root; tools read and write only beneath it.
Root string
// Profiles is the active profile set.
Profiles []string
// Tier caps the exposed tools: core shows the daily subset, standard
// shows everything the profiles expose. Empty means the default tier.
Tier string
// ServerVersion is the build identity reported to clients.
ServerVersion string
// Instructions is the discipline note clients receive at initialize.
Instructions string
// Log receives server diagnostics (stderr in the CLI).
Log io.Writer
}
Config is the project binding a tool set serves.