mcp

package
v0.46.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const Instructions = `` /* 691-byte string literal not displayed */

newKnotMCPServer builds one knot MCP server instance: name, version, instructions and the MCP Apps (SEP-1865) capability declaration, which script tools can carry a _meta.ui link (see ScriptToolsProvider). Doesn't gate whether _meta.ui is attached to a tool descriptor — that happens unconditionally, per this library's own guidance for an HTTP, multi-tenant server — purely so the server's declared capabilities accurately reflect what it offers. Instructions tells the model what knot is and how to find its on-demand tools. The library follows it with its own tool_search/execute_tool hint when the server has discoverable tools.

Variables

This section is empty.

Functions

func BuildSkillsPrompt added in v0.23.6

func BuildSkillsPrompt(ctx context.Context, user *model.User, retrieval string) string

BuildSkillsPrompt returns a skills section to append to the system prompt: this knot instance's own skills (from the database, so zone restrictions and group-based access control apply) plus the skills of every reachable remote MCP server, one line each as "name: description (uri)". retrieval names how the calling surface reads a skill back and is appended to the header when non-empty, e.g. "Call the lmchatkit__get_skill tool with the skill URI". Returns an empty string when no skills are available.

func CreateAuthProvider added in v0.23.0

func CreateAuthProvider(remoteServer config.MCPRemoteServerConfig) mcp.AuthProvider

CreateAuthProvider creates an MCP authentication provider from configuration

func FlushAccessibleSkillsCache added in v0.36.0

func FlushAccessibleSkillsCache()

FlushAccessibleSkillsCache drops every cached listing (tests; admin actions wanting immediate effect can call it too).

func FlushRemoteResourcesCache added in v0.36.0

func FlushRemoteResourcesCache()

FlushRemoteResourcesCache drops every cached remote listing (tests; wanting immediate effect after changing a user's remote servers).

func FromToml added in v0.23.0

func FromToml(tomlStr string) ([]mcppkg.Parameter, error)

FromToml parses a TOML schema definition and returns MCP parameters

func GetAccessibleSkills added in v0.29.0

func GetAccessibleSkills(user *model.User) []*model.Skill

GetAccessibleSkills returns the active, zone-valid, ACL-filtered skills for the user (global + own), with user skills overriding globals of the same name. Returns nil if the user is nil or the database is unreachable. Results are cached per user for a minute.

func GetRemoteServerProtocolVersion added in v0.36.0

func GetRemoteServerProtocolVersion(server *model.MCPServer) (string, error)

GetRemoteServerProtocolVersion connects to the remote MCP server (if not already connected) and returns the MCP protocol version it actually negotiated — e.g. "2025-06-18" for a legacy server, or the modern era's fixed revision. Used by the API endpoint for the server management UI.

func InitializeMCPServer

func InitializeMCPServer(routes *http.ServeMux, enableWebEndpoint bool, mcpConfig *config.MCPConfig) *mcp.Server

InitializeMCPServer builds knot's two MCP server instances and registers the public /mcp HTTP endpoint.

The endpoint server serves ONLY knot's own tools: script and method tool providers, attached per request. Remote MCP servers — operator-configured (server.mcp.remote_servers) and user-configured alike — are deliberately NOT federated through the public endpoint: an external MCP client that wants another server's tools connects to that server directly, and knot's name and tool list describe knot alone. The returned server is the internal one used by knot's own AI surfaces (web chat, OpenAI-compatible endpoints, scriptling's knot.mcp), which keep remote servers registered — those consumers have no way to attach to servers themselves.

func ListRemoteServerTools added in v0.29.0

func ListRemoteServerTools(server *model.MCPServer) ([]mcp.MCPTool, error)

ListRemoteServerTools connects to the remote MCP server and returns its tool list. Used by the API endpoint for the tools management UI.

func NewMethodToolsProvider added in v0.28.0

func NewMethodToolsProvider(user *model.User) *methodToolsProvider

func NewRemoteServerProvider added in v0.29.0

func NewRemoteServerProvider(user *model.User) *remoteServerProvider

func NewScriptToolsProvider added in v0.23.0

func NewScriptToolsProvider(user *model.User) *scriptToolsProvider

NewScriptToolsProvider creates a new script tools provider for a user Returns all tools (native and discoverable) with their visibility set

func NewSkillsProvider added in v0.36.0

func NewSkillsProvider(user *model.User) *skillsProvider

NewSkillsProvider returns the per-user skills provider. Attach it to the request context with mcp.WithSkillProviders AND mcp.WithResourceProviders (it implements both: the extension listing, and the resources the entries point at).

func NotifyPromptsChanged added in v0.29.0

func NotifyPromptsChanged()

NotifyPromptsChanged emits a notifications/prompts/list_changed.

func NotifyResourcesChanged added in v0.29.0

func NotifyResourcesChanged()

NotifyResourcesChanged emits a notifications/resources/list_changed.

func NotifyToolsChanged added in v0.29.0

func NotifyToolsChanged()

NotifyToolsChanged emits a notifications/tools/list_changed to every connected MCP client of every recorded server, signalling that its cached tool list is stale. It is a no-op (and cheap) when no server is set or no clients are connected. Call this when the data behind a tool provider changes (e.g. a user's scripts are created, updated, or deleted).

func SetServer added in v0.29.0

func SetServer(servers ...*mcp.Server)

SetServer records the MCP servers the notification helpers reach, replacing any recorded before. nil entries are ignored.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL