xmcp 1.1.3 → 1.3.0

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.
@@ -0,0 +1,24 @@
1
+ import type { LoggingLevel, ServerContext } from "@modelcontextprotocol/server";
2
+ import type { McpClientInfo } from "../../types/client-info";
3
+ export interface RequestContext {
4
+ readonly clientInfo?: Readonly<McpClientInfo>;
5
+ readonly http?: {
6
+ /** The HTTP request ID generated by xmcp, not the JSON-RPC message ID. */
7
+ readonly id: string;
8
+ readonly headers: Readonly<Record<string, string | readonly string[] | undefined>>;
9
+ };
10
+ /** The live cancellation signal supplied by the MCP SDK. */
11
+ readonly signal: AbortSignal;
12
+ /** Store a value for this MCP operation, shared with its async helpers. */
13
+ set(key: string | symbol, value: unknown): void;
14
+ /** Read a request-local value. The type parameter is a compile-time cast. */
15
+ get<T = unknown>(key: string | symbol): T | undefined;
16
+ /** Send progress when the current request supplies a progress token. */
17
+ progress(value: number, total?: number): Promise<void>;
18
+ /** Send an MCP log message using the SDK's capability and level checks. */
19
+ log(level: LoggingLevel, data: unknown): Promise<void>;
20
+ }
21
+ /** Read the current MCP request from a handler or one of its async helpers. */
22
+ export declare function getRequestContext(): RequestContext;
23
+ /** Internal boundary around MCP operation execution; handler arguments stay intact. */
24
+ export declare function withRequestContext<T>(ctx: ServerContext, clientInfo: McpClientInfo | undefined, callback: () => T): T;
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,()=>(()=>{"use strict";var e={};e.d=(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{headers:()=>c});let r=require("async_hooks"),o=(e,t)=>{globalThis[e]=t},n=e=>globalThis[e],l=function({name:e}){let t=Symbol.for(`xmcp-context-${e}`),l=Symbol.for(`xmcp-context-${e}-fallback-store`);if(n(t))return n(t);let s=new r.AsyncLocalStorage,c=globalThis[l]??{current:null};o(l,c);let i={provider:(e,t)=>(c.current=e,s.run(e,t)),getContext:()=>{let t=s.getStore();if(t)return t;if(c.current)return c.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:t=>{let r=s.getStore()??c.current;if(!r)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(r,t)}};return o(t,i),i}({name:"http-request-context"});l.setContext;let s=l.getContext;l.provider;let c=()=>{let e=s().headers,t=new Map;for(let r of Object.keys(e)){let e=r.toLowerCase();t.has(e)||t.set(e,r)}let r=e=>t.get(e.toLowerCase())??e;return new Proxy(e,{get:(e,t,o)=>"string"!=typeof t?Reflect.get(e,t,o):Reflect.get(e,r(t),o),has:(e,t)=>"string"!=typeof t?Reflect.has(e,t):Reflect.has(e,r(t)),getOwnPropertyDescriptor:(e,t)=>"string"!=typeof t?Reflect.getOwnPropertyDescriptor(e,t):Reflect.getOwnPropertyDescriptor(e,r(t))})};return t})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,()=>(()=>{"use strict";var e={};e.d=(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{headers:()=>c});let r=require("async_hooks"),o=(e,t)=>{globalThis[e]=t},n=e=>globalThis[e],l=function({name:e,fallback:t=!0}){let l=Symbol.for(`xmcp-context-${e}`),s=Symbol.for(`xmcp-context-${e}-fallback-store`);if(n(l))return n(l);let c=new r.AsyncLocalStorage,i=globalThis[s]??{current:null};o(s,i);let f={provider:(e,r)=>(t&&(i.current=e),c.run(e,r)),getContext:()=>{let r=c.getStore();if(r)return r;if(t&&i.current)return i.current;throw Error(`getContext() can only be used within the ${e} context.`)},setContext:r=>{let o=c.getStore()??(t?i.current:null);if(!o)throw Error(`setContext() can only be used within the ${e} context.`);Object.assign(o,r)}};return o(l,f),f}({name:"http-request-context"});l.setContext;let s=l.getContext;l.provider;let c=()=>{let e=s().headers,t=new Map;for(let r of Object.keys(e)){let e=r.toLowerCase();t.has(e)||t.set(e,r)}let r=e=>t.get(e.toLowerCase())??e;return new Proxy(e,{get:(e,t,o)=>"string"!=typeof t?Reflect.get(e,t,o):Reflect.get(e,r(t),o),has:(e,t)=>"string"!=typeof t?Reflect.has(e,t):Reflect.has(e,r(t)),getOwnPropertyDescriptor:(e,t)=>"string"!=typeof t?Reflect.getOwnPropertyDescriptor(e,t):Reflect.getOwnPropertyDescriptor(e,r(t))})};return t})());