Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(exec GraphQLExecutor, serverName string, version string, toolPrefix string, opts ...Option) (http.Handler, error)
New creates an http.Handler that serves an MCP Streamable HTTP server. It wraps a GraphQL executor and exposes registered tools as MCP tools. A condensed SDL must be supplied via WithCondensedSchema.
Types ¶
type ArgDefinition ¶
type ArgDefinition struct {
Name string
Type string // "string", "integer", "number", "boolean", "object", "array"
Description string
Required bool
ItemsType string // JSON Schema type for array elements
EnumValues []string // Allowed values for enum types
}
ArgDefinition describes a single argument for a tool.
type GraphQLExecutor ¶
type GraphQLExecutor interface {
Execute(ctx context.Context, query string, variables map[string]any) ([]byte, error)
}
GraphQLExecutor executes GraphQL operations and returns the JSON response.
func NewGQLGenExecutor ¶
func NewGQLGenExecutor(es graphql.ExecutableSchema) GraphQLExecutor
NewGQLGenExecutor returns a GraphQLExecutor backed by a gqlgen ExecutableSchema.
type Option ¶
type Option func(*config)
Option configures the MCP server.
func WithCondensedSchema ¶
WithCondensedSchema returns an Option that provides a condensed SDL schema for the get_schema tool to return instead of the full introspection JSON.
func WithLogger ¶
WithLogger returns an Option that sets an slog.Logger for MCP-level logging.
func WithMaxQuerySize ¶
WithMaxQuerySize returns an Option that sets the maximum allowed query size in bytes.
func WithStateless ¶
WithStateless returns an Option that controls whether the MCP server runs in stateless mode.
func WithTokenVerifier ¶
func WithTokenVerifier(v TokenVerifier) Option
WithTokenVerifier returns an Option that adds bearer token authentication middleware. Use this for simple deployments where the MCP server manages its own auth. For services that already have HTTP middleware (e.g., JWT validation chains), wrap the handler externally instead — this avoids duplicating auth logic and lets you reuse existing middleware stacks.
func WithTools ¶
func WithTools(tools []ToolDefinition) Option
WithTools returns an Option that registers additional tool definitions.
type TokenVerifier ¶
TokenVerifier validates a bearer token and returns an enriched context.
type ToolDefinition ¶
type ToolDefinition struct {
Name string
Description string
Args []ArgDefinition
Query string
Annotations *mcp.ToolAnnotations
}
ToolDefinition describes an MCP tool backed by a GraphQL query.