Documentation
¶
Overview ¶
Package mcp serves the tools ritsu generates for agents (requests/mcp/tools.json) as an MCP server. A person's agent calls a tool; the call becomes one operation of the framework's Server.Do, done as that person, so the gate, the revision and the refusals hold as they do for the screens and the API.
https://i2y.github.io/ringi-server/agents/ says how to use it, and DESIGN.md how it works.
The package has the name of the SDK's package; a file that uses both names the SDK's sdkmcp.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Language answers the language of the sentences, of the refusals' leads and of the refusals'
// own texts (a refusal's text_ja for "ja", when the kind gives one): "en" or "ja". h is the HTTP
// request's header, nil when the session is one person's. Left out, it is chosen as the pages
// choose theirs (server.LanguageChoice): the most wanted of en and ja in Accept-Language, read as
// the pages read it (server.AcceptLanguages: by q, a tag of q=0 not wanted), else the language
// the organization's data gives the person (Server.PersonLanguage) unless the header does not
// want it, else en.
Language func(p server.Person, h http.Header) string
// Name and Version name the implementation in the MCP handshake (default "ringi-server",
// "0.0.0").
Name, Version string
// Logger logs what fails (default slog.Default()).
Logger *slog.Logger
// ChooseEvery is how often the tools of a session Connect started are chosen again, besides when
// the server serves other packages: a version that takes effect on a day, or that an
// administrator switched, changes them then (default a minute).
ChooseEvery time.Duration
}
Config is what the tools are made of, besides the server: the tools read the packages, the clock and the largest body from the server.
type HTTP ¶
type HTTP struct {
// Verify answers the person a bearer token stands for.
Verify Verifier
// ResourceMetadataURL is the URL of the protected resource's metadata (RFC 9728), told in the
// WWW-Authenticate header of a 401. With Verify only.
ResourceMetadataURL string
// Scopes are the scopes a token must have; a token without them is answered 403. With Verify only.
Scopes []string
// Person answers the person who sends a request, as the server's sign-in finds them: serve.Person
// for the route of package serve the handler is served on (Stores.Handle, which has found them
// already), or the server's Authenticate (Server.Authenticate) for a handler served otherwise.
// For a request with no person, it answers an error that wraps server.ErrNoPerson: the handler
// answers 401. Any other error is answered 500, and logged. The handler takes a request whatever
// its Host, as the pages and the API do: a sign-in that checks no one takes only a request to a
// loopback address (as the framework's do), so that another site's page cannot act through it.
Person func(*http.Request) (server.Person, error)
}
HTTP is how the streamable HTTP handler finds the person an agent acts for: by a bearer token (Verify), or by what the server's sign-in found in the request (Person). It takes one of the two.
type Token ¶
type Token struct {
// Person is the person the agent acts for, with the roles the gate reads.
Person server.Person
// Expires is when the token stops being taken; zero when the verifier does not say.
Expires time.Time
// Scopes are the token's scopes.
Scopes []string
}
Token is what a bearer token stands for.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
Tools serves the agents' tools of a server's packages.
func (*Tools) Connect ¶
func (t *Tools) Connect(ctx context.Context, tr sdkmcp.Transport, p server.Person) (*sdkmcp.ServerSession, error)
Connect starts a session of one person on a transport of the SDK: every call of the session is done as p. The tools are the ones of now, and they follow the versions in effect as the session goes on: once the server serves other packages (a bundle approved), and every Config.ChooseEvery, the tools are chosen again, and when they change, the session is told (notifications/tools/list_changed).
func (*Tools) Handler ¶
Handler answers MCP over streamable HTTP, statelessly, in JSON: each POST stands alone. A request with no person is answered 401: with Verify, one with no bearer token, or one Verify does not take; with Person, one Person finds no one in ({"error":"no one is signed in"}, as the framework's API answers it).