(sigil mcp server)
MCP server implementation.
Provides the main server loop, message routing, and MCP protocol handling for the Sigil MCP server.
Exports
mcp-serverprocedureConstruct a mcp-server struct.
mcp-server?procedureTest if a value is a mcp-server struct.
mcp-server-nameprocedureGet the name field of a mcp-server struct.
mcp-server-versionprocedureGet the version field of a mcp-server struct.
mcp-server-toolsprocedureGet the tools field of a mcp-server struct.
mcp-server-resourcesprocedureGet the resources field of a mcp-server struct.
mcp-server-promptsprocedureGet the prompts field of a mcp-server struct.
mcp-server-capabilitiesprocedureGet the capabilities field of a mcp-server struct.
mcp-server-instructionsprocedureGet the instructions field of a mcp-server struct.
mcp-server-initializedprocedureGet the initialized field of a mcp-server struct.
mcp-server-legacy-onlyprocedureGet the legacy-only field of a mcp-server struct.
set-mcp-server-tools!procedureSet the tools field of a mcp-server struct.
set-mcp-server-resources!procedureSet the resources field of a mcp-server struct.
set-mcp-server-prompts!procedureSet the prompts field of a mcp-server struct.
set-mcp-server-initialized!procedureSet the initialized field of a mcp-server struct.
%tool-def--typevariableSet the initialized field of a mcp-server struct.
tool-defprocedureConstruct a tool-def struct.
tool-def?procedureTest if a value is a tool-def struct.
tool-def-nameprocedureGet the name field of a tool-def struct.
tool-def-descriptionprocedureGet the description field of a tool-def struct.
tool-def-input-schemaprocedureGet the input-schema field of a tool-def struct.
tool-def-handlerprocedureGet the handler field of a tool-def struct.
%resource-def--typevariableGet the handler field of a tool-def struct.
resource-defprocedureConstruct a resource-def struct.
resource-def?procedureTest if a value is a resource-def struct.
resource-def-uriprocedureGet the uri field of a resource-def struct.
resource-def-nameprocedureGet the name field of a resource-def struct.
resource-def-descriptionprocedureGet the description field of a resource-def struct.
resource-def-mime-typeprocedureGet the mime-type field of a resource-def struct.
resource-def-handlerprocedureGet the handler field of a resource-def struct.
%prompt-def--typevariableGet the handler field of a resource-def struct.
prompt-defprocedureConstruct a prompt-def struct.
prompt-def?procedureTest if a value is a prompt-def struct.
prompt-def-nameprocedureGet the name field of a prompt-def struct.
prompt-def-descriptionprocedureGet the description field of a prompt-def struct.
prompt-def-argumentsprocedureGet the arguments field of a prompt-def struct.
prompt-def-handlerprocedureGet the handler field of a prompt-def struct.
mcp-server-register-tool!procedureRegister a tool with the server.
mcp-server-register-resource!procedureRegister a resource with the server.
mcp-server-register-prompt!procedureRegister a prompt with the server.
mcp-server-notify!procedureSend a notification from the server to the client.
Used for server-initiated messages such as channel events. The notification is written as a JSON-RPC message to the current output port.
Examples:
(mcp-server-notify! server "notifications/claude/channel"
params: '((content . "new message")
(meta . ((sender . "david")))))mcp-server-infoprocedureThe server's identity, as initialize and _meta.serverInfo both want it.
A function rather than two exported field accessors: transports need the pair together, and this keeps the struct's shape private so a field can be renamed without breaking an importer.
mcp-cacheable-method?procedureDoes a modern-era result for method have to carry cache metadata?
mcp-request-modern-versionprocedureThe modern protocol revision a request names in its _meta, or #f when the request is legacy (no _meta version, or a revision that is only reachable through initialize).
A modern client sends its version on EVERY request instead of negotiating it once, so this is how a transport tells which shape of result the client will validate against.
mcp-augment-modern-resultprocedureStamp a successful result with the envelope every modern result owes: resultType, _meta.serverInfo, and ttlMs/cacheScope for the methods that require them. Error responses pass through untouched -- the spec puts none of this on an error.
A modern client REJECTS a listing without the cache fields rather than defaulting them: Claude Code 2.1.282 validates tools/list against a schema where both are required, retries a few times, and then registers no tools at all.
Idempotent: a result that already carries resultType is returned unchanged, so a transport may stamp a response that mcp-server-handle-message has already stamped without emitting duplicate JSON keys.
handle-server-discoverprocedureAnswer server/discover: the versions, capabilities and identity a client reads before sending anything else. Required of every server from revision 2026-07-28, and harmless on stdio, so it is answered here rather than in a single transport.
mcp-server-handle-messageprocedureHandle a parsed JSON-RPC message and return a response (or #f for notifications).
A request whose _meta names protocol revision 2026-07-28 gets a result in that revision's shape (see mcp-augment-modern-result), so a custom read loop can write the response as-is.
mcp-server-runvariable(No description)