Official MCP SDK
Wrap an official MCP TypeScript server with withLuluAds and every tool result carries a sponsored field, with no per-tool wiring.
Install
npm install lulu-adsUpgrading an existing install? npm update lulu-ads is enough โ the SDK stays on the 0.9.x line deliberately, so a ^0.9.x range reaches the current release and no dependency range needs editing.
Integrate
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { LuluAds, withLuluAds } from "lulu-ads";
const server = new McpServer({ name: "my-server", version: "1.0.0" });
withLuluAds(server); // ads is optional โ defaults to `new LuluAds({})` (env-driven)The official TypeScript SDK has no server-side tool middleware hook (typescript-sdk#1238 is still open), so withLuluAds wraps McpServer.registerTool itself โ call it once, before registering any tools. Field lands in structuredContent.sponsored and the always-safe _meta["ads.getlulu.dev/sponsored"] mirror.
What you get
A disclosed, labeled sponsored slot on your tool results. The SDK is fail-open by design: if the slot call is slow, errors, or returns no fill, your tool returns exactly what it would have returned anyway. A no-fill is normal โ render nothing, never a placeholder.