@embd/mcp 0.7.8 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{J as D}from"./bin-66kzqre3.js";import F from"node:process";class A{append(b){this._buffer=this._buffer?Buffer.concat([this._buffer,b]):b}readMessage(){if(!this._buffer)return null;let b=this._buffer.indexOf(`
1
+ import{J as D}from"./bin-abb2cdyk.js";import F from"node:process";class A{append(b){this._buffer=this._buffer?Buffer.concat([this._buffer,b]):b}readMessage(){if(!this._buffer)return null;let b=this._buffer.indexOf(`
2
2
  `);if(b===-1)return null;let q=this._buffer.toString("utf8",0,b).replace(/\r$/,"");return this._buffer=this._buffer.subarray(b+1),G(q)}clear(){this._buffer=void 0}}function G(b){return D.parse(JSON.parse(b))}function E(b){return JSON.stringify(b)+`
3
3
  `}class H{constructor(b=F.stdin,q=F.stdout){this._stdin=b,this._stdout=q,this._readBuffer=new A,this._started=!1,this._ondata=(w)=>{this._readBuffer.append(w),this.processReadBuffer()},this._onerror=(w)=>{this.onerror?.(w)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let b=this._readBuffer.readMessage();if(b===null)break;this.onmessage?.(b)}catch(b){this.onerror?.(b)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(b){return new Promise((q)=>{let w=E(b);if(this._stdout.write(w))q();else this._stdout.once("drain",q)})}}
4
4
  export{H as a};
@@ -1,4 +1,4 @@
1
- import{q as o,r,s as e,t as ZZ,y as $Z}from"./bin-bw6a4d6a.js";import{D as G,E as MZ,F as C,G as z,H as v,I as S,J as c,K as l,L as s}from"./bin-66kzqre3.js";var VZ=["line","area","bar","stacked-bar","stacked-area","bar-horizontal","scatter","pie","donut","heatmap","radar"],E=["stage","slate","dusk","paper","mist","sepia"];function H(Z,$){return{content:[{type:"text",text:Z}],structuredContent:{url:Z,kind:$}}}function k(Z){return{content:[{type:"text",text:Z instanceof Error?Z.message:String(Z)}],isError:!0}}async function LZ(Z,$={}){try{let Q=await o(Z.data,{origin:$.origin,kind:Z.kind,title:Z.title,themeId:Z.theme});return H(Q,"chart")}catch(Q){return k(Q)}}async function UZ(Z,$={}){try{let Q=await r(Z.content,{origin:$.origin,theme:Z.theme});return H(Q,"markdown")}catch(Q){return k(Q)}}async function fZ(Z,$={}){try{let Q=await e(Z,{origin:$.origin});return H(Q,"kpi")}catch(Q){return k(Q)}}async function AZ(Z,$={}){try{let Q=await ZZ(Z,{origin:$.origin});return H(Q,"qr")}catch(Q){return k(Q)}}var O={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1},_Z=["create_kpi"];function QZ(Z={}){let $=new s({name:"embd",version:$Z});if($.registerTool("create_chart",{title:"Create a shareable embd chart link",description:"Turn tabular data into a beautiful, shareable chart and return a self-contained embd.sh URL. "+"No account, no upload, no API call — the chart data is encoded directly into the returned link, "+"so it works anywhere and needs no backend. Use this when you have data (CSV text or an array of flat JSON row objects) and the user wants a chart they can link to, share, or embed. "+"Column roles are inferred automatically (first non-numeric column → X axis, numeric columns → "+"series). Because the data rides in the URL, there is a size limit — if the data is too large the "+"tool returns an error asking you to reduce it; very large datasets need the hosted embd server instead.",inputSchema:G.object({data:G.union([G.string(),G.array(G.record(G.string(),G.unknown()))]).describe('CSV text (first row = headers) or an array of flat row objects with identical keys, e.g. [{"month":"Jan","sales":120}, ...].'),kind:G.enum(VZ).optional().describe("Chart type. Default: inferred from the data (usually line or bar)."),title:G.string().optional().describe("Chart title."),theme:G.string().optional().describe("Theme id (e.g. aurora-dark, aurora-light). Default: aurora-dark.")}),annotations:O},async(Q)=>LZ(Q,Z)),$.registerTool("create_doc",{title:"Create a shareable embd markdown doc link",description:"Render Markdown into a clean, shareable page and return a self-contained embd.sh URL. "+"No account and no upload — the Markdown source is encoded into the link. Use this for a report, "+"write-up, or formatted notes the user wants to share as a link. Markdown only (HTML documents require the hosted embd server). Large documents may exceed the URL size limit and return an error.",inputSchema:G.object({content:G.string().describe("The Markdown source text."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>UZ(Q,Z)),!_Z.includes("create_kpi"))$.registerTool("create_kpi",{title:"Create a shareable embd KPI/stat link",description:"Build a big-number KPI card (value + label, optional change indicator, caption and sparkline) and "+"return a self-contained embd.sh URL. No account or upload — the card is encoded into the link. "+'Values are pre-formatted strings (you format them, e.g. "$1.2M", "98%").',inputSchema:G.object({value:G.string().describe('The big value, pre-formatted (e.g. "$1.2M", "98%").'),label:G.string().describe('What it measures (e.g. "Monthly revenue").'),caption:G.string().optional().describe("Optional sub-line (context or timeframe)."),delta:G.object({value:G.string().describe('Displayed change, e.g. "12%" or "340".'),dir:G.enum(["up","down","flat"]).describe("Arrow direction."),good:G.boolean().optional().describe("Whether this direction reads as positive (drives color). Default: up=good.")}).optional().describe("Optional change indicator."),sparkline:G.array(G.number()).optional().describe("Optional trend series (numbers) drawn behind the value."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>fZ(Q,Z));return $.registerTool("create_qr",{title:"Create a shareable embd QR-code link",description:"Generate a styled QR code for a URL or text and return a self-contained embd.sh URL that renders it. No account or upload. Supports an optional heading, caption, foreground/background hex colors, and a small center emoji icon.",inputSchema:G.object({content:G.string().describe("What the QR encodes (a URL, text, …)."),label:G.string().optional().describe("Optional heading above the code."),caption:G.string().optional().describe("Optional sub-line below it."),fg:G.string().optional().describe("Module (foreground) color as a 6-digit hex."),bg:G.string().optional().describe("Background color as a 6-digit hex."),icon:G.string().optional().describe("A small center emoji icon."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>AZ(Q,Z)),$}import{createServer as hZ}from"node:http";import{Http2ServerRequest as YZ,constants as DZ}from"http2";import{Http2ServerRequest as I}from"http2";import{Readable as WZ}from"stream";import vZ from"crypto";var V=class extends Error{constructor(Z,$){super(Z,$);this.name="RequestError"}},NZ=(Z)=>{if(Z instanceof V)return Z;return new V(Z.message,{cause:Z})},TZ=global.Request,N=class extends TZ{constructor(Z,$){if(typeof Z==="object"&&_ in Z)Z=Z[_]();if(typeof $?.body?.getReader<"u")$.duplex??="half";super(Z,$)}},zZ=(Z)=>{let $=[],Q=Z.rawHeaders;for(let W=0;W<Q.length;W+=2){let{[W]:X,[W+1]:Y}=Q;if(X.charCodeAt(0)!==58)$.push([X,Y])}return new Headers($)},jZ=Symbol("wrapBodyStream"),PZ=(Z,$,Q,W,X)=>{let Y={method:Z,headers:Q,signal:X.signal};if(Z==="TRACE"){Y.method="GET";let j=new N($,Y);return Object.defineProperty(j,"method",{get(){return"TRACE"}}),j}if(!(Z==="GET"||Z==="HEAD"))if("rawBody"in W&&W.rawBody instanceof Buffer)Y.body=new ReadableStream({start(j){j.enqueue(W.rawBody),j.close()}});else if(W[jZ]){let j;Y.body=new ReadableStream({async pull(x){try{j||=WZ.toWeb(W).getReader();let{done:B,value:K}=await j.read();if(B)x.close();else x.enqueue(K)}catch(B){x.error(B)}}})}else Y.body=WZ.toWeb(W);return new N($,Y)},_=Symbol("getRequestCache"),xZ=Symbol("requestCache"),w=Symbol("incomingKey"),y=Symbol("urlKey"),OZ=Symbol("headersKey"),A=Symbol("abortControllerKey"),HZ=Symbol("getAbortController"),T={get method(){return this[w].method||"GET"},get url(){return this[y]},get headers(){return this[OZ]||=zZ(this[w])},[HZ](){return this[_](),this[A]},[_](){return this[A]||=new AbortController,this[xZ]||=PZ(this.method,this[y],this.headers,this[w],this[A])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach((Z)=>{Object.defineProperty(T,Z,{get(){return this[_]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(T,Z,{value:function(){return this[_]()[Z]()}})});Object.defineProperty(T,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[xZ]};return`Request (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(T,N.prototype);var kZ=(Z,$)=>{let Q=Object.create(T);Q[w]=Z;let W=Z.url||"";if(W[0]!=="/"&&(W.startsWith("http://")||W.startsWith("https://"))){if(Z instanceof I)throw new V("Absolute URL for :path is not allowed in HTTP/2");try{let x=new URL(W);Q[y]=x.href}catch(x){throw new V("Invalid absolute URL",{cause:x})}return Q}let X=(Z instanceof I?Z.authority:Z.headers.host)||$;if(!X)throw new V("Missing host header");let Y;if(Z instanceof I){if(Y=Z.scheme,!(Y==="http"||Y==="https"))throw new V("Unsupported scheme")}else Y=Z.socket&&Z.socket.encrypted?"https":"http";let j=new URL(`${Y}://${X}${W}`);if(j.hostname.length!==X.length&&j.hostname!==X.replace(/:\d+$/,""))throw new V("Invalid host header");return Q[y]=j.href,Q},R=Symbol("responseCache"),f=Symbol("getResponseCache"),L=Symbol("cache"),p=global.Response,D=class Z{#$;#Z;[f](){return delete this[L],this[R]||=new p(this.#$,this.#Z)}constructor($,Q){let W;if(this.#$=$,Q instanceof Z){let X=Q[R];if(X){this.#Z=X,this[f]();return}else this.#Z=Q.#Z,W=new Headers(Q.#Z.headers)}else this.#Z=Q;if(typeof $==="string"||typeof $?.getReader<"u"||$ instanceof Blob||$ instanceof Uint8Array)this[L]=[Q?.status||200,$,W||Q?.headers]}get headers(){let $=this[L];if($){if(!($[2]instanceof Headers))$[2]=new Headers($[2]||{"content-type":"text/plain; charset=UTF-8"});return $[2]}return this[f]().headers}get status(){return this[L]?.[0]??this[f]().status}get ok(){let $=this.status;return $>=200&&$<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{get(){return this[f]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{value:function(){return this[f]()[Z]()}})});Object.defineProperty(D.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[R]};return`Response (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(D,p);Object.setPrototypeOf(D.prototype,p.prototype);async function wZ(Z){return Promise.race([Z,Promise.resolve().then(()=>Promise.resolve(void 0))])}function GZ(Z,$,Q){let W=(x)=>{Z.cancel(x).catch(()=>{})};return $.on("close",W),$.on("error",W),(Q??Z.read()).then(j,X),Z.closed.finally(()=>{$.off("close",W),$.off("error",W)});function X(x){if(x)$.destroy(x)}function Y(){Z.read().then(j,X)}function j({done:x,value:B}){try{if(x)$.end();else if(!$.write(B))$.once("drain",Y);else return Z.read().then(j,X)}catch(K){X(K)}}}function yZ(Z,$){if(Z.locked)throw TypeError("ReadableStream is locked.");else if($.destroyed)return;return GZ(Z.getReader(),$)}var h=(Z)=>{let $={};if(!(Z instanceof Headers))Z=new Headers(Z??void 0);let Q=[];for(let[W,X]of Z)if(W==="set-cookie")Q.push(X);else $[W]=X;if(Q.length>0)$["set-cookie"]=Q;return $["content-type"]??="text/plain; charset=UTF-8",$},CZ="x-hono-already-sent";if(typeof global.crypto>"u")global.crypto=vZ;var u=Symbol("outgoingEnded"),XZ=Symbol("incomingDraining"),SZ=500,EZ=67108864,b=(Z)=>{let $=Z;if(Z.destroyed||$[XZ])return;if($[XZ]=!0,Z instanceof YZ){try{Z.stream?.close?.(DZ.NGHTTP2_NO_ERROR)}catch{}return}let Q=0,W=()=>{clearTimeout(Y),Z.off("data",j),Z.off("end",W),Z.off("error",W)},X=()=>{W();let x=Z.socket;if(x&&!x.destroyed)x.destroySoon()},Y=setTimeout(X,SZ);Y.unref?.();let j=(x)=>{if(Q+=x.length,Q>EZ)X()};Z.on("data",j),Z.on("end",W),Z.on("error",W),Z.resume()},IZ=()=>new Response(null,{status:400}),BZ=(Z)=>new Response(null,{status:Z instanceof Error&&(Z.name==="TimeoutError"||Z.constructor.name==="TimeoutError")?504:500}),q=(Z,$)=>{let Q=Z instanceof Error?Z:Error("unknown error",{cause:Z});if(Q.code==="ERR_STREAM_PREMATURE_CLOSE")console.info("The user aborted a request.");else{if(console.error(Z),!$.headersSent)$.writeHead(500,{"Content-Type":"text/plain"});$.end(`Error: ${Q.message}`),$.destroy(Q)}},KZ=(Z)=>{if("flushHeaders"in Z&&Z.writable)Z.flushHeaders()},FZ=async(Z,$)=>{let[Q,W,X]=Z[L],Y=!1;if(!X)X={"content-type":"text/plain; charset=UTF-8"};else if(X instanceof Headers)Y=X.has("content-length"),X=h(X);else if(Array.isArray(X)){let j=new Headers(X);Y=j.has("content-length"),X=h(j)}else for(let j in X)if(j.length===14&&j.toLowerCase()==="content-length"){Y=!0;break}if(!Y){if(typeof W==="string")X["Content-Length"]=Buffer.byteLength(W);else if(W instanceof Uint8Array)X["Content-Length"]=W.byteLength;else if(W instanceof Blob)X["Content-Length"]=W.size}if($.writeHead(Q,X),typeof W==="string"||W instanceof Uint8Array)$.end(W);else if(W instanceof Blob)$.end(new Uint8Array(await W.arrayBuffer()));else KZ($),await yZ(W,$)?.catch((j)=>q(j,$));$[u]?.()},bZ=(Z)=>typeof Z.then==="function",RZ=async(Z,$,Q={})=>{if(bZ(Z))if(Q.errorHandler)try{Z=await Z}catch(X){let Y=await Q.errorHandler(X);if(!Y)return;Z=Y}else Z=await Z.catch(BZ);if(L in Z)return FZ(Z,$);let W=h(Z.headers);if(Z.body){let X=Z.body.getReader(),Y=[],j=!1,x=void 0;if(W["transfer-encoding"]!=="chunked"){let B=2;for(let K=0;K<B;K++){x||=X.read();let M=await wZ(x).catch((U)=>{console.error(U),j=!0});if(!M){if(K===1){await new Promise((U)=>setTimeout(U)),B=3;continue}break}if(x=void 0,M.value)Y.push(M.value);if(M.done){j=!0;break}}if(j&&!("content-length"in W))W["content-length"]=Y.reduce((K,M)=>K+M.length,0)}if($.writeHead(Z.status,W),Y.forEach((B)=>{$.write(B)}),j)$.end();else{if(Y.length===0)KZ($);await GZ(X,$,x)}}else if(W[CZ]);else $.writeHead(Z.status,W),$.end();$[u]?.()},m=(Z,$={})=>{let Q=$.autoCleanupIncoming??!0;if($.overrideGlobalObjects!==!1&&global.Request!==N)Object.defineProperty(global,"Request",{value:N}),Object.defineProperty(global,"Response",{value:D});return async(W,X)=>{let Y,j;try{j=kZ(W,$.hostname);let x=!Q||W.method==="GET"||W.method==="HEAD";if(!x){if(W[jZ]=!0,W.on("end",()=>{x=!0}),W instanceof YZ)X[u]=()=>{if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})};X.on("finish",()=>{if(!x)b(W)})}if(X.on("close",()=>{if(j[A]){if(W.errored)j[A].abort(W.errored.toString());else if(!X.writableFinished)j[A].abort("Client connection prematurely closed.")}if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})}),Y=Z(j,{incoming:W,outgoing:X}),L in Y)return FZ(Y,X)}catch(x){if(!Y)if($.errorHandler){if(Y=await $.errorHandler(j?x:NZ(x)),!Y)return}else if(!j)Y=IZ();else Y=BZ(x);else return q(x,X)}try{return await RZ(Y,X,$)}catch(x){return q(x,X)}}};class d{constructor(Z={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=Z.sessionIdGenerator,this._enableJsonResponse=Z.enableJsonResponse??!1,this._eventStore=Z.eventStore,this._onsessioninitialized=Z.onsessioninitialized,this._onsessionclosed=Z.onsessionclosed,this._allowedHosts=Z.allowedHosts,this._allowedOrigins=Z.allowedOrigins,this._enableDnsRebindingProtection=Z.enableDnsRebindingProtection??!1,this._retryInterval=Z.retryInterval}async start(){if(this._started)throw Error("Transport already started");this._started=!0}createJsonErrorResponse(Z,$,Q,W){let X={code:$,message:Q};if(W?.data!==void 0)X.data=W.data;return new Response(JSON.stringify({jsonrpc:"2.0",error:X,id:null}),{status:Z,headers:{"Content-Type":"application/json",...W?.headers}})}validateRequestHeaders(Z){if(!this._enableDnsRebindingProtection)return;if(this._allowedHosts&&this._allowedHosts.length>0){let $=Z.headers.get("host");if(!$||!this._allowedHosts.includes($)){let Q=`Invalid Host header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let $=Z.headers.get("origin");if($&&!this._allowedOrigins.includes($)){let Q=`Invalid Origin header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}return}async handleRequest(Z,$){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let Q=this.validateRequestHeaders(Z);if(Q)return Q;switch(Z.method){case"POST":return this.handlePostRequest(Z,$);case"GET":return this.handleGetRequest(Z);case"DELETE":return this.handleDeleteRequest(Z);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(Z,$,Q,W){if(!this._eventStore)return;if(W<"2025-11-25")return;let X=await this._eventStore.storeEvent(Q,{}),Y=`id: ${X}
1
+ import{q as o,r,s as e,t as ZZ,y as $Z}from"./bin-8sz4cm9k.js";import{D as G,E as MZ,F as C,G as z,H as v,I as S,J as c,K as l,L as s}from"./bin-abb2cdyk.js";var VZ=["line","area","bar","stacked-bar","stacked-area","bar-horizontal","scatter","pie","donut","heatmap","radar"],E=["stage","slate","dusk","paper","mist","sepia"];function H(Z,$){return{content:[{type:"text",text:Z}],structuredContent:{url:Z,kind:$}}}function k(Z){return{content:[{type:"text",text:Z instanceof Error?Z.message:String(Z)}],isError:!0}}async function LZ(Z,$={}){try{let Q=await o(Z.data,{origin:$.origin,kind:Z.kind,title:Z.title,themeId:Z.theme});return H(Q,"chart")}catch(Q){return k(Q)}}async function UZ(Z,$={}){try{let Q=await r(Z.content,{origin:$.origin,theme:Z.theme});return H(Q,"markdown")}catch(Q){return k(Q)}}async function fZ(Z,$={}){try{let Q=await e(Z,{origin:$.origin});return H(Q,"kpi")}catch(Q){return k(Q)}}async function AZ(Z,$={}){try{let Q=await ZZ(Z,{origin:$.origin});return H(Q,"qr")}catch(Q){return k(Q)}}var O={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1},_Z=["create_kpi"];function QZ(Z={}){let $=new s({name:"embd",version:$Z});if($.registerTool("create_chart",{title:"Create a shareable embd chart link",description:"Turn tabular data into a beautiful, shareable chart and return a self-contained embd.sh URL. "+"No account, no upload, no API call — the chart data is encoded directly into the returned link, "+"so it works anywhere and needs no backend. Use this when you have data (CSV text or an array of flat JSON row objects) and the user wants a chart they can link to, share, or embed. "+"Column roles are inferred automatically (first non-numeric column → X axis, numeric columns → "+"series). Because the data rides in the URL, there is a size limit — if the data is too large the "+"tool returns an error asking you to reduce it; very large datasets need the hosted embd server instead.",inputSchema:G.object({data:G.union([G.string(),G.array(G.record(G.string(),G.unknown()))]).describe('CSV text (first row = headers) or an array of flat row objects with identical keys, e.g. [{"month":"Jan","sales":120}, ...].'),kind:G.enum(VZ).optional().describe("Chart type. Default: inferred from the data (usually line or bar)."),title:G.string().optional().describe("Chart title."),theme:G.string().optional().describe("Theme id (e.g. aurora-dark, aurora-light). Default: aurora-dark.")}),annotations:O},async(Q)=>LZ(Q,Z)),$.registerTool("create_doc",{title:"Create a shareable embd markdown doc link",description:"Render Markdown into a clean, shareable page and return a self-contained embd.sh URL. "+"No account and no upload — the Markdown source is encoded into the link. Use this for a report, "+"write-up, or formatted notes the user wants to share as a link. Markdown only (HTML documents require the hosted embd server). Large documents may exceed the URL size limit and return an error.",inputSchema:G.object({content:G.string().describe("The Markdown source text."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>UZ(Q,Z)),!_Z.includes("create_kpi"))$.registerTool("create_kpi",{title:"Create a shareable embd KPI/stat link",description:"Build a big-number KPI card (value + label, optional change indicator, caption and sparkline) and "+"return a self-contained embd.sh URL. No account or upload — the card is encoded into the link. "+'Values are pre-formatted strings (you format them, e.g. "$1.2M", "98%").',inputSchema:G.object({value:G.string().describe('The big value, pre-formatted (e.g. "$1.2M", "98%").'),label:G.string().describe('What it measures (e.g. "Monthly revenue").'),caption:G.string().optional().describe("Optional sub-line (context or timeframe)."),delta:G.object({value:G.string().describe('Displayed change, e.g. "12%" or "340".'),dir:G.enum(["up","down","flat"]).describe("Arrow direction."),good:G.boolean().optional().describe("Whether this direction reads as positive (drives color). Default: up=good.")}).optional().describe("Optional change indicator."),sparkline:G.array(G.number()).optional().describe("Optional trend series (numbers) drawn behind the value."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>fZ(Q,Z));return $.registerTool("create_qr",{title:"Create a shareable embd QR-code link",description:"Generate a styled QR code for a URL or text and return a self-contained embd.sh URL that renders it. No account or upload. Supports an optional heading, caption, foreground/background hex colors, and a small center emoji icon.",inputSchema:G.object({content:G.string().describe("What the QR encodes (a URL, text, …)."),label:G.string().optional().describe("Optional heading above the code."),caption:G.string().optional().describe("Optional sub-line below it."),fg:G.string().optional().describe("Module (foreground) color as a 6-digit hex."),bg:G.string().optional().describe("Background color as a 6-digit hex."),icon:G.string().optional().describe("A small center emoji icon."),theme:G.enum(E).optional().describe("Reading theme. Default: stage.")}),annotations:O},async(Q)=>AZ(Q,Z)),$}import{createServer as hZ}from"node:http";import{Http2ServerRequest as YZ,constants as DZ}from"http2";import{Http2ServerRequest as I}from"http2";import{Readable as WZ}from"stream";import vZ from"crypto";var V=class extends Error{constructor(Z,$){super(Z,$);this.name="RequestError"}},NZ=(Z)=>{if(Z instanceof V)return Z;return new V(Z.message,{cause:Z})},TZ=global.Request,N=class extends TZ{constructor(Z,$){if(typeof Z==="object"&&_ in Z)Z=Z[_]();if(typeof $?.body?.getReader<"u")$.duplex??="half";super(Z,$)}},zZ=(Z)=>{let $=[],Q=Z.rawHeaders;for(let W=0;W<Q.length;W+=2){let{[W]:X,[W+1]:Y}=Q;if(X.charCodeAt(0)!==58)$.push([X,Y])}return new Headers($)},jZ=Symbol("wrapBodyStream"),PZ=(Z,$,Q,W,X)=>{let Y={method:Z,headers:Q,signal:X.signal};if(Z==="TRACE"){Y.method="GET";let j=new N($,Y);return Object.defineProperty(j,"method",{get(){return"TRACE"}}),j}if(!(Z==="GET"||Z==="HEAD"))if("rawBody"in W&&W.rawBody instanceof Buffer)Y.body=new ReadableStream({start(j){j.enqueue(W.rawBody),j.close()}});else if(W[jZ]){let j;Y.body=new ReadableStream({async pull(x){try{j||=WZ.toWeb(W).getReader();let{done:B,value:K}=await j.read();if(B)x.close();else x.enqueue(K)}catch(B){x.error(B)}}})}else Y.body=WZ.toWeb(W);return new N($,Y)},_=Symbol("getRequestCache"),xZ=Symbol("requestCache"),w=Symbol("incomingKey"),y=Symbol("urlKey"),OZ=Symbol("headersKey"),A=Symbol("abortControllerKey"),HZ=Symbol("getAbortController"),T={get method(){return this[w].method||"GET"},get url(){return this[y]},get headers(){return this[OZ]||=zZ(this[w])},[HZ](){return this[_](),this[A]},[_](){return this[A]||=new AbortController,this[xZ]||=PZ(this.method,this[y],this.headers,this[w],this[A])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach((Z)=>{Object.defineProperty(T,Z,{get(){return this[_]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(T,Z,{value:function(){return this[_]()[Z]()}})});Object.defineProperty(T,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[xZ]};return`Request (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(T,N.prototype);var kZ=(Z,$)=>{let Q=Object.create(T);Q[w]=Z;let W=Z.url||"";if(W[0]!=="/"&&(W.startsWith("http://")||W.startsWith("https://"))){if(Z instanceof I)throw new V("Absolute URL for :path is not allowed in HTTP/2");try{let x=new URL(W);Q[y]=x.href}catch(x){throw new V("Invalid absolute URL",{cause:x})}return Q}let X=(Z instanceof I?Z.authority:Z.headers.host)||$;if(!X)throw new V("Missing host header");let Y;if(Z instanceof I){if(Y=Z.scheme,!(Y==="http"||Y==="https"))throw new V("Unsupported scheme")}else Y=Z.socket&&Z.socket.encrypted?"https":"http";let j=new URL(`${Y}://${X}${W}`);if(j.hostname.length!==X.length&&j.hostname!==X.replace(/:\d+$/,""))throw new V("Invalid host header");return Q[y]=j.href,Q},R=Symbol("responseCache"),f=Symbol("getResponseCache"),L=Symbol("cache"),p=global.Response,D=class Z{#$;#Z;[f](){return delete this[L],this[R]||=new p(this.#$,this.#Z)}constructor($,Q){let W;if(this.#$=$,Q instanceof Z){let X=Q[R];if(X){this.#Z=X,this[f]();return}else this.#Z=Q.#Z,W=new Headers(Q.#Z.headers)}else this.#Z=Q;if(typeof $==="string"||typeof $?.getReader<"u"||$ instanceof Blob||$ instanceof Uint8Array)this[L]=[Q?.status||200,$,W||Q?.headers]}get headers(){let $=this[L];if($){if(!($[2]instanceof Headers))$[2]=new Headers($[2]||{"content-type":"text/plain; charset=UTF-8"});return $[2]}return this[f]().headers}get status(){return this[L]?.[0]??this[f]().status}get ok(){let $=this.status;return $>=200&&$<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{get(){return this[f]()[Z]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach((Z)=>{Object.defineProperty(D.prototype,Z,{value:function(){return this[f]()[Z]()}})});Object.defineProperty(D.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(Z,$,Q){let W={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[R]};return`Response (lightweight) ${Q(W,{...$,depth:Z==null?null:Z-1})}`}});Object.setPrototypeOf(D,p);Object.setPrototypeOf(D.prototype,p.prototype);async function wZ(Z){return Promise.race([Z,Promise.resolve().then(()=>Promise.resolve(void 0))])}function GZ(Z,$,Q){let W=(x)=>{Z.cancel(x).catch(()=>{})};return $.on("close",W),$.on("error",W),(Q??Z.read()).then(j,X),Z.closed.finally(()=>{$.off("close",W),$.off("error",W)});function X(x){if(x)$.destroy(x)}function Y(){Z.read().then(j,X)}function j({done:x,value:B}){try{if(x)$.end();else if(!$.write(B))$.once("drain",Y);else return Z.read().then(j,X)}catch(K){X(K)}}}function yZ(Z,$){if(Z.locked)throw TypeError("ReadableStream is locked.");else if($.destroyed)return;return GZ(Z.getReader(),$)}var h=(Z)=>{let $={};if(!(Z instanceof Headers))Z=new Headers(Z??void 0);let Q=[];for(let[W,X]of Z)if(W==="set-cookie")Q.push(X);else $[W]=X;if(Q.length>0)$["set-cookie"]=Q;return $["content-type"]??="text/plain; charset=UTF-8",$},CZ="x-hono-already-sent";if(typeof global.crypto>"u")global.crypto=vZ;var u=Symbol("outgoingEnded"),XZ=Symbol("incomingDraining"),SZ=500,EZ=67108864,b=(Z)=>{let $=Z;if(Z.destroyed||$[XZ])return;if($[XZ]=!0,Z instanceof YZ){try{Z.stream?.close?.(DZ.NGHTTP2_NO_ERROR)}catch{}return}let Q=0,W=()=>{clearTimeout(Y),Z.off("data",j),Z.off("end",W),Z.off("error",W)},X=()=>{W();let x=Z.socket;if(x&&!x.destroyed)x.destroySoon()},Y=setTimeout(X,SZ);Y.unref?.();let j=(x)=>{if(Q+=x.length,Q>EZ)X()};Z.on("data",j),Z.on("end",W),Z.on("error",W),Z.resume()},IZ=()=>new Response(null,{status:400}),BZ=(Z)=>new Response(null,{status:Z instanceof Error&&(Z.name==="TimeoutError"||Z.constructor.name==="TimeoutError")?504:500}),q=(Z,$)=>{let Q=Z instanceof Error?Z:Error("unknown error",{cause:Z});if(Q.code==="ERR_STREAM_PREMATURE_CLOSE")console.info("The user aborted a request.");else{if(console.error(Z),!$.headersSent)$.writeHead(500,{"Content-Type":"text/plain"});$.end(`Error: ${Q.message}`),$.destroy(Q)}},KZ=(Z)=>{if("flushHeaders"in Z&&Z.writable)Z.flushHeaders()},FZ=async(Z,$)=>{let[Q,W,X]=Z[L],Y=!1;if(!X)X={"content-type":"text/plain; charset=UTF-8"};else if(X instanceof Headers)Y=X.has("content-length"),X=h(X);else if(Array.isArray(X)){let j=new Headers(X);Y=j.has("content-length"),X=h(j)}else for(let j in X)if(j.length===14&&j.toLowerCase()==="content-length"){Y=!0;break}if(!Y){if(typeof W==="string")X["Content-Length"]=Buffer.byteLength(W);else if(W instanceof Uint8Array)X["Content-Length"]=W.byteLength;else if(W instanceof Blob)X["Content-Length"]=W.size}if($.writeHead(Q,X),typeof W==="string"||W instanceof Uint8Array)$.end(W);else if(W instanceof Blob)$.end(new Uint8Array(await W.arrayBuffer()));else KZ($),await yZ(W,$)?.catch((j)=>q(j,$));$[u]?.()},bZ=(Z)=>typeof Z.then==="function",RZ=async(Z,$,Q={})=>{if(bZ(Z))if(Q.errorHandler)try{Z=await Z}catch(X){let Y=await Q.errorHandler(X);if(!Y)return;Z=Y}else Z=await Z.catch(BZ);if(L in Z)return FZ(Z,$);let W=h(Z.headers);if(Z.body){let X=Z.body.getReader(),Y=[],j=!1,x=void 0;if(W["transfer-encoding"]!=="chunked"){let B=2;for(let K=0;K<B;K++){x||=X.read();let M=await wZ(x).catch((U)=>{console.error(U),j=!0});if(!M){if(K===1){await new Promise((U)=>setTimeout(U)),B=3;continue}break}if(x=void 0,M.value)Y.push(M.value);if(M.done){j=!0;break}}if(j&&!("content-length"in W))W["content-length"]=Y.reduce((K,M)=>K+M.length,0)}if($.writeHead(Z.status,W),Y.forEach((B)=>{$.write(B)}),j)$.end();else{if(Y.length===0)KZ($);await GZ(X,$,x)}}else if(W[CZ]);else $.writeHead(Z.status,W),$.end();$[u]?.()},m=(Z,$={})=>{let Q=$.autoCleanupIncoming??!0;if($.overrideGlobalObjects!==!1&&global.Request!==N)Object.defineProperty(global,"Request",{value:N}),Object.defineProperty(global,"Response",{value:D});return async(W,X)=>{let Y,j;try{j=kZ(W,$.hostname);let x=!Q||W.method==="GET"||W.method==="HEAD";if(!x){if(W[jZ]=!0,W.on("end",()=>{x=!0}),W instanceof YZ)X[u]=()=>{if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})};X.on("finish",()=>{if(!x)b(W)})}if(X.on("close",()=>{if(j[A]){if(W.errored)j[A].abort(W.errored.toString());else if(!X.writableFinished)j[A].abort("Client connection prematurely closed.")}if(!x)setTimeout(()=>{if(!x)setTimeout(()=>{b(W)})})}),Y=Z(j,{incoming:W,outgoing:X}),L in Y)return FZ(Y,X)}catch(x){if(!Y)if($.errorHandler){if(Y=await $.errorHandler(j?x:NZ(x)),!Y)return}else if(!j)Y=IZ();else Y=BZ(x);else return q(x,X)}try{return await RZ(Y,X,$)}catch(x){return q(x,X)}}};class d{constructor(Z={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=Z.sessionIdGenerator,this._enableJsonResponse=Z.enableJsonResponse??!1,this._eventStore=Z.eventStore,this._onsessioninitialized=Z.onsessioninitialized,this._onsessionclosed=Z.onsessionclosed,this._allowedHosts=Z.allowedHosts,this._allowedOrigins=Z.allowedOrigins,this._enableDnsRebindingProtection=Z.enableDnsRebindingProtection??!1,this._retryInterval=Z.retryInterval}async start(){if(this._started)throw Error("Transport already started");this._started=!0}createJsonErrorResponse(Z,$,Q,W){let X={code:$,message:Q};if(W?.data!==void 0)X.data=W.data;return new Response(JSON.stringify({jsonrpc:"2.0",error:X,id:null}),{status:Z,headers:{"Content-Type":"application/json",...W?.headers}})}validateRequestHeaders(Z){if(!this._enableDnsRebindingProtection)return;if(this._allowedHosts&&this._allowedHosts.length>0){let $=Z.headers.get("host");if(!$||!this._allowedHosts.includes($)){let Q=`Invalid Host header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let $=Z.headers.get("origin");if($&&!this._allowedOrigins.includes($)){let Q=`Invalid Origin header: ${$}`;return this.onerror?.(Error(Q)),this.createJsonErrorResponse(403,-32000,Q)}}return}async handleRequest(Z,$){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let Q=this.validateRequestHeaders(Z);if(Q)return Q;switch(Z.method){case"POST":return this.handlePostRequest(Z,$);case"GET":return this.handleGetRequest(Z);case"DELETE":return this.handleDeleteRequest(Z);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(Z,$,Q,W){if(!this._eventStore)return;if(W<"2025-11-25")return;let X=await this._eventStore.storeEvent(Q,{}),Y=`id: ${X}
2
2
  data:
3
3
 
4
4
  `;if(this._retryInterval!==void 0)Y=`id: ${X}
package/dist/bin.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{a as g}from"./bin-361phfqr.js";import{n as h,p as q,z as u}from"./bin-bw6a4d6a.js";import"./bin-66kzqre3.js";async function z(){let f=process.env.EMBD_API_KEY;if(!f)console.error(`embd MCP server: the EMBD_API_KEY environment variable is required.
2
+ import{a as g}from"./bin-f58c3spd.js";import{n as h,p as q,z as u}from"./bin-8sz4cm9k.js";import"./bin-abb2cdyk.js";async function z(){let f=process.env.EMBD_API_KEY;if(!f)console.error(`embd MCP server: the EMBD_API_KEY environment variable is required.
3
3
  Create an API key in your embd account settings (${h}), then configure this server with EMBD_API_KEY=embd_sk_...`),process.exit(1);let w=new q({apiKey:f,apiUrl:process.env.EMBD_API_URL});await u(w).connect(new g),console.error("embd MCP server running on stdio")}z().catch((f)=>{console.error("embd MCP server failed to start:",f),process.exit(1)});
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as h}from"./bin-361phfqr.js";import{b as q,c as y,d as z}from"./bin-0ftgp1t8.js";import"./bin-66kzqre3.js";try{let f=new q(process.env.EMBD_DOCUMENT_TOKEN??"",process.env.EMBD_DOCUMENT_ORIGIN);await z(f,new y(f,process.env.EMBD_DOCUMENT_TOKEN??"",process.env.EMBD_DOCUMENT_ORIGIN,process.env.EMBD_KB_DIR)).connect(new h),console.error("embd private document MCP ready")}catch{console.error("Cannot start document MCP. Check EMBD_DOCUMENT_TOKEN and EMBD_DOCUMENT_ORIGIN."),process.exitCode=1}
2
+ import{a as h}from"./bin-f58c3spd.js";import{b as q,c as y,d as z}from"./bin-7hkeyekt.js";import"./bin-abb2cdyk.js";try{let f=new q(process.env.EMBD_DOCUMENT_TOKEN??"",process.env.EMBD_DOCUMENT_ORIGIN);await z(f,new y(f,process.env.EMBD_DOCUMENT_TOKEN??"",process.env.EMBD_DOCUMENT_ORIGIN,process.env.EMBD_KB_DIR)).connect(new h),console.error("embd private document MCP ready")}catch{console.error("Cannot start document MCP. Check EMBD_DOCUMENT_TOKEN and EMBD_DOCUMENT_ORIGIN."),process.exitCode=1}
package/dist/http-bin.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{k as x}from"./bin-9vtm5gnz.js";import"./bin-bw6a4d6a.js";import"./bin-66kzqre3.js";var j=Number(process.env.PORT??process.env.EMBD_MCP_PORT??8787),q=process.env.EMBD_MCP_HOST??"127.0.0.1",y=process.env.EMBD_MCP_PATH??"/mcp",C=process.env.EMBD_ORIGIN,z=(process.env.EMBD_MCP_ALLOWED_HOSTS??"").split(",").map((b)=>b.trim()).filter((b)=>b.length>0),A=x({origin:C,mcpPath:y,allowedHosts:z});A.listen(j,q,()=>{if(console.log(`embd MCP (stateless HTTP) listening on http://${q}:${j}${y}`),z.length===0)console.log("Note: DNS-rebinding protection is OFF. Set EMBD_MCP_ALLOWED_HOSTS if exposing this port directly.")});function B(b){console.log(`
2
+ import{k as x}from"./bin-rxb1ygpc.js";import"./bin-8sz4cm9k.js";import"./bin-abb2cdyk.js";var j=Number(process.env.PORT??process.env.EMBD_MCP_PORT??8787),q=process.env.EMBD_MCP_HOST??"127.0.0.1",y=process.env.EMBD_MCP_PATH??"/mcp",C=process.env.EMBD_ORIGIN,z=(process.env.EMBD_MCP_ALLOWED_HOSTS??"").split(",").map((b)=>b.trim()).filter((b)=>b.length>0),A=x({origin:C,mcpPath:y,allowedHosts:z});A.listen(j,q,()=>{if(console.log(`embd MCP (stateless HTTP) listening on http://${q}:${j}${y}`),z.length===0)console.log("Note: DNS-rebinding protection is OFF. Set EMBD_MCP_ALLOWED_HOSTS if exposing this port directly.")});function B(b){console.log(`
3
3
  embd MCP: received ${b}, shutting down.`),A.close(()=>process.exit(0)),setTimeout(()=>process.exit(0),5000).unref()}process.on("SIGINT",()=>B("SIGINT"));process.on("SIGTERM",()=>B("SIGTERM"));
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{b as h,d as m}from"./bin-0ftgp1t8.js";import{e as i,f as s,g as E,h as c,i as y,j as S,k as f}from"./bin-9vtm5gnz.js";import{l as e,m as t,o as r,p as a,u as p,v as o,w as n,x as l,y as C,z as d}from"./bin-bw6a4d6a.js";import"./bin-66kzqre3.js";export{c as handleQrUrl,n as handleListCharts,E as handleKpiUrl,s as handleDocUrl,l as handleDeleteChart,o as handleCreateDoc,p as handleCreateChart,i as handleChartUrl,r as friendlyErrorMessage,y as createStatelessServer,S as createRequestListener,f as createHttpServer,d as createEmbdServer,m as createDocumentServer,C as SERVER_VERSION,t as EmbdApiError,a as EmbdApiClient,h as DocumentClient,e as DEFAULT_API_URL};
1
+ import{b as h,d as m}from"./bin-7hkeyekt.js";import{e as i,f as s,g as E,h as c,i as y,j as S,k as f}from"./bin-rxb1ygpc.js";import{l as e,m as t,o as r,p as a,u as p,v as o,w as n,x as l,y as C,z as d}from"./bin-8sz4cm9k.js";import"./bin-abb2cdyk.js";export{c as handleQrUrl,n as handleListCharts,E as handleKpiUrl,s as handleDocUrl,l as handleDeleteChart,o as handleCreateDoc,p as handleCreateChart,i as handleChartUrl,r as friendlyErrorMessage,y as createStatelessServer,S as createRequestListener,f as createHttpServer,d as createEmbdServer,m as createDocumentServer,C as SERVER_VERSION,t as EmbdApiError,a as EmbdApiClient,h as DocumentClient,e as DEFAULT_API_URL};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embd/mcp",
3
- "version": "0.7.8",
3
+ "version": "0.7.9",
4
4
  "description": "Private collaborative Markdown/HTML workspaces and embeddable charts from AI agents via MCP",
5
5
  "type": "module",
6
6
  "bin": {
@@ -44,5 +44,5 @@
44
44
  "url": "git+https://github.com/arthurpark/embd.git",
45
45
  "directory": "packages/mcp"
46
46
  },
47
- "embdRelease": "81f8ffbda4e64ec8acb289139f1ac71416cee63d755de5a216f081643472b468"
47
+ "embdRelease": "7192cbd0fd99e9a2e82f64553b30f1999d72cf675e34b0993cacceb54e6db132"
48
48
  }