MCP
Serve fake MCP tools, resources and prompts from a mock.
Every mock is also an MCP server, over Streamable HTTP:
https://api.loremllm.com/m/<mock>/mcpAdd it to any MCP client:
{
"mcpServers": {
"support": { "url": "https://api.loremllm.com/m/support-bot/mcp" }
}
}Defining the server
Field names follow the MCP spec, so a definition reads like a tools/list or resources/list result.
import { defineMock, json, text, toolError } from "loremllm";
defineMock("support-bot", {
mcp: {
tools: {
lookupOrder: {
description: "Find an order by id",
inputSchema: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
scenarios: [
{ when: { input: { id: "A-1042" } }, reply: json({ status: "delivered", total: 48 }) },
{ reply: toolError("Order not found") },
],
},
},
resources: [
{
uri: "docs://refund-policy",
name: "refund-policy",
title: "Refund policy",
mimeType: "text/markdown",
text: "Refunds within 30 days.",
},
],
prompts: [
{
name: "triage",
description: "Triage a ticket",
arguments: [{ name: "ticket", required: true }],
messages: ({ ticket }) => [
{ role: "user", content: { type: "text", text: `Triage: ${ticket}` } },
],
},
],
},
});Tool scenarios work like mock scenarios, but when.input matches the call's arguments (partial deep equality, RegExps allowed in leaves). inputSchema also accepts a Zod schema in config files.
Tool results
| Builder | tools/call result |
|---|---|
text("...") | content: [{ type: "text", text }] |
json(value) | structuredContent: value, plus the same JSON as a text block |
image(data, mime) | content: [{ type: "image", data, mimeType }] |
resourceLink(uri) | content: [{ type: "resource_link", uri, name }] |
toolError("...") | isError: true with the message as a text block |
error(-32602) | A JSON-RPC error instead of a result, for protocol-level failures |
toolError is the one to reach for: per the spec, tool failures are results the model can read, not protocol errors.
What it supports
initialize, withtools,resourcesandpromptscapabilitiestools/listandtools/call, includingoutputSchemaandstructuredContentresources/list,resources/read,resources/templates/listandresources/subscribeprompts/listandprompts/getnotifications/progresswhen the client sends aprogressToken, timed bydelay(ms)notifications/tools/list_changedwhen you push a new version- Streamable HTTP: one endpoint for
POSTandGET, sessions via theMcp-Session-Idheader
Testing an MCP client
Point your agent's MCP client at the mock, and its model at the same mock's OpenAI or Anthropic endpoint. You control both the tool list your agent sees and what each tool returns.
For a local or stdio server, use @loremllm/mcp.