Extensions
MCP
Extensions
mcp.md

MCP

The Model Context Protocol over Streamable HTTP, both ways: the program as an MCP server, so that Claude, an IDE's assistant or any other MCP client can call its typed fns as tools and read its rows as resources; and the program as an MCP client of other servers, whose tools the ai extension's tool loop offers a model beside the program's own. An extension: ordinary Mote in extensions/mcp/. Back to the map.

mote
use "pkg:mcp/server.mote"
model Note
title: string key
body: string
// The weather in a city now.
fn weatherIn(city: string): string = `18°C in ${city}`
// A note, read whole.
shape NoteOut
title: string
body: string
// The note of a title.
fn noteOf(title: string): NoteOut
let n = Note.get(title)?
if n == none fail(`There is no note ${title}.`)?
return {title, body: n?.body ?? ""}
// The tools: made from the fns, their schemas from their parameters' types, their
// descriptions from the comments above them.
fn mcpTools(who: string): McpTool[] = [
mcpToolFor("weather", schema(weatherIn)),
{...mcpToolFor("note", schema(noteOf)), outputSchema: schema(NoteOut)}
]
// A call of one: a `match` on its name into the program's own fns.
fn mcpCall(call: McpCall, tell: (done: number, total: number, words: string) => bool): McpResult
if call.name == "weather" return mcpText(weatherIn(`${call.input.city}`))
if call.name == "note" return mcpValue(noteOf(`${call.input.title}`)?)
return fail(`no tool ${call.name}`)?
fn mcpResources(who: string): McpResource[] = Note.find({})?.map(n => ({uri: `note://${n.title}`, name: n.title, mimeType: "text/plain"}))
fn mcpRead(uri: string, who: string): McpRead[]
let n = Note.get(uri.replace("note://", ""))?
if n == none fail("no such note")?
return [{uri, mimeType: "text/plain", text: n?.body ?? ""}]
toml
[packages]
mcp = "../mote/extensions/mcp"
sh
MCP_TOKEN=a-long-random-token bun dist/server/main.js
claude mcp add --transport http notes http://localhost:4870/mcp --header "Authorization: Bearer a-long-random-token"

No other implementation has met it yet. Both sides are written from the protocol's specification (version 2025-06-18, with 2025-03-26 and 2025-11-25 taken), and checked against each other and against a plain fetch client written from the same pages (tests/all.sh real_svc_mcp). The steps to check it with real clients and servers are below.

The server#

The client#

Another server's tools in the tool loop#

Signing in by OAuth, for later#

Checking it against other implementations#

esc
1072 sections of 111 pages, ranked as you type.A heading's words count for more than what stands under it.
↑↓move
↵open
ranked by BM25, in the page