Documentation
¶
Overview ¶
Package helpers builds the servers, tools and readers that this module's own tests drive.
Everything here is exported because the tests import it from another package, which is the cost of a test tree that only sees the public API. None of it is part of what this module publishes: it is scaffolding for the suite under tests/, it carries no compatibility promise, and the layout guard fails if a package that ships ever reaches it.
Index ¶
- Constants
- func Blog(tool mcp.Tool) *mcp.Server
- func Everything() *mcp.Server
- func IsNonEmptyString(raw json.RawMessage) bool
- func ObjectMembers(body []byte) (map[string]json.RawMessage, bool)
- func Post(body string) *httptest.ResponseRecorder
- func SameJSON(a, b []byte) bool
- type AnswerShape
- type Posts
- type Readme
- type Summarise
- type Undescribed
Constants ¶
const ( CodeParse = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInternal = -32603 )
The error codes the protocol declares, repeated here because the package keeps them unexported and a test that imported them would be asserting that a constant equals itself.
Variables ¶
This section is empty.
Functions ¶
func Blog ¶
Blog is a server carrying the one tool it is given, so a test can keep hold of the tool and assert about what it was called with.
func Everything ¶
Everything carries one of each kind, so a message can reach every branch.
func IsNonEmptyString ¶
func IsNonEmptyString(raw json.RawMessage) bool
IsNonEmptyString reports whether a raw member is a string with something in it, which is what the protocol requires of a method name.
func ObjectMembers ¶
func ObjectMembers(body []byte) (map[string]json.RawMessage, bool)
ObjectMembers reads a message as a JSON object, and reports whether it was one. It is how a test tells a member that is absent from one that is null, which is the difference between a notification and a request.
func Post ¶
func Post(body string) *httptest.ResponseRecorder
Post sends one message to the web transport, through the router that mounts it, and returns what came back.
Types ¶
type AnswerShape ¶
type AnswerShape struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id"`
Result json.RawMessage `json:"result"`
Error *struct {
Code int `json:"code"`
Message string `json:"message"`
} `json:"error"`
}
AnswerShape is the response the protocol carries, read back loosely: every member is raw, so a test can tell "absent" from "null".
type Posts ¶
type Posts struct {
// Asked records who the tool was told to act as, which is the thing worth
// asserting about -- everything else in this package is transport.
Asked security.Subject
// Refuse makes the service answer the way an authorization failure does.
Refuse bool
}
Posts is a tool shaped the way a real one is: it asks a service, and the service is handed the Subject the request carried.
func (*Posts) Description ¶
type Readme ¶
type Readme struct{}
Readme is a resource, so a message can reach the branches that list and read one.
func (Readme) Description ¶
type Summarise ¶
type Summarise struct{}
Summarise is a prompt, so a message can reach the branches that list and render one.
func (Summarise) Description ¶
type Undescribed ¶
type Undescribed struct{}
Undescribed is the mistake a server is required to refuse at boot: a tool with nothing for the model to read before deciding whether to call it.
func (Undescribed) Description ¶
func (Undescribed) Description() string
func (Undescribed) Name ¶
func (Undescribed) Name() string
Name, Description, Schema and Handle make it a tool, and the empty description is the whole point of it.
func (Undescribed) Schema ¶
func (Undescribed) Schema() mcp.Schema