Documentation
¶
Overview ¶
Package test has a mock MCP server, for tests of the MCP clients, and connectors
Index ¶
Constants ¶
const ( Name = "test-server" Version = "1.0" // ResourceName is the server's name, in the metadata of how it's // authorized, when it needs to be ResourceName = "Test Resource" )
The name, and version, which the mock server says it is, as it's connected to
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶
type Opt func(*opt)
Opt is an option of a mock server
func WithAuth ¶
func WithAuth() Opt
WithAuth makes the server need to be authorized, with a bearer token, which its own authorization server issues: its metadata, and the resource's, are at their well-known paths, a client is registered, and a code, which Approve gives, as a person would, is exchanged for a token, with PKCE's S256, which is refreshed
func WithPingResult ¶
WithPingResult replies to a ping, with the streamable HTTP transport, with the result, such as [], which some servers reply with, rather than {}
func WithSSE ¶
func WithSSE() Opt
WithSSE serves only the SSE transport, of the 2024-11-05 protocol, rather than the streamable HTTP transport
func WithTokenLifetime ¶ added in v1.7.0
///////////////////////////////////////////////////////////////////////////// WithTokenLifetime makes the tokens the server issues, when it needs to be authorized, last the seconds, such as 5, which is so short that a client refreshes them before they're used
type Server ¶
type Server struct {
*httptest.Server
// The MCP server, which tools, prompts and resources can be added to
MCP *sdkmcp.Server
// contains filtered or unexported fields
}
Server is a mock MCP server, over HTTP, which records the headers of the requests it's sent
func NewServer ¶
NewServer starts a mock MCP server, with the streamable HTTP transport, or only SSE, with WithSSE, which is closed when the test ends
func (*Server) Approve ¶
Approve approves the authorization URL, as a person would, and returns the URL it redirects to, with a code, and its state, or an error, when it isn't a valid request, such as one without S256
func (*Server) Client ¶
Client adds a client, with its secret, and redirect URIs, as one which is registered beforehand, rather than dynamically, would be
func (*Server) Headers ¶
Headers returns the headers of the requests the server has been sent, in the order they were sent