mcp2service 1.0.5 → 1.0.6

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.
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var P=Object.create;var{getPrototypeOf:z,defineProperty:I,getOwnPropertyNames:J,getOwnPropertyDescriptor:tt}=Object,B=Object.prototype.hasOwnProperty;var q=(t,i,s)=>{s=t!=null?P(z(t)):{};let e=i||!t||!t.__esModule?I(s,"default",{value:t,enumerable:!0}):s;for(let r of J(t))if(!B.call(e,r))I(e,r,{get:()=>t[r],enumerable:!0});return e},F=new WeakMap,it=(t)=>{var i=F.get(t),s;if(i)return i;if(i=I({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")J(t).map((e)=>!B.call(i,e)&&I(i,e,{get:()=>t[e],enumerable:!(s=tt(t,e))||s.enumerable}));return F.set(t,i),i};var et=(t,i)=>{for(var s in i)I(t,s,{get:i[s],enumerable:!0,configurable:!0,set:(e)=>i[s]=()=>e})};var ot={};et(ot,{grpcAdapterConfigSchema:()=>M,graphqlAdapterConfigSchema:()=>Z,defaultAdapterFactory:()=>v,McpProxy:()=>j,HttpAdapter:()=>Q,GrpcAdapter:()=>$,GraphQLAdapter:()=>V,DefaultAdapterFactory:()=>W});module.exports=it(ot);var N=require("@kingecg/fastmcp");class G extends Error{code;statusCode;details;constructor(t,i,s,e){super(t);this.code=i;this.statusCode=s;this.details=e;this.name="MCPError"}}class c extends G{constructor(t,i){super(t,"VALIDATION_ERROR",400,i);this.name="ValidationError"}}class p extends G{constructor(t,i){super(t,"CONFIGURATION_ERROR",500,i);this.name="ConfigurationError"}}class h extends G{adapterName;constructor(t,i,s){super(t,"ADAPTER_ERROR",502,{adapterName:i,...s});this.adapterName=i;this.name="AdapterError"}}var pt=require("axios"),H=q(require("axios"));var n=require("zod");var nt=n.z.custom((t)=>typeof t==="function",{message:"authedFn must be a function that returns a Promise"}),st=n.z.custom((t)=>typeof t==="function",{message:"execute must be a function"}),C=n.z.union([n.z.literal("string"),n.z.literal("number"),n.z.literal("boolean"),n.z.literal("any")]),k=n.z.string().regex(/^(string|number|boolean|any):/),O=n.z.object({type:C,description:n.z.string().optional()}),_=n.z.lazy(()=>n.z.object({type:n.z.literal("object"),description:n.z.string().optional(),properties:n.z.record(n.z.string(),n.z.union([C,O,_,b,k,n.z.record(n.z.string(),C),n.z.array(C)]))})),b=n.z.lazy(()=>n.z.object({type:n.z.literal("array"),description:n.z.string().optional(),items:n.z.union([C,O,_,b,k,n.z.record(n.z.string(),C),n.z.array(C)])})),S=n.z.lazy(()=>n.z.union([O,_,b,k])),K=n.z.union([C,O,_,b,n.z.record(n.z.string(),C),n.z.array(C)]),rt=n.z.object({type:n.z.string().min(1,"Tool type is required"),description:n.z.string().optional(),params:K.optional(),outputs:K.optional(),options:n.z.record(n.z.string(),n.z.any()),execute:st.optional()}),X=n.z.object({name:n.z.string().min(1,"Name is required"),version:n.z.string().regex(/^\d+\.\d+\.\d+$/,"Version must be in format x.y.z"),headers:n.z.array(n.z.string()).optional(),authedFn:nt.optional(),transport:n.z.object({httpStream:n.z.object({enableJsonResponse:n.z.boolean().optional(),endpoint:n.z.string().regex(/^\/\w+/,"Endpoint must start with /").optional(),eventStore:n.z.any().optional(),host:n.z.string().optional(),port:n.z.number().int().min(1).max(65535),stateless:n.z.boolean().optional()}).optional(),transportType:n.z.enum(["httpStream","stdio"]).optional()}).partial(),tools:n.z.record(n.z.string(),rt)}).strict(),Rt=n.z.object({}).passthrough(),Y=n.z.object({url:n.z.string().url("Valid URL is required"),method:n.z.enum(["GET","POST","PUT","DELETE","PATCH"]).default("POST"),headers:n.z.record(n.z.string(),n.z.string()).default({}),timeout:n.z.number().int().positive().optional(),retry:n.z.object({attempts:n.z.number().int().min(1).max(10).default(3),backoff:n.z.number().positive().default(1000)}).optional()});function x(t,i,s){let e=t.safeParse(i);if(!e.success){let r=e.error.issues.map((o)=>({path:o.path.join("."),message:o.message,code:o.code,receivedValue:o.received,expected:o.expected})),d=s?`${s} validation failed:
1
+ var et=Object.create;var{getPrototypeOf:it,defineProperty:_,getOwnPropertyNames:B,getOwnPropertyDescriptor:nt}=Object,J=Object.prototype.hasOwnProperty;var I=(t,e,i)=>{i=t!=null?et(it(t)):{};let n=e||!t||!t.__esModule?_(i,"default",{value:t,enumerable:!0}):i;for(let r of B(t))if(!J.call(n,r))_(n,r,{get:()=>t[r],enumerable:!0});return n},D=new WeakMap,st=(t)=>{var e=D.get(t),i;if(e)return e;if(e=_({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")B(t).map((n)=>!J.call(e,n)&&_(e,n,{get:()=>t[n],enumerable:!(i=nt(t,n))||i.enumerable}));return D.set(t,e),e};var rt=(t,e)=>{for(var i in e)_(t,i,{get:e[i],enumerable:!0,configurable:!0,set:(n)=>e[i]=()=>n})};var ht={};rt(ht,{grpcAdapterConfigSchema:()=>j,graphqlAdapterConfigSchema:()=>U,defaultAdapterFactory:()=>F,McpProxy:()=>tt,HttpAdapter:()=>Q,GrpcAdapter:()=>V,GraphQLAdapter:()=>T,DefaultAdapterFactory:()=>W});module.exports=st(ht);var z=require("@kingecg/fastmcp");class O extends Error{code;statusCode;details;constructor(t,e,i,n){super(t);this.code=e;this.statusCode=i;this.details=n;this.name="MCPError"}}class C extends O{constructor(t,e){super(t,"VALIDATION_ERROR",400,e);this.name="ValidationError"}}class p extends O{constructor(t,e){super(t,"CONFIGURATION_ERROR",500,e);this.name="ConfigurationError"}}class f extends O{adapterName;constructor(t,e,i){super(t,"ADAPTER_ERROR",502,{adapterName:e,...i});this.adapterName=e;this.name="AdapterError"}}var yt=require("axios"),S=I(require("axios"));var s=require("zod");var ot=s.z.custom((t)=>typeof t==="function",{message:"authedFn must be a function that returns a Promise"}),ut=s.z.custom((t)=>typeof t==="function",{message:"execute must be a function"}),a=s.z.union([s.z.literal("string"),s.z.literal("number"),s.z.literal("boolean"),s.z.literal("any")]),v=s.z.string().regex(/^(string|number|boolean|any):/),b=s.z.object({type:a,description:s.z.string().optional()}),k=s.z.lazy(()=>s.z.object({type:s.z.literal("object"),description:s.z.string().optional(),properties:s.z.record(s.z.string(),s.z.union([a,b,k,m,v,s.z.record(s.z.string(),a),s.z.array(a)]))})),m=s.z.lazy(()=>s.z.object({type:s.z.literal("array"),description:s.z.string().optional(),items:s.z.union([a,b,k,m,v,s.z.record(s.z.string(),a),s.z.array(a)])})),X=s.z.lazy(()=>s.z.union([b,k,m,v])),K=s.z.union([a,b,k,m,s.z.record(s.z.string(),a),s.z.array(a)]),dt=s.z.object({type:s.z.string().min(1,"Tool type is required"),description:s.z.string().optional(),params:K.optional(),outputs:K.optional(),options:s.z.record(s.z.string(),s.z.any()),execute:ut.optional()}),Y=s.z.object({name:s.z.string().min(1,"Name is required"),version:s.z.string().regex(/^\d+\.\d+\.\d+$/,"Version must be in format x.y.z"),headers:s.z.array(s.z.string()).optional(),authedFn:ot.optional(),transport:s.z.object({httpStream:s.z.object({enableJsonResponse:s.z.boolean().optional(),endpoint:s.z.string().regex(/^\/\w+/,"Endpoint must start with /").optional(),eventStore:s.z.any().optional(),host:s.z.string().optional(),port:s.z.number().int().min(1).max(65535),stateless:s.z.boolean().optional()}).optional(),transportType:s.z.enum(["httpStream","stdio"]).optional()}).partial(),tools:s.z.record(s.z.string(),dt)}).strict(),at=s.z.object({}).passthrough(),Z=s.z.object({url:s.z.string().url("Valid URL is required"),method:s.z.enum(["GET","POST","PUT","DELETE","PATCH"]).default("POST"),headers:s.z.record(s.z.string(),s.z.string()).default({}),timeout:s.z.number().int().positive().optional(),retry:s.z.object({attempts:s.z.number().int().min(1).max(10).default(3),backoff:s.z.number().positive().default(1000)}).optional()});function x(t,e,i){let n=t.safeParse(e);if(!n.success){let r=n.error.issues.map((u)=>({path:u.path.join("."),message:u.message,code:u.code,receivedValue:u.received,expected:u.expected})),o=i?`${i} validation failed:
2
2
  `:`Validation failed:
3
- `;throw d+=e.error.issues.map((o,u)=>` ${u+1}. Field "${o.path.join(".")}" - ${o.message}`).join(`
4
- `),new c(d,{details:r})}return e.data}class Q{url="";method="POST";headers={};axiosConfig={};timeout;retryConfig;config(t){let i=x(Y,t,"HTTP adapter configuration");this.url=i.url,this.method=i.method,this.headers=i.headers,this.timeout=i.timeout,this.retryConfig=i.retry,this.axiosConfig={method:this.method,url:this.url,headers:this.headers,timeout:this.timeout}}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:i,backoff:s}=this.retryConfig,e;for(let r=1;r<=i;r++)try{return await t()}catch(d){if(e=d,r<i)await new Promise((o)=>setTimeout(o,s*r))}throw e}async call(t,i){let s=async()=>{let e={...this.axiosConfig};if(this.method.toUpperCase()==="GET")e.params=t;else e.data=t;try{return(await H.default.request(e)).data}catch(r){if(H.default.isAxiosError(r))throw new h(`HTTP request failed: ${r.message}`,"http",{url:this.url,method:this.method,statusCode:r.response?.status,responseData:r.response?.data});throw new h(`Request failed: ${r.message}`,"http",{url:this.url,method:this.method})}};return this.executeWithRetry(s)}}var T=q(require("axios"));var f=require("zod"),Z=f.z.object({endpoint:f.z.string().url("Valid GraphQL endpoint URL is required"),headers:f.z.record(f.z.string(),f.z.string()).default({}),timeout:f.z.number().int().positive().optional(),operationName:f.z.string().optional(),variables:f.z.record(f.z.string(),f.z.any()).optional(),retry:f.z.object({attempts:f.z.number().int().min(1).max(10).default(3),backoff:f.z.number().positive().default(1000)}).optional()});class V{adapterConfig=null;endpoint="";headers={};timeout;retryConfig;operationName;defaultVariables;config(t){this.adapterConfig=x(Z,t,"GraphQL adapter configuration"),this.endpoint=this.adapterConfig.endpoint,this.headers=this.adapterConfig.headers,this.timeout=this.adapterConfig.timeout,this.retryConfig=this.adapterConfig.retry,this.operationName=this.adapterConfig.operationName,this.defaultVariables=this.adapterConfig.variables}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:i,backoff:s}=this.retryConfig,e;for(let r=1;r<=i;r++)try{return await t()}catch(d){if(e=d,r<i)await new Promise((o)=>setTimeout(o,s*r))}throw e}async call(t,i){if(!this.adapterConfig)throw new h("GraphQL adapter not configured","graphql");let s=async()=>{try{let e=t.query||t.body||t.data;if(!e)throw new c("GraphQL query is required",{args:t});let r=t.variables||this.defaultVariables||{},d=t.operationName||this.operationName,o={query:typeof e==="string"?e:JSON.stringify(e),variables:r,operationName:d},u=await T.default.post(this.endpoint,o,{headers:{"Content-Type":"application/json",...this.headers},timeout:this.timeout});if(u.data.errors&&Array.isArray(u.data.errors)&&u.data.errors.length>0)throw new h(`GraphQL errors: ${u.data.errors.map((A)=>A.message).join(", ")}`,"graphql",{endpoint:this.endpoint,errors:u.data.errors});return u.data.data||u.data}catch(e){if(T.default.isAxiosError(e))throw new h(`GraphQL request failed: ${e.message}`,"graphql",{endpoint:this.endpoint,statusCode:e.response?.status,responseData:e.response?.data});if(e instanceof c||e instanceof h)throw e;throw new h(`GraphQL request failed: ${e.message}`,"graphql",{endpoint:this.endpoint})}};return this.executeWithRetry(s)}}var w=q(require("@grpc/grpc-js")),m=q(require("@grpc/proto-loader"));var R=require("zod"),M=R.z.object({protoPath:R.z.string().min(1,"Proto file path is required"),serviceName:R.z.string().min(1,"Service name is required"),methodName:R.z.string().min(1,"Method name is required"),address:R.z.string().min(1,"gRPC server address is required"),credentials:R.z.enum(["insecure","ssl"]).default("insecure"),timeout:R.z.number().int().positive().optional(),metadata:R.z.record(R.z.string(),R.z.string()).optional(),retry:R.z.object({attempts:R.z.number().int().min(1).max(10).default(3),backoff:R.z.number().positive().default(1000)}).optional()});class ${adapterConfig=null;client=null;packageDefinition=null;proto=null;config(t){this.adapterConfig=x(M,t,"gRPC adapter configuration"),this._loadProto()}_loadProto(){if(!this.adapterConfig)throw new h("gRPC adapter not configured","grpc");try{let{protoPath:t}=this.adapterConfig,i=m.loadSync(t,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0}),s=w.loadPackageDefinition(i);this.packageDefinition=s}catch(t){throw new h(`Failed to load proto file: ${t.message}`,"grpc",{protoPath:this.adapterConfig.protoPath})}}_getClient(){if(!this.adapterConfig||!this.packageDefinition)throw new h("gRPC adapter not properly configured","grpc");if(this.client)return this.client;let{serviceName:t,address:i,credentials:s}=this.adapterConfig;try{let e=t.split("."),r=this.packageDefinition;for(let o of e)if(r=r[o],!r)throw Error(`Service part '${o}' not found in proto definition`);let d=s==="ssl"?w.credentials.createSsl():w.credentials.createInsecure();return this.client=new r(i,d),this.client}catch(e){throw new h(`Failed to create gRPC client: ${e.message}`,"grpc",{serviceName:t,address:i})}}async executeWithRetry(t){if(!this.adapterConfig?.retry)return t();let{attempts:i,backoff:s}=this.adapterConfig.retry,e;for(let r=1;r<=i;r++)try{return await t()}catch(d){if(e=d,r<i)await new Promise((o)=>setTimeout(o,s*r))}throw e}async call(t,i){if(!this.adapterConfig)throw new h("gRPC adapter not configured","grpc");let s=async()=>{try{let e=this._getClient(),{methodName:r,metadata:d,timeout:o}=this.adapterConfig,u=new w.Metadata;if(d)Object.entries(d).forEach(([g,E])=>{u.add(g,E)});let A=e[r];if(typeof A!=="function")throw Error(`Method '${r}' not found on service`);return new Promise((g,E)=>{let l=o?Date.now()+o:void 0;A.call(e,t,u,{deadline:l},(L,D)=>{if(L)E(new h(`gRPC call failed: ${L.message}`,"grpc",{methodName:r,code:L.code,details:L.details}));else try{g(D)}catch(dt){g(String(D))}})})}catch(e){if(e instanceof h||e instanceof c)throw e;throw new h(`gRPC request failed: ${e.message}`,"grpc",{methodName:this.adapterConfig?.methodName,serviceName:this.adapterConfig?.serviceName})}};return this.executeWithRetry(s)}}class W{adapterRegistry=new Map;constructor(){this.registerDefaultAdapters()}registerDefaultAdapters(){this.registerAdapter("http",Q),this.registerAdapter("graphql",V),this.registerAdapter("grpc",$)}createAdapter(t,i){let s=this.adapterRegistry.get(t);if(!s)throw new p(`Unsupported adapter type: ${t}`,{supportedTypes:this.getSupportedTypes()});try{let e=new s;return e.config(i),e}catch(e){if(e instanceof p)throw e;throw new p(`Failed to create adapter of type '${t}': ${e.message}`,{adapterType:t,options:i})}}registerAdapter(t,i){if(this.adapterRegistry.has(t))throw new p(`Adapter type '${t}' is already registered`);this.adapterRegistry.set(t,i)}getSupportedTypes(){return Array.from(this.adapterRegistry.keys())}}var v=new W;var a=q(require("zod"));function U(t){let{name:i,version:s,headers:e,authedFn:r,transport:d,tools:o}=t,u={};if(o&&Object.keys(o).length>0)for(let g in o){let{params:E,outputs:l,...L}=o[g];if(u[g]={...L},E)u[g].params=y(E);if(l)u[g].outputs=y(l)}let A={transportType:"stdio"};if(d&&d.httpStream){if(!d.httpStream.endpoint)throw Error("transport.httpStream.endpoint is required");let g=d.httpStream.endpoint;if(!g.startsWith("/"))A={...d,httpStream:{...d.httpStream,endpoint:`/${g}`}};else A={...d,httpStream:{...d.httpStream,endpoint:g}}}return{name:i,version:s,headers:e,authedFn:r,transport:A,tools:u}}function y(t){if(Array.isArray(t)){if(t.length!==1)throw Error("Only one param is supported for array define");let e=y(t[0]);return a.default.array(e)}if(typeof t==="object"&&t!==null){if("type"in t)try{let r=S.parse(t),{type:d}=r;if(d==="object"){let o=t;return y(o.properties).describe(o.description||"")}else if(d==="array"){let o=t;return y(o.items).describe(o.description||"")}else return y(d).describe(t.description||"")}catch(r){throw Error(`Invalid param type: ${JSON.stringify(t)}`)}let e={};for(let r in t){let d=r.endsWith("?")?r.slice(0,-1):r,o=t[r],u=y(o);if(r.endsWith("?"))e[d]=u.optional();else e[d]=u}return a.default.object(e)}let i=t,s="";if(i.startsWith("string"))return s=i.slice(7),a.default.string().describe(s);if(i.startsWith("number"))return s=i.slice(7),a.default.number().describe(s);if(i.startsWith("boolean"))return s=i.slice(8),a.default.boolean().describe(s);if(i.startsWith("any"))return s=i.slice(4),a.default.any().describe(s);throw Error(`Unsupported param type: ${t}`)}class j{server=void 0;_toolhandlers={};validatedOptions;constructor(t){this.validatedOptions=U(x(X,t,"MCP configuration")),this._createMcpServer()}_createMcpServer(){let t=this.validatedOptions.version;this.server=new N.FastMCP({name:this.validatedOptions.name,version:t,authenticate:async(i)=>{let s={};if(this.validatedOptions.authedFn)s=await this.validatedOptions.authedFn(i);if(this.validatedOptions.headers)s.headers=this.validatedOptions.headers.map((e)=>i.headers[e]);return s}});for(let i in this.validatedOptions.tools){let s=this.validatedOptions.tools[i];if(s)this._registerTool(i,s)}}_registerTool(t,i){if(!i.type)throw new p(`Tool '${t}' must have a type`);try{let s=v.createAdapter(i.type,i.options);this._toolhandlers[t]=s,this.server.addTool({name:t,description:i.description,parameters:i.params,execute:async(e,r)=>{if(i.defaultParams&&typeof e==="object")e={...i.defaultParams,...e};return await s.call(e,r)}})}catch(s){if(s instanceof c||s instanceof p)throw new p(`Invalid configuration for tool '${t}': ${s.message}`,s.details);throw s}}_convertTransportForFastMCP(){let t={...this.validatedOptions.transport};if(t.httpStream){let i={...t.httpStream};if(i.endpoint)i.endpoint=i.endpoint;if(i.eventStore)i.eventStore=i.eventStore;return{...t,httpStream:i}}return t}async start(){if(!this.server)throw new p("Server not created");let t=this._convertTransportForFastMCP();await this.server.start(t)}}
3
+ `;throw o+=n.error.issues.map((u,d)=>` ${d+1}. Field "${u.path.join(".")}" - ${u.message}`).join(`
4
+ `),new C(o,{details:r})}return n.data}var L=I(require("lodash"));function q(t,e){switch(e.resultType){case"text":return ct(t,e);case"struct":return ft(t,e);default:return}}function ft(t,e){let i={type:"struct",structuredContent:{}};if(e.processMethod==="passThrough")i.structuredContent=t;if(e.processMethod==="selector"){if(typeof e.selector==="string")i.structuredContent=L.get(t,e.selector,null);else if(typeof e.selector==="object"&&e.selector)for(let n in e.selector){let r=e.selector[n]||".",o=L.get(t,r);L.set(i.structuredContent,n,o)}}return i}function ct(t,e){let i={text:t,type:"text"};if(e.processMethod==="selector")if(typeof e.selector!=="string")i.text="Error:For text content, selector must be a string";else{let n=L.get(t,e.selector);if(n)i.text=n;else i.text="Error:Selector not found"}else if(e.processMethod==="passThrough")i.text=typeof t==="string"?t:JSON.stringify(t);else if(e.processMethod==="fixedText"){if(e.fixedResponse)i.text=t instanceof Error?e.fixedResponse.error:e.fixedResponse.success}return i}class Q{url="";method="POST";headers={};axiosConfig={};timeout;retryConfig;resultRule;config(t,e=void 0){this.resultRule=e;let i=x(Z,t,"HTTP adapter configuration");this.url=i.url,this.method=i.method,this.headers=i.headers,this.timeout=i.timeout,this.retryConfig=i.retry,this.axiosConfig={method:this.method,url:this.url,headers:this.headers,timeout:this.timeout}}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:e,backoff:i}=this.retryConfig,n;for(let r=1;r<=e;r++)try{return await t()}catch(o){if(n=o,r<e)await new Promise((u)=>setTimeout(u,i*r))}throw n}async call(t,e){let i=async()=>{let n={...this.axiosConfig};if(this.method.toUpperCase()==="GET")n.params=t;else n.data=t;try{let o=(await S.default.request(n)).data;if(this.resultRule)return o=q(o,this.resultRule),o;return}catch(r){if(S.default.isAxiosError(r))throw new f(`HTTP request failed: ${r.message}`,"http",{url:this.url,method:this.method,statusCode:r.response?.status,responseData:r.response?.data});throw new f(`Request failed: ${r.message}`,"http",{url:this.url,method:this.method})}};return this.executeWithRetry(i)}}var H=I(require("axios"));var c=require("zod");var U=c.z.object({endpoint:c.z.string().url("Valid GraphQL endpoint URL is required"),headers:c.z.record(c.z.string(),c.z.string()).default({}),timeout:c.z.number().int().positive().optional(),operationName:c.z.string().optional(),variables:c.z.record(c.z.string(),c.z.any()).optional(),retry:c.z.object({attempts:c.z.number().int().min(1).max(10).default(3),backoff:c.z.number().positive().default(1000)}).optional()});class T{adapterConfig=null;endpoint="";headers={};timeout;retryConfig;operationName;defaultVariables;resultRule;config(t,e=void 0){this.resultRule=e,this.adapterConfig=x(U,t,"GraphQL adapter configuration"),this.endpoint=this.adapterConfig.endpoint,this.headers=this.adapterConfig.headers,this.timeout=this.adapterConfig.timeout,this.retryConfig=this.adapterConfig.retry,this.operationName=this.adapterConfig.operationName,this.defaultVariables=this.adapterConfig.variables}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:e,backoff:i}=this.retryConfig,n;for(let r=1;r<=e;r++)try{return await t()}catch(o){if(n=o,r<e)await new Promise((u)=>setTimeout(u,i*r))}throw n}async call(t,e){if(!this.adapterConfig)throw new f("GraphQL adapter not configured","graphql");let i=async()=>{try{let n=t.query||t.body||t.data;if(!n)throw new C("GraphQL query is required",{args:t});let r=t.variables||this.defaultVariables||{},o=t.operationName||this.operationName,u={query:typeof n==="string"?n:JSON.stringify(n),variables:r,operationName:o},d=await H.default.post(this.endpoint,u,{headers:{"Content-Type":"application/json",...this.headers},timeout:this.timeout});if(d.data.errors&&Array.isArray(d.data.errors)&&d.data.errors.length>0)throw new f(`GraphQL errors: ${d.data.errors.map((R)=>R.message).join(", ")}`,"graphql",{endpoint:this.endpoint,errors:d.data.errors});let g=d.data.data||d.data;if(this.resultRule)return g=q(g,this.resultRule),g;return}catch(n){if(H.default.isAxiosError(n))throw new f(`GraphQL request failed: ${n.message}`,"graphql",{endpoint:this.endpoint,statusCode:n.response?.status,responseData:n.response?.data});if(n instanceof C||n instanceof f)throw n;throw new f(`GraphQL request failed: ${n.message}`,"graphql",{endpoint:this.endpoint})}};return this.executeWithRetry(i)}}var y=I(require("@grpc/grpc-js")),N=I(require("@grpc/proto-loader"));var h=require("zod");var j=h.z.object({protoPath:h.z.string().min(1,"Proto file path is required"),serviceName:h.z.string().min(1,"Service name is required"),methodName:h.z.string().min(1,"Method name is required"),address:h.z.string().min(1,"gRPC server address is required"),credentials:h.z.enum(["insecure","ssl"]).default("insecure"),timeout:h.z.number().int().positive().optional(),metadata:h.z.record(h.z.string(),h.z.string()).optional(),retry:h.z.object({attempts:h.z.number().int().min(1).max(10).default(3),backoff:h.z.number().positive().default(1000)}).optional()});class V{adapterConfig=null;client=null;packageDefinition=null;proto=null;resultRule;config(t,e=void 0){this.resultRule=e,this.adapterConfig=x(j,t,"gRPC adapter configuration"),this._loadProto()}_loadProto(){if(!this.adapterConfig)throw new f("gRPC adapter not configured","grpc");try{let{protoPath:t}=this.adapterConfig,e=N.loadSync(t,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0}),i=y.loadPackageDefinition(e);this.packageDefinition=i}catch(t){throw new f(`Failed to load proto file: ${t.message}`,"grpc",{protoPath:this.adapterConfig.protoPath})}}_getClient(){if(!this.adapterConfig||!this.packageDefinition)throw new f("gRPC adapter not properly configured","grpc");if(this.client)return this.client;let{serviceName:t,address:e,credentials:i}=this.adapterConfig;try{let n=t.split("."),r=this.packageDefinition;for(let u of n)if(r=r[u],!r)throw Error(`Service part '${u}' not found in proto definition`);let o=i==="ssl"?y.credentials.createSsl():y.credentials.createInsecure();return this.client=new r(e,o),this.client}catch(n){throw new f(`Failed to create gRPC client: ${n.message}`,"grpc",{serviceName:t,address:e})}}async executeWithRetry(t){if(!this.adapterConfig?.retry)return t();let{attempts:e,backoff:i}=this.adapterConfig.retry,n;for(let r=1;r<=e;r++)try{return await t()}catch(o){if(n=o,r<e)await new Promise((u)=>setTimeout(u,i*r))}throw n}async call(t,e){if(!this.adapterConfig)throw new f("gRPC adapter not configured","grpc");let i=async()=>{try{let r=this._getClient(),{methodName:o,metadata:u,timeout:d}=this.adapterConfig,g=new y.Metadata;if(u)Object.entries(u).forEach(([A,E])=>{g.add(A,E)});let R=r[o];if(typeof R!=="function")throw Error(`Method '${o}' not found on service`);return new Promise((A,E)=>{let $=d?Date.now()+d:void 0;R.call(r,t,g,{deadline:$},(G,M)=>{if(G)E(new f(`gRPC call failed: ${G.message}`,"grpc",{methodName:o,code:G.code,details:G.details}));else try{A(M)}catch(Rt){A(String(M))}})})}catch(r){if(r instanceof f||r instanceof C)throw r;throw new f(`gRPC request failed: ${r.message}`,"grpc",{methodName:this.adapterConfig?.methodName,serviceName:this.adapterConfig?.serviceName})}},n=await this.executeWithRetry(i);if(this.resultRule)return n=q(n,this.resultRule),n;return}}class W{adapterRegistry=new Map;constructor(){this.registerDefaultAdapters()}registerDefaultAdapters(){this.registerAdapter("http",Q),this.registerAdapter("graphql",T),this.registerAdapter("grpc",V)}createAdapter(t,e,i){let n=this.adapterRegistry.get(t);if(!n)throw new p(`Unsupported adapter type: ${t}`,{supportedTypes:this.getSupportedTypes()});try{let r=new n;return r.config(e,i),r}catch(r){if(r instanceof p)throw r;throw new p(`Failed to create adapter of type '${t}': ${r.message}`,{adapterType:t,options:e})}}registerAdapter(t,e){if(this.adapterRegistry.has(t))throw new p(`Adapter type '${t}' is already registered`);this.adapterRegistry.set(t,e)}getSupportedTypes(){return Array.from(this.adapterRegistry.keys())}}var F=new W;var l=I(require("zod"));function P(t){let{name:e,version:i,headers:n,authedFn:r,transport:o,tools:u}=t,d={};if(u&&Object.keys(u).length>0)for(let R in u){let{params:A,outputs:E,...$}=u[R];if(d[R]={...$},A)d[R].params=w(A);if(E)d[R].outputs=w(E)}let g={transportType:"stdio"};if(o&&o.httpStream){if(!o.httpStream.endpoint)throw Error("transport.httpStream.endpoint is required");let R=o.httpStream.endpoint;if(!R.startsWith("/"))g={...o,httpStream:{...o.httpStream,endpoint:`/${R}`}};else g={...o,httpStream:{...o.httpStream,endpoint:R}}}return{name:e,version:i,headers:n,authedFn:r,transport:g,tools:d}}function w(t){if(Array.isArray(t)){if(t.length!==1)throw Error("Only one param is supported for array define");let n=w(t[0]);return l.default.array(n)}if(typeof t==="object"&&t!==null){if("type"in t)try{let r=X.parse(t),{type:o}=r;if(o==="object"){let u=t;return w(u.properties).describe(u.description||"")}else if(o==="array"){let u=t;return w(u.items).describe(u.description||"")}else return w(o).describe(t.description||"")}catch(r){throw Error(`Invalid param type: ${JSON.stringify(t)}`)}let n={};for(let r in t){let o=r.endsWith("?")?r.slice(0,-1):r,u=t[r],d=w(u);if(r.endsWith("?"))n[o]=d.optional();else n[o]=d}return l.default.object(n)}let e=t,i="";if(e.startsWith("string"))return i=e.slice(7),l.default.string().describe(i);if(e.startsWith("number"))return i=e.slice(7),l.default.number().describe(i);if(e.startsWith("boolean"))return i=e.slice(8),l.default.boolean().describe(i);if(e.startsWith("any"))return i=e.slice(4),l.default.any().describe(i);throw Error(`Unsupported param type: ${t}`)}class tt{server=void 0;_toolhandlers={};validatedOptions;constructor(t){this.validatedOptions=P(x(Y,t,"MCP configuration")),this._createMcpServer()}_createMcpServer(){let t=this.validatedOptions.version;this.server=new z.FastMCP({name:this.validatedOptions.name,version:t,authenticate:async(e)=>{let i={};if(this.validatedOptions.authedFn)i=await this.validatedOptions.authedFn(e);if(this.validatedOptions.headers)i.headers=this.validatedOptions.headers.map((n)=>e.headers[n]);return i}});for(let e in this.validatedOptions.tools){let i=this.validatedOptions.tools[e];if(i)this._registerTool(e,i)}}_registerTool(t,e){if(!e.type)throw new p(`Tool '${t}' must have a type`);try{if(!e.execute){let i=F.createAdapter(e.type,e.options,e.resultProcessRule);this._toolhandlers[t]=i}this.server.addTool({name:t,description:e.description,parameters:e.params,execute:async(i,n)=>{if(e.defaultParams&&typeof i==="object")i={...e.defaultParams,...i};if(e.execute)return await e.execute(i,n);if(this._toolhandlers[t])return await this._toolhandlers[t].call(i,n);return}})}catch(i){if(i instanceof C||i instanceof p)throw new p(`Invalid configuration for tool '${t}': ${i.message}`,i.details);throw i}}_convertTransportForFastMCP(){let t={...this.validatedOptions.transport};if(t.httpStream){let e={...t.httpStream};if(e.endpoint)e.endpoint=e.endpoint;if(e.eventStore)e.eventStore=e.eventStore;return{...t,httpStream:e}}return t}async start(){if(!this.server)throw new p("Server not created");let t=this._convertTransportForFastMCP();await this.server.start(t)}}
5
5
 
6
- //# debugId=956B7E442B73697D64756E2164756E21
6
+ //# debugId=3B088D6FA8793F8E64756E2164756E21
7
7
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../mpc-proxy.ts", "../../errors.ts", "../../adapters/http.ts", "../../validation.ts", "../../adapters/graphql.ts", "../../adapters/grpc.ts", "../../adapters/factory.ts", "../../config.ts"],
3
+ "sources": ["../../mpc-proxy.ts", "../../errors.ts", "../../adapters/http.ts", "../../validation.ts", "../../adapters/result.ts", "../../adapters/graphql.ts", "../../adapters/grpc.ts", "../../adapters/factory.ts", "../../config.ts"],
4
4
  "sourcesContent": [
5
- "import { FastMCP } from '@kingecg/fastmcp';\nimport { IncomingMessage } from 'http'\nimport * as types from './types';\nimport { defaultAdapterFactory } from './adapters/factory';\nimport { mcpOptionsSchema, validate, type ValidatedMcpOptions } from './validation';\nimport { ConfigurationError, ValidationError } from './errors';\nimport type { EventStore } from \"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js\";\nimport { convertParamsInConfig } from './config';\nimport type z from 'zod';\nexport class McpProxy {\n server: FastMCP|undefined = undefined\n private _toolhandlers: Record<string, types.ServiceAdapter> = {}\n private validatedOptions: ValidatedMcpOptions;\n \n constructor(options: z.infer<typeof mcpOptionsSchema>) {\n this.validatedOptions = convertParamsInConfig(validate(mcpOptionsSchema, options, 'MCP configuration'));\n this._createMcpServer()\n } \n \n _createMcpServer() { \n // 类型断言:验证已经确保version格式正确\n const version = this.validatedOptions.version as `${number}.${number}.${number}`;\n \n this.server = new FastMCP({\n name: this.validatedOptions.name,\n version: version,\n authenticate: async (req: IncomingMessage) => {\n let ret: Record<string, any> = {};\n if (this.validatedOptions.authedFn) {\n ret = await this.validatedOptions.authedFn(req);\n }\n if (this.validatedOptions.headers) {\n ret.headers = this.validatedOptions.headers.map(h => req.headers[h]);\n }\n return ret;\n }\n })\n \n for (const toolName in this.validatedOptions.tools) {\n const tool = this.validatedOptions.tools[toolName];\n if (tool) {\n this._registerTool(toolName, tool as types.ToolDefine);\n }\n }\n }\n \n private _registerTool(toolName: string, tool: types.ToolDefine) {\n if (!tool.type) {\n throw new ConfigurationError(`Tool '${toolName}' must have a type`);\n }\n \n try {\n const adapter = defaultAdapterFactory.createAdapter(tool.type, tool.options);\n this._toolhandlers[toolName] = adapter;\n \n this.server!.addTool({\n name: toolName,\n description: tool.description,\n parameters: tool.params,\n execute: async (args, context) => {\n if(tool.defaultParams && typeof args === 'object'){\n args = {...tool.defaultParams, ...args};\n }\n return await adapter.call(args, context);\n } \n });\n } catch (error) {\n if (error instanceof ValidationError || error instanceof ConfigurationError) {\n throw new ConfigurationError(\n `Invalid configuration for tool '${toolName}': ${error.message}`,\n (error as any).details\n );\n }\n throw error;\n }\n }\n \n private _convertTransportForFastMCP(): Partial<{\n httpStream: {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n };\n transportType: \"httpStream\" | \"stdio\";\n }> {\n const transport = { ...this.validatedOptions.transport };\n \n if (transport.httpStream) {\n const httpStream = { ...transport.httpStream };\n if (httpStream.endpoint) {\n // 类型转换:验证已经确保endpoint以/开头\n httpStream.endpoint = httpStream.endpoint as `/${string}`;\n }\n if (httpStream.eventStore) {\n httpStream.eventStore = httpStream.eventStore as EventStore;\n }\n \n return {\n ...transport,\n httpStream: httpStream as {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n }\n };\n }\n \n return transport as any;\n }\n \n async start() {\n if(!this.server){\n throw new ConfigurationError('Server not created');\n }\n const convertedTransport = this._convertTransportForFastMCP();\n await this.server.start(convertedTransport);\n }\n}",
5
+ "import { FastMCP } from '@kingecg/fastmcp';\nimport { IncomingMessage } from 'http'\nimport * as types from './types';\nimport { defaultAdapterFactory } from './adapters/factory';\nimport { mcpOptionsSchema, validate, type ValidatedMcpOptions } from './validation';\nimport { ConfigurationError, ValidationError } from './errors';\nimport type { EventStore } from \"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js\";\nimport { convertParamsInConfig } from './config';\nimport type z from 'zod';\nexport class McpProxy {\n server: FastMCP|undefined = undefined\n private _toolhandlers: Record<string, types.ServiceAdapter> = {}\n private validatedOptions: ValidatedMcpOptions;\n \n constructor(options: z.infer<typeof mcpOptionsSchema>) {\n this.validatedOptions = convertParamsInConfig(validate(mcpOptionsSchema, options, 'MCP configuration'));\n this._createMcpServer()\n } \n \n _createMcpServer() { \n // 类型断言:验证已经确保version格式正确\n const version = this.validatedOptions.version as `${number}.${number}.${number}`;\n \n this.server = new FastMCP({\n name: this.validatedOptions.name,\n version: version,\n authenticate: async (req: IncomingMessage) => {\n let ret: Record<string, any> = {};\n if (this.validatedOptions.authedFn) {\n ret = await this.validatedOptions.authedFn(req);\n }\n if (this.validatedOptions.headers) {\n ret.headers = this.validatedOptions.headers.map(h => req.headers[h]);\n }\n return ret;\n }\n })\n \n for (const toolName in this.validatedOptions.tools) {\n const tool = this.validatedOptions.tools[toolName];\n if (tool) {\n this._registerTool(toolName, tool as types.ToolDefine);\n }\n }\n }\n \n private _registerTool(toolName: string, tool: types.ToolDefine) {\n if (!tool.type) {\n throw new ConfigurationError(`Tool '${toolName}' must have a type`);\n }\n \n try {\n if(!tool.execute){\n const adapter = defaultAdapterFactory.createAdapter(tool.type, tool.options, tool.resultProcessRule);\n this._toolhandlers[toolName] = adapter;\n }\n \n \n this.server!.addTool({\n name: toolName,\n description: tool.description,\n parameters: tool.params,\n execute: async (args, context) => {\n if(tool.defaultParams && typeof args === 'object'){\n args = {...tool.defaultParams, ...args};\n }\n if(tool.execute){\n return await tool.execute(args, context);\n }\n if( this._toolhandlers[toolName]){\n const adapter = this._toolhandlers[toolName];\n return await adapter.call(args, context);\n }\n return\n } \n });\n } catch (error) {\n if (error instanceof ValidationError || error instanceof ConfigurationError) {\n throw new ConfigurationError(\n `Invalid configuration for tool '${toolName}': ${error.message}`,\n (error as any).details\n );\n }\n throw error;\n }\n }\n \n private _convertTransportForFastMCP(): Partial<{\n httpStream: {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n };\n transportType: \"httpStream\" | \"stdio\";\n }> {\n const transport = { ...this.validatedOptions.transport };\n \n if (transport.httpStream) {\n const httpStream = { ...transport.httpStream };\n if (httpStream.endpoint) {\n // 类型转换:验证已经确保endpoint以/开头\n httpStream.endpoint = httpStream.endpoint as `/${string}`;\n }\n if (httpStream.eventStore) {\n httpStream.eventStore = httpStream.eventStore as EventStore;\n }\n \n return {\n ...transport,\n httpStream: httpStream as {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n }\n };\n }\n \n return transport as any;\n }\n \n async start() {\n if(!this.server){\n throw new ConfigurationError('Server not created');\n }\n const convertedTransport = this._convertTransportForFastMCP();\n await this.server.start(convertedTransport);\n }\n}",
6
6
  "export class MCPError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly statusCode?: number,\n public readonly details?: Record<string, any>\n ) {\n super(message);\n this.name = 'MCPError';\n }\n}\n\nexport class ValidationError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'VALIDATION_ERROR', 400, details);\n this.name = 'ValidationError';\n }\n}\n\nexport class ConfigurationError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'CONFIGURATION_ERROR', 500, details);\n this.name = 'ConfigurationError';\n }\n}\n\nexport class AdapterError extends MCPError {\n constructor(message: string, public readonly adapterName: string, details?: Record<string, any>) {\n super(message, 'ADAPTER_ERROR', 502, { adapterName, ...details });\n this.name = 'AdapterError';\n }\n}\n\nexport class AuthenticationError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'AUTHENTICATION_ERROR', 401, details);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class RateLimitError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'RATE_LIMIT_ERROR', 429, details);\n this.name = 'RateLimitError';\n }\n}\n\nexport type ErrorType = \n | 'VALIDATION_ERROR'\n | 'CONFIGURATION_ERROR'\n | 'ADAPTER_ERROR'\n | 'AUTHENTICATION_ERROR'\n | 'RATE_LIMIT_ERROR'\n | 'INTERNAL_ERROR';",
7
- "import 'axios'\nimport type {AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent, ToolParameters} from '@kingecg/fastmcp'\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ServiceAdapter } from '../types';\nimport type { AxiosRequestConfig } from 'axios';\nimport axios from 'axios';\nimport { httpAdapterConfigSchema, validate } from '../validation';\nimport { AdapterError } from '../errors';\n\nexport class HttpAdapter implements ServiceAdapter {\n private url: string = '';\n private method = 'POST';\n private headers: Record<string, string> = {}; \n private axiosConfig :AxiosRequestConfig = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n \n config(option: Record<string, any>) {\n const validatedConfig = validate(httpAdapterConfigSchema, option, 'HTTP adapter configuration');\n \n this.url = validatedConfig.url;\n this.method = validatedConfig.method; \n this.headers = validatedConfig.headers;\n this.timeout = validatedConfig.timeout;\n this.retryConfig = validatedConfig.retry;\n \n this.axiosConfig = {\n method: this.method,\n url: this.url,\n headers: this.headers,\n timeout: this.timeout\n };\n }\n \n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n \n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n \n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n \n if (attempt < attempts) {\n await new Promise(resolve => setTimeout(resolve, backoff * attempt));\n }\n }\n }\n \n throw lastError!;\n }\n \n async call(args: StandardSchemaV1.InferOutput<any>, context: Context<any>): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void> {\n const executeRequest = async () => {\n const axiosConfig = {...this.axiosConfig};\n \n if (this.method.toUpperCase() === 'GET') {\n axiosConfig.params = args;\n } else {\n axiosConfig.data = args;\n }\n \n try {\n const response = await axios.request(axiosConfig);\n return response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `HTTP request failed: ${error.message}`,\n 'http',\n {\n url: this.url,\n method: this.method,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n }\n );\n }\n throw new AdapterError(\n `Request failed: ${(error as Error).message}`,\n 'http',\n { url: this.url, method: this.method }\n );\n }\n };\n \n return this.executeWithRetry(executeRequest);\n }\n}",
7
+ "import \"axios\";\nimport type {\n AudioContent,\n ContentResult,\n Context,\n ImageContent,\n ResourceContent,\n ResourceLink,\n TextContent,\n ToolParameters,\n} from \"@kingecg/fastmcp\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ResultProcessRule, ServiceAdapter } from \"../types\";\nimport type { AxiosRequestConfig } from \"axios\";\nimport axios from \"axios\";\nimport { httpAdapterConfigSchema, validate } from \"../validation\";\nimport { AdapterError } from \"../errors\";\nimport { makeResponseContent } from \"./result\";\n\nexport class HttpAdapter implements ServiceAdapter {\n private url: string = \"\";\n private method = \"POST\";\n private headers: Record<string, string> = {};\n private axiosConfig: AxiosRequestConfig = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n private resultRule?: ResultProcessRule;\n config(\n option: Record<string, any>,\n rule: ResultProcessRule | undefined = undefined,\n ) {\n this.resultRule = rule;\n const validatedConfig = validate(\n httpAdapterConfigSchema,\n option,\n \"HTTP adapter configuration\",\n );\n\n this.url = validatedConfig.url;\n this.method = validatedConfig.method;\n this.headers = validatedConfig.headers;\n this.timeout = validatedConfig.timeout;\n this.retryConfig = validatedConfig.retry;\n\n this.axiosConfig = {\n method: this.method,\n url: this.url,\n headers: this.headers,\n timeout: this.timeout,\n };\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n\n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt < attempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, backoff * attempt),\n );\n }\n }\n }\n\n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>,\n context: Context<any>,\n ): Promise<\n | AudioContent\n | ContentResult\n | ImageContent\n | ResourceContent\n | ResourceLink\n | string\n | TextContent\n | void\n > {\n const executeRequest = async () => {\n const axiosConfig = { ...this.axiosConfig };\n\n if (this.method.toUpperCase() === \"GET\") {\n axiosConfig.params = args;\n } else {\n axiosConfig.data = args;\n }\n\n try {\n const response = await axios.request(axiosConfig);\n let result = response.data;\n if (this.resultRule) {\n result = makeResponseContent(result, this.resultRule);\n return result;\n }\n return;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `HTTP request failed: ${error.message}`,\n \"http\",\n {\n url: this.url,\n method: this.method,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n },\n );\n }\n throw new AdapterError(\n `Request failed: ${(error as Error).message}`,\n \"http\",\n { url: this.url, method: this.method },\n );\n }\n };\n\n return this.executeWithRetry(executeRequest);\n }\n}\n",
8
8
  "import { z } from 'zod';\nimport { ValidationError } from './errors';\nimport type { IncomingMessage } from 'http';\n\n// 自定义验证器用于authenticate函数\nconst authenticateSchema = z.custom<\n (request: IncomingMessage) => Promise<Record<string, any>>\n>((val) => typeof val === 'function', {\n message: 'authedFn must be a function that returns a Promise',\n});\n\n// 自定义验证器用于工具执行函数\nconst toolExecuteSchema = z.custom<\n (args: any, context: any) => Promise<any>\n>((val) => typeof val === 'function', {\n message: 'execute must be a function',\n});\nexport const ParamTypeUnion:z.ZodType= z.union([\n z.literal('string'),\n z.literal('number'),\n z.literal('boolean'),\n z.literal('any')\n])\nexport const AbbToolParamType:z.ZodType= z.string().regex(/^(string|number|boolean|any):/)\nexport const ParamTypObject:z.ZodType= z.object({\n type: ParamTypeUnion,\n description: z.string().optional()\n})\nexport const ParamObjectType:z.ZodType= z.lazy(()=>z.object({\n type: z.literal('object'),\n description: z.string().optional(),\n properties: z.record(z.string(), z.union([ ParamTypeUnion,\n ParamTypObject, \n ParamObjectType,\n ParamArrayType,\n AbbToolParamType,\n z.record(z.string(),ParamTypeUnion),\n z.array(ParamTypeUnion)]))\n}) )\nexport const ParamArrayType:z.ZodType= z.lazy(()=>z.object({\n type: z.literal('array'),\n description: z.string().optional(),\n items: z.union([ ParamTypeUnion,\n ParamTypObject, \n ParamObjectType,\n ParamArrayType,\n AbbToolParamType,\n z.record(z.string(),ParamTypeUnion),\n z.array(ParamTypeUnion)])}));\n\nexport const RegularDefineSchema = z.lazy(()=>z.union([\n ParamTypObject,\n ParamObjectType,\n ParamArrayType,\n AbbToolParamType\n]))\nexport const ToolParamSchema = z.union([\n ParamTypeUnion,\n ParamTypObject, \n ParamObjectType,\n ParamArrayType,\n z.record(z.string(),ParamTypeUnion),\n z.array(ParamTypeUnion)\n])\nexport const ToolDefineSchema = z.object({\n type: z.string().min(1, 'Tool type is required'),\n description: z.string().optional(),\n params: ToolParamSchema.optional(), // ToolParameters from fastmcp\n outputs: ToolParamSchema.optional(),\n options: z.record(z.string(), z.any()),\n execute: toolExecuteSchema.optional(),\n});\n// MCP配置验证\nexport const mcpOptionsSchema = z.object({\n name: z.string().min(1, 'Name is required'),\n version: z.string().regex(/^\\d+\\.\\d+\\.\\d+$/, 'Version must be in format x.y.z'),\n headers: z.array(z.string()).optional(),\n authedFn: authenticateSchema.optional(),\n transport: z.object({\n httpStream: z.object({\n enableJsonResponse: z.boolean().optional(),\n endpoint: z.string().regex(/^\\/\\w+/, 'Endpoint must start with /').optional(),\n eventStore: z.any().optional(),\n host: z.string().optional(),\n port: z.number().int().min(1).max(65535),\n stateless: z.boolean().optional(),\n }).optional(),\n transportType: z.enum(['httpStream', 'stdio']).optional(),\n }).partial(),\n tools: z.record(z.string(), ToolDefineSchema),\n}).strict();\n\n// 工具参数验证基础模式\nexport const toolParamsSchema = z.object({}).passthrough(); // 允许任意参数,但可以进一步约束\n\n// HTTP适配器配置验证\nexport const httpAdapterConfigSchema = z.object({\n url: z.string().url('Valid URL is required'),\n method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).default('POST'),\n headers: z.record(z.string(), z.string()).default({}),\n timeout: z.number().int().positive().optional(),\n retry: z.object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n }).optional(),\n});\n\n// 通用验证函数\nexport function validate<T>(schema: z.ZodSchema<T>, data: unknown, context?: string): T {\n const result = schema.safeParse(data);\n \n if (!result.success) {\n const details = result.error.issues.map((err: any) => ({\n path: err.path.join('.'),\n message: err.message,\n code: err.code,\n receivedValue: err.received,\n expected: err.expected,\n }));\n \n // 构建更友好的错误消息,包含所有错误细节\n let message = context \n ? `${context} validation failed:\\n`\n : 'Validation failed:\\n';\n \n message += result.error.issues.map((err: any, index: number) => \n ` ${index + 1}. Field \"${err.path.join('.')}\" - ${err.message}`\n ).join('\\n');\n \n throw new ValidationError(message, { details });\n }\n \n return result.data;\n}\n\n// 类型推断\nexport type ValidatedMcpOptions = z.infer<typeof mcpOptionsSchema>;\nexport type ValidatedHttpAdapterConfig = z.infer<typeof httpAdapterConfigSchema>;",
9
- "import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '@kingecg/fastmcp';\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ServiceAdapter } from '../types';\nimport axios from 'axios';\nimport { validate } from '../validation';\nimport { AdapterError, ValidationError } from '../errors';\nimport { z } from 'zod';\n\n// GraphQL适配器配置验证\nexport const graphqlAdapterConfigSchema = z.object({\n endpoint: z.string().url('Valid GraphQL endpoint URL is required'),\n headers: z.record(z.string(), z.string()).default({}),\n timeout: z.number().int().positive().optional(),\n // GraphQL特定配置\n operationName: z.string().optional(),\n variables: z.record(z.string(), z.any()).optional(),\n // 重试配置\n retry: z.object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n }).optional(),\n});\n\nexport type GraphQLAdapterConfig = z.infer<typeof graphqlAdapterConfigSchema>;\n\nexport class GraphQLAdapter implements ServiceAdapter {\n private adapterConfig: GraphQLAdapterConfig | null = null;\n private endpoint: string = '';\n private headers: Record<string, string> = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n private operationName?: string;\n private defaultVariables?: Record<string, any>;\n\n config(options: Record<string, any>): void {\n this.adapterConfig = validate(graphqlAdapterConfigSchema, options, 'GraphQL adapter configuration');\n \n this.endpoint = this.adapterConfig.endpoint;\n this.headers = this.adapterConfig.headers;\n this.timeout = this.adapterConfig.timeout;\n this.retryConfig = this.adapterConfig.retry;\n this.operationName = this.adapterConfig.operationName;\n this.defaultVariables = this.adapterConfig.variables;\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n \n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n \n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n \n if (attempt < attempts) {\n await new Promise(resolve => setTimeout(resolve, backoff * attempt));\n }\n }\n }\n \n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>, \n context: Context<any>\n ): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void> {\n if (!this.adapterConfig) {\n throw new AdapterError('GraphQL adapter not configured', 'graphql');\n }\n\n const executeRequest = async () => {\n try {\n // 解析GraphQL查询和变量\n const query = args.query || args.body || args.data;\n if (!query) {\n throw new ValidationError('GraphQL query is required', { args });\n }\n\n const variables = args.variables || this.defaultVariables || {};\n const operationName = args.operationName || this.operationName;\n\n const graphqlRequest = {\n query: typeof query === 'string' ? query : JSON.stringify(query),\n variables,\n operationName,\n };\n\n const response = await axios.post(this.endpoint, graphqlRequest, {\n headers: {\n 'Content-Type': 'application/json',\n ...this.headers,\n },\n timeout: this.timeout,\n });\n\n // 检查GraphQL错误\n if (response.data.errors && Array.isArray(response.data.errors) && response.data.errors.length > 0) {\n throw new AdapterError(\n `GraphQL errors: ${response.data.errors.map((e: any) => e.message).join(', ')}`,\n 'graphql',\n {\n endpoint: this.endpoint,\n errors: response.data.errors,\n }\n );\n }\n\n return response.data.data || response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `GraphQL request failed: ${error.message}`,\n 'graphql',\n {\n endpoint: this.endpoint,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n }\n );\n }\n \n if (error instanceof ValidationError || error instanceof AdapterError) {\n throw error;\n }\n \n throw new AdapterError(\n `GraphQL request failed: ${(error as Error).message}`,\n 'graphql',\n { endpoint: this.endpoint }\n );\n }\n };\n\n return this.executeWithRetry(executeRequest);\n }\n}",
10
- "import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '@kingecg/fastmcp';\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ServiceAdapter } from '../types';\nimport * as grpc from '@grpc/grpc-js';\nimport * as protoLoader from '@grpc/proto-loader';\nimport { validate } from '../validation';\nimport { AdapterError, ValidationError } from '../errors';\nimport { z } from 'zod';\n\n// gRPC适配器配置验证\nexport const grpcAdapterConfigSchema = z.object({\n protoPath: z.string().min(1, 'Proto file path is required'),\n serviceName: z.string().min(1, 'Service name is required'),\n methodName: z.string().min(1, 'Method name is required'),\n address: z.string().min(1, 'gRPC server address is required'),\n // 连接选项\n credentials: z.enum(['insecure', 'ssl']).default('insecure'),\n timeout: z.number().int().positive().optional(),\n // 元数据\n metadata: z.record(z.string(), z.string()).optional(),\n // 重试配置\n retry: z.object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n }).optional(),\n});\n\nexport type GrpcAdapterConfig = z.infer<typeof grpcAdapterConfigSchema>;\n\nexport class GrpcAdapter implements ServiceAdapter {\n private adapterConfig: GrpcAdapterConfig | null = null;\n private client: any = null;\n private packageDefinition: any = null;\n private proto: any = null;\n \n config(options: Record<string, any>): void {\n this.adapterConfig = validate(grpcAdapterConfigSchema, options, 'gRPC adapter configuration');\n this._loadProto();\n }\n \n private _loadProto(): void {\n if (!this.adapterConfig) {\n throw new AdapterError('gRPC adapter not configured', 'grpc');\n }\n \n try {\n const { protoPath } = this.adapterConfig;\n const packageDefinition = protoLoader.loadSync(protoPath, {\n keepCase: true,\n longs: String,\n enums: String,\n defaults: true,\n oneofs: true,\n });\n \n const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);\n this.packageDefinition = protoDescriptor;\n } catch (error) {\n throw new AdapterError(\n `Failed to load proto file: ${(error as Error).message}`,\n 'grpc',\n { protoPath: this.adapterConfig.protoPath }\n );\n }\n }\n \n private _getClient(): any {\n if (!this.adapterConfig || !this.packageDefinition) {\n throw new AdapterError('gRPC adapter not properly configured', 'grpc');\n }\n \n if (this.client) {\n return this.client;\n }\n \n const { serviceName, address, credentials } = this.adapterConfig;\n \n try {\n // 解析服务名称(格式:package.Service)\n const servicePath = serviceName.split('.');\n let service = this.packageDefinition;\n \n for (const part of servicePath) {\n service = service[part];\n if (!service) {\n throw new Error(`Service part '${part}' not found in proto definition`);\n }\n }\n \n // 创建gRPC客户端\n const credentialsType = credentials === 'ssl' \n ? grpc.credentials.createSsl()\n : grpc.credentials.createInsecure();\n \n this.client = new service(address, credentialsType);\n return this.client;\n } catch (error) {\n throw new AdapterError(\n `Failed to create gRPC client: ${(error as Error).message}`,\n 'grpc',\n { serviceName, address }\n );\n }\n }\n \n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.adapterConfig?.retry) {\n return fn();\n }\n \n const { attempts, backoff } = this.adapterConfig.retry;\n let lastError: Error;\n \n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n \n if (attempt < attempts) {\n await new Promise(resolve => setTimeout(resolve, backoff * attempt));\n }\n }\n }\n \n throw lastError!;\n }\n \n async call(\n args: StandardSchemaV1.InferOutput<any>, \n context: Context<any>\n ): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void> {\n if (!this.adapterConfig) {\n throw new AdapterError('gRPC adapter not configured', 'grpc');\n }\n \n const executeRequest = async () => {\n try {\n const client = this._getClient();\n const { methodName, metadata, timeout } = this.adapterConfig!;\n \n // 准备请求元数据\n const grpcMetadata = new grpc.Metadata();\n if (metadata) {\n Object.entries(metadata).forEach(([key, value]) => {\n grpcMetadata.add(key, value);\n });\n }\n \n // 查找方法\n const method = client[methodName];\n if (typeof method !== 'function') {\n throw new Error(`Method '${methodName}' not found on service`);\n }\n \n // 执行gRPC调用\n return new Promise<any>((resolve, reject) => {\n const deadline = timeout ? Date.now() + timeout : undefined;\n \n method.call(\n client,\n args,\n grpcMetadata,\n { deadline },\n (error: any, response: any) => {\n if (error) {\n reject(new AdapterError(\n `gRPC call failed: ${error.message}`,\n 'grpc',\n {\n methodName,\n code: error.code,\n details: error.details,\n }\n ));\n } else {\n // 尝试将响应转换为可序列化的格式\n try {\n // 如果是普通对象或数组,直接返回\n resolve(response);\n } catch (serializationError) {\n // 如果无法序列化,返回字符串表示\n resolve(String(response));\n }\n }\n }\n );\n });\n } catch (error) {\n if (error instanceof AdapterError || error instanceof ValidationError) {\n throw error;\n }\n \n throw new AdapterError(\n `gRPC request failed: ${(error as Error).message}`,\n 'grpc',\n {\n methodName: this.adapterConfig?.methodName,\n serviceName: this.adapterConfig?.serviceName,\n }\n );\n }\n };\n \n return this.executeWithRetry(executeRequest);\n }\n}",
11
- "import type { ServiceAdapter, AdapterFactory } from '../types';\nimport { ConfigurationError } from '../errors';\nimport { HttpAdapter } from './http';\nimport { GraphQLAdapter } from './graphql';\nimport { GrpcAdapter } from './grpc';\n\nexport class DefaultAdapterFactory implements AdapterFactory {\n private adapterRegistry: Map<string, new () => ServiceAdapter> = new Map();\n \n constructor() {\n this.registerDefaultAdapters();\n }\n \n private registerDefaultAdapters() {\n // 默认注册HTTP适配器\n this.registerAdapter('http', HttpAdapter);\n // 注册GraphQL适配器\n this.registerAdapter('graphql', GraphQLAdapter);\n // 注册gRPC适配器\n this.registerAdapter('grpc', GrpcAdapter);\n }\n \n createAdapter(type: string, options: Record<string, any>): ServiceAdapter {\n const AdapterClass = this.adapterRegistry.get(type);\n \n if (!AdapterClass) {\n throw new ConfigurationError(\n `Unsupported adapter type: ${type}`,\n { supportedTypes: this.getSupportedTypes() }\n );\n }\n \n try {\n const adapter = new AdapterClass();\n adapter.config(options);\n return adapter;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n throw new ConfigurationError(\n `Failed to create adapter of type '${type}': ${(error as Error).message}`,\n { adapterType: type, options }\n );\n }\n }\n \n registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void {\n if (this.adapterRegistry.has(type)) {\n throw new ConfigurationError(`Adapter type '${type}' is already registered`);\n }\n this.adapterRegistry.set(type, adapterClass);\n }\n \n getSupportedTypes(): string[] {\n return Array.from(this.adapterRegistry.keys());\n }\n}\n\n// 默认工厂实例\nexport const defaultAdapterFactory = new DefaultAdapterFactory();",
9
+ "import type {\n AudioContent,\n ContentResult,\n TextContent,\n StructContent,\n ImageContent,\n} from \"@kingecg/fastmcp\";\nimport type { ResultProcessRule } from \"../types\";\nimport * as _ from \"lodash\";\n\nexport function makeMediaContent(\n result: string | Buffer,\n mimeType: string,\n): AudioContent | ImageContent {\n return result instanceof Buffer\n ? {\n data: result.toString(\"base64\"),\n mimeType,\n type: mimeType.startsWith(\"image\") ? \"image\" : \"audio\",\n }\n : {\n data: result as string,\n mimeType,\n type: mimeType.startsWith(\"image\") ? \"image\" : \"audio\",\n };\n}\nexport function makeResponseContent(\n result: any,\n rule: ResultProcessRule,\n): TextContent | StructContent | void {\n switch (rule.resultType) {\n case \"text\":\n return makeTextContent(result, rule);\n case \"struct\":\n return makeStructContent(result, rule);\n default:\n return;\n }\n}\nfunction makeStructContent(result: any, rule: ResultProcessRule) {\n const content: StructContent = {\n type: \"struct\",\n structuredContent: {},\n };\n if (rule.processMethod === \"passThrough\") {\n content.structuredContent = result;\n }\n if (rule.processMethod === \"selector\") {\n if (typeof rule.selector === \"string\") {\n content.structuredContent = _.get(result, rule.selector, null);\n } else if (typeof rule.selector === \"object\" && rule.selector) {\n for (const key in rule.selector) {\n const propertyPath = rule.selector[key] || \".\";\n const value = _.get(result, propertyPath);\n _.set(content.structuredContent, key, value);\n }\n }\n }\n return content;\n}\n\nfunction makeTextContent(result: any, rule: ResultProcessRule): TextContent {\n let content: TextContent = {\n text: result,\n type: \"text\" as const,\n };\n if (rule.processMethod === \"selector\") {\n if (typeof rule.selector !== \"string\") {\n content.text = \"Error:For text content, selector must be a string\";\n } else {\n const selector = _.get(result, rule.selector);\n if (selector) {\n content.text = selector;\n } else {\n content.text = \"Error:Selector not found\";\n }\n }\n } else if (rule.processMethod === \"passThrough\") {\n content.text = typeof result === \"string\" ? result : JSON.stringify(result);\n } else if (rule.processMethod === \"fixedText\") {\n if (rule.fixedResponse) {\n content.text =\n result instanceof Error\n ? rule.fixedResponse.error\n : rule.fixedResponse.success;\n }\n }\n return content;\n}\n",
10
+ "import type {\n AudioContent,\n ContentResult,\n Context,\n ImageContent,\n ResourceContent,\n ResourceLink,\n TextContent,\n} from \"@kingecg/fastmcp\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ResultProcessRule, ServiceAdapter } from \"../types\";\nimport axios from \"axios\";\nimport { validate } from \"../validation\";\nimport { AdapterError, ValidationError } from \"../errors\";\nimport { z } from \"zod\";\nimport { makeResponseContent } from \"./result\";\n\n// GraphQL适配器配置验证\nexport const graphqlAdapterConfigSchema = z.object({\n endpoint: z.string().url(\"Valid GraphQL endpoint URL is required\"),\n headers: z.record(z.string(), z.string()).default({}),\n timeout: z.number().int().positive().optional(),\n // GraphQL特定配置\n operationName: z.string().optional(),\n variables: z.record(z.string(), z.any()).optional(),\n // 重试配置\n retry: z\n .object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n })\n .optional(),\n});\n\nexport type GraphQLAdapterConfig = z.infer<typeof graphqlAdapterConfigSchema>;\n\nexport class GraphQLAdapter implements ServiceAdapter {\n private adapterConfig: GraphQLAdapterConfig | null = null;\n private endpoint: string = \"\";\n private headers: Record<string, string> = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n private operationName?: string;\n private defaultVariables?: Record<string, any>;\n private resultRule?: ResultProcessRule;\n\n config(\n options: Record<string, any>,\n rule: ResultProcessRule | undefined = undefined,\n ): void {\n this.resultRule = rule;\n this.adapterConfig = validate(\n graphqlAdapterConfigSchema,\n options,\n \"GraphQL adapter configuration\",\n );\n\n this.endpoint = this.adapterConfig.endpoint;\n this.headers = this.adapterConfig.headers;\n this.timeout = this.adapterConfig.timeout;\n this.retryConfig = this.adapterConfig.retry;\n this.operationName = this.adapterConfig.operationName;\n this.defaultVariables = this.adapterConfig.variables;\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n\n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt < attempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, backoff * attempt),\n );\n }\n }\n }\n\n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>,\n context: Context<any>,\n ): Promise<\n | AudioContent\n | ContentResult\n | ImageContent\n | ResourceContent\n | ResourceLink\n | string\n | TextContent\n | void\n > {\n if (!this.adapterConfig) {\n throw new AdapterError(\"GraphQL adapter not configured\", \"graphql\");\n }\n\n const executeRequest = async () => {\n try {\n // 解析GraphQL查询和变量\n const query = args.query || args.body || args.data;\n if (!query) {\n throw new ValidationError(\"GraphQL query is required\", { args });\n }\n\n const variables = args.variables || this.defaultVariables || {};\n const operationName = args.operationName || this.operationName;\n\n const graphqlRequest = {\n query: typeof query === \"string\" ? query : JSON.stringify(query),\n variables,\n operationName,\n };\n\n const response = await axios.post(this.endpoint, graphqlRequest, {\n headers: {\n \"Content-Type\": \"application/json\",\n ...this.headers,\n },\n timeout: this.timeout,\n });\n\n // 检查GraphQL错误\n if (\n response.data.errors &&\n Array.isArray(response.data.errors) &&\n response.data.errors.length > 0\n ) {\n throw new AdapterError(\n `GraphQL errors: ${response.data.errors.map((e: any) => e.message).join(\", \")}`,\n \"graphql\",\n {\n endpoint: this.endpoint,\n errors: response.data.errors,\n },\n );\n }\n\n let result = response.data.data || response.data;\n if (this.resultRule) {\n result = makeResponseContent(result, this.resultRule);\n return result;\n }\n return\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `GraphQL request failed: ${error.message}`,\n \"graphql\",\n {\n endpoint: this.endpoint,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n },\n );\n }\n\n if (error instanceof ValidationError || error instanceof AdapterError) {\n throw error;\n }\n\n throw new AdapterError(\n `GraphQL request failed: ${(error as Error).message}`,\n \"graphql\",\n { endpoint: this.endpoint },\n );\n }\n };\n\n return this.executeWithRetry(executeRequest);\n }\n}\n",
11
+ "import type {\n AudioContent,\n ContentResult,\n Context,\n ImageContent,\n ResourceContent,\n ResourceLink,\n TextContent,\n} from \"@kingecg/fastmcp\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ResultProcessRule, ServiceAdapter } from \"../types\";\nimport * as grpc from \"@grpc/grpc-js\";\nimport * as protoLoader from \"@grpc/proto-loader\";\nimport { validate } from \"../validation\";\nimport { AdapterError, ValidationError } from \"../errors\";\nimport { z } from \"zod\";\nimport { makeResponseContent } from \"./result\";\n\n// gRPC适配器配置验证\nexport const grpcAdapterConfigSchema = z.object({\n protoPath: z.string().min(1, \"Proto file path is required\"),\n serviceName: z.string().min(1, \"Service name is required\"),\n methodName: z.string().min(1, \"Method name is required\"),\n address: z.string().min(1, \"gRPC server address is required\"),\n // 连接选项\n credentials: z.enum([\"insecure\", \"ssl\"]).default(\"insecure\"),\n timeout: z.number().int().positive().optional(),\n // 元数据\n metadata: z.record(z.string(), z.string()).optional(),\n // 重试配置\n retry: z\n .object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n })\n .optional(),\n});\n\nexport type GrpcAdapterConfig = z.infer<typeof grpcAdapterConfigSchema>;\n\nexport class GrpcAdapter implements ServiceAdapter {\n private adapterConfig: GrpcAdapterConfig | null = null;\n private client: any = null;\n private packageDefinition: any = null;\n private proto: any = null;\n private resultRule?: ResultProcessRule;\n\n config(\n options: Record<string, any>,\n rule: ResultProcessRule | undefined = undefined,\n ): void {\n this.resultRule = rule;\n this.adapterConfig = validate(\n grpcAdapterConfigSchema,\n options,\n \"gRPC adapter configuration\",\n );\n this._loadProto();\n }\n\n private _loadProto(): void {\n if (!this.adapterConfig) {\n throw new AdapterError(\"gRPC adapter not configured\", \"grpc\");\n }\n\n try {\n const { protoPath } = this.adapterConfig;\n const packageDefinition = protoLoader.loadSync(protoPath, {\n keepCase: true,\n longs: String,\n enums: String,\n defaults: true,\n oneofs: true,\n });\n\n const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);\n this.packageDefinition = protoDescriptor;\n } catch (error) {\n throw new AdapterError(\n `Failed to load proto file: ${(error as Error).message}`,\n \"grpc\",\n { protoPath: this.adapterConfig.protoPath },\n );\n }\n }\n\n private _getClient(): any {\n if (!this.adapterConfig || !this.packageDefinition) {\n throw new AdapterError(\"gRPC adapter not properly configured\", \"grpc\");\n }\n\n if (this.client) {\n return this.client;\n }\n\n const { serviceName, address, credentials } = this.adapterConfig;\n\n try {\n // 解析服务名称(格式:package.Service)\n const servicePath = serviceName.split(\".\");\n let service = this.packageDefinition;\n\n for (const part of servicePath) {\n service = service[part];\n if (!service) {\n throw new Error(\n `Service part '${part}' not found in proto definition`,\n );\n }\n }\n\n // 创建gRPC客户端\n const credentialsType =\n credentials === \"ssl\"\n ? grpc.credentials.createSsl()\n : grpc.credentials.createInsecure();\n\n this.client = new service(address, credentialsType);\n return this.client;\n } catch (error) {\n throw new AdapterError(\n `Failed to create gRPC client: ${(error as Error).message}`,\n \"grpc\",\n { serviceName, address },\n );\n }\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.adapterConfig?.retry) {\n return fn();\n }\n\n const { attempts, backoff } = this.adapterConfig.retry;\n let lastError: Error;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt < attempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, backoff * attempt),\n );\n }\n }\n }\n\n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>,\n context: Context<any>,\n ): Promise<\n | AudioContent\n | ContentResult\n | ImageContent\n | ResourceContent\n | ResourceLink\n | string\n | TextContent\n | void\n > {\n if (!this.adapterConfig) {\n throw new AdapterError(\"gRPC adapter not configured\", \"grpc\");\n }\n\n const executeRequest = async () => {\n try {\n const client = this._getClient();\n const { methodName, metadata, timeout } = this.adapterConfig!;\n\n // 准备请求元数据\n const grpcMetadata = new grpc.Metadata();\n if (metadata) {\n Object.entries(metadata).forEach(([key, value]) => {\n grpcMetadata.add(key, value);\n });\n }\n\n // 查找方法\n const method = client[methodName];\n if (typeof method !== \"function\") {\n throw new Error(`Method '${methodName}' not found on service`);\n }\n\n // 执行gRPC调用\n return new Promise<any>((resolve, reject) => {\n const deadline = timeout ? Date.now() + timeout : undefined;\n\n method.call(\n client,\n args,\n grpcMetadata,\n { deadline },\n (error: any, response: any) => {\n if (error) {\n reject(\n new AdapterError(\n `gRPC call failed: ${error.message}`,\n \"grpc\",\n {\n methodName,\n code: error.code,\n details: error.details,\n },\n ),\n );\n } else {\n // 尝试将响应转换为可序列化的格式\n try {\n // 如果是普通对象或数组,直接返回\n resolve(response);\n } catch (serializationError) {\n // 如果无法序列化,返回字符串表示\n resolve(String(response));\n }\n }\n },\n );\n });\n } catch (error) {\n if (error instanceof AdapterError || error instanceof ValidationError) {\n throw error;\n }\n\n throw new AdapterError(\n `gRPC request failed: ${(error as Error).message}`,\n \"grpc\",\n {\n methodName: this.adapterConfig?.methodName,\n serviceName: this.adapterConfig?.serviceName,\n },\n );\n }\n };\n\n let result = await this.executeWithRetry(executeRequest);\n if (this.resultRule) {\n result = makeResponseContent(result, this.resultRule);\n return result;\n }\n return ;\n }\n}\n",
12
+ "import type { ServiceAdapter, AdapterFactory, ResultProcessRule } from '../types';\nimport { ConfigurationError } from '../errors';\nimport { HttpAdapter } from './http';\nimport { GraphQLAdapter } from './graphql';\nimport { GrpcAdapter } from './grpc';\n\nexport class DefaultAdapterFactory implements AdapterFactory {\n private adapterRegistry: Map<string, new () => ServiceAdapter> = new Map();\n \n constructor() {\n this.registerDefaultAdapters();\n }\n \n private registerDefaultAdapters() {\n // 默认注册HTTP适配器\n this.registerAdapter('http', HttpAdapter);\n // 注册GraphQL适配器\n this.registerAdapter('graphql', GraphQLAdapter);\n // 注册gRPC适配器\n this.registerAdapter('grpc', GrpcAdapter);\n }\n \n createAdapter(type: string, options: Record<string, any>, rule: ResultProcessRule|undefined): ServiceAdapter {\n const AdapterClass = this.adapterRegistry.get(type);\n \n if (!AdapterClass) {\n throw new ConfigurationError(\n `Unsupported adapter type: ${type}`,\n { supportedTypes: this.getSupportedTypes() }\n );\n }\n \n try {\n const adapter = new AdapterClass();\n adapter.config(options, rule);\n return adapter;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n throw new ConfigurationError(\n `Failed to create adapter of type '${type}': ${(error as Error).message}`,\n { adapterType: type, options }\n );\n }\n }\n \n registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void {\n if (this.adapterRegistry.has(type)) {\n throw new ConfigurationError(`Adapter type '${type}' is already registered`);\n }\n this.adapterRegistry.set(type, adapterClass);\n }\n \n getSupportedTypes(): string[] {\n return Array.from(this.adapterRegistry.keys());\n }\n}\n\n// 默认工厂实例\nexport const defaultAdapterFactory = new DefaultAdapterFactory();",
12
13
  "import z from \"zod\";\nimport { mcpOptionsSchema, RegularDefineSchema, ToolDefineSchema, ToolParamSchema } from \"./validation\";\nimport type { McpOptions } from \"./types\";\nimport type { ToolParameters } from \"@kingecg/fastmcp\";\n\n\nexport function convertParamsInConfig(config: z.infer<typeof mcpOptionsSchema>): McpOptions {\n const { name, version, headers, authedFn, transport, tools } = config;\n const ntools: any = {}\n if (tools && Object.keys(tools).length > 0) {\n for (const toolName in tools) {\n const { params, outputs, ...remainDef } = (tools[toolName] as z.infer<typeof ToolDefineSchema>)\n ntools[toolName] = {\n ...remainDef\n }\n if (params) {\n ntools[toolName].params = convertParams(params)\n }\n if (outputs) {\n ntools[toolName].outputs = convertParams(outputs)\n }\n }\n }\n\n // 处理 transport 对象,确保 endpoint 符合类型要求\n let processedTransport: any = {\n transportType: 'stdio'\n };\n if (transport && transport.httpStream) {\n if (!transport.httpStream.endpoint) {\n throw new Error('transport.httpStream.endpoint is required');\n }\n // 确保 endpoint 是以 \"/\" 开头的字符串格式\n const endpoint = transport.httpStream.endpoint as string;\n if (!endpoint.startsWith('/')) {\n processedTransport = {\n ...transport,\n httpStream: {\n ...transport.httpStream,\n endpoint: `/${endpoint}` as `/${string}`\n }\n };\n } else {\n processedTransport = {\n ...transport,\n httpStream: {\n ...transport.httpStream,\n endpoint: endpoint as `/${string}`\n }\n };\n }\n }\n\n return {\n name,\n version: version as `${number}.${number}.${number}`,\n headers,\n authedFn,\n transport: processedTransport,\n tools: ntools\n }\n}\n\nexport function convertParams(params: z.infer<typeof ToolParamSchema>): ToolParameters {\n if (Array.isArray(params)) {\n if (params.length !== 1) {\n throw new Error('Only one param is supported for array define');\n }\n const zType = convertParams(params[0]);\n return z.array(zType as z.ZodType)\n }\n if (typeof params === 'object' && params !== null) {\n\n // 处理对象类型定义\n if ('type' in params) {\n try {\n const parsedparams = RegularDefineSchema.parse(params)\n const { type } = (parsedparams as any)\n\n if (type === 'object') {\n \n const objParam = params as { type: 'object', properties: Record<string, any>,description?:string }\n const p = convertParams(objParam.properties);\n \n return (p as z.ZodObject).describe(objParam.description||'');\n } else if (type === 'array') {\n \n const arrParam = params as { type: 'array', items: any,description?:string }\n const p = convertParams(arrParam.items);\n \n return (p as z.ZodType).describe(arrParam.description||'');\n } else {\n const p = convertParams(type);\n return (p as z.ZodType).describe((params as any).description||'');\n }\n } catch (e) {\n throw new Error(`Invalid param type: ${JSON.stringify(params)}`)\n }\n\n\n }\n\n // 处理普通对象(参数定义)\n const rshape: any = {}\n for (const paramName in params) {\n let pname = paramName.endsWith('?') ? paramName.slice(0, -1) : paramName\n const param = (params as any)[paramName]\n const p = convertParams(param)\n if (paramName.endsWith('?')) {\n rshape[pname] = (p as z.ZodType).optional()\n } else {\n rshape[pname] = p\n }\n }\n return z.object(rshape)\n }\n\n const typeStr = params as string // type string maybe '<type>' or '<type>:<description>'\n let desc = ''\n if (typeStr.startsWith('string')) {\n desc = typeStr.slice(7)\n return z.string().describe(desc)\n }\n if (typeStr.startsWith('number')) {\n desc = typeStr.slice(7)\n return z.number().describe(desc)\n }\n if (typeStr.startsWith('boolean')) {\n desc = typeStr.slice(8)\n return z.boolean().describe(desc)\n }\n if(typeStr.startsWith('any')){\n desc = typeStr.slice(4)\n return z.any().describe(desc)\n }\n throw new Error(`Unsupported param type: ${params}`)\n}"
13
14
  ],
14
- "mappings": "+4BAAyB,IAAzB,8BCAO,MAAM,UAAiB,KAAM,CAGhB,KACA,WACA,QAJlB,WAAW,CACT,EACgB,EACA,EACA,EAChB,CACA,MAAM,CAAO,EAJG,YACA,kBACA,eAGhB,KAAK,KAAO,WAEhB,CAEO,MAAM,UAAwB,CAAS,CAC5C,WAAW,CAAC,EAAiB,EAA+B,CAC1D,MAAM,EAAS,mBAAoB,IAAK,CAAO,EAC/C,KAAK,KAAO,kBAEhB,CAEO,MAAM,UAA2B,CAAS,CAC/C,WAAW,CAAC,EAAiB,EAA+B,CAC1D,MAAM,EAAS,sBAAuB,IAAK,CAAO,EAClD,KAAK,KAAO,qBAEhB,CAEO,MAAM,UAAqB,CAAS,CACI,YAA7C,WAAW,CAAC,EAAiC,EAAqB,EAA+B,CAC/F,MAAM,EAAS,gBAAiB,IAAK,CAAE,iBAAgB,CAAQ,CAAC,EADrB,mBAE3C,KAAK,KAAO,eAEhB,CC/BO,IAAP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,KAAK,EAAM,CAAO,EAE3C,OAER,CAAC,EACH,MAAO,EAAO,CACZ,GAAI,aAAiB,GAAmB,aAAiB,EACrD,MAAM,IAAI,EACN,mCAAmC,OAAc,EAAM,UACtD,EAAc,OACnB,EAEJ,MAAM,GAIN,2BAA2B,EAUhC,CACC,IAAM,EAAY,IAAK,KAAK,iBAAiB,SAAU,EAEvD,GAAI,EAAU,WAAY,CACtB,IAAM,EAAa,IAAK,EAAU,UAAW,EAC7C,GAAI,EAAW,SAEX,EAAW,SAAW,EAAW,SAErC,GAAI,EAAW,WACX,EAAW,WAAa,EAAW,WAGvC,MAAO,IACA,EACH,WAAY,CAQhB,EAGJ,OAAO,OAGL,MAAK,EAAG,CACV,GAAG,CAAC,KAAK,OACL,MAAM,IAAI,EAAmB,oBAAoB,EAErD,IAAM,EAAqB,KAAK,4BAA4B,EAC5D,MAAM,KAAK,OAAO,MAAM,CAAkB,EAElD",
16
+ "debugId": "3B088D6FA8793F8E64756E2164756E21",
16
17
  "names": []
17
18
  }
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import{FastMCP as M}from"@kingecg/fastmcp";class q extends Error{code;statusCode;details;constructor(t,i,s,n){super(t);this.code=i;this.statusCode=s;this.details=n;this.name="MCPError"}}class c extends q{constructor(t,i){super(t,"VALIDATION_ERROR",400,i);this.name="ValidationError"}}class p extends q{constructor(t,i){super(t,"CONFIGURATION_ERROR",500,i);this.name="ConfigurationError"}}class h extends q{adapterName;constructor(t,i,s){super(t,"ADAPTER_ERROR",502,{adapterName:i,...s});this.adapterName=i;this.name="AdapterError"}}import"axios";import v from"axios";import{z as e}from"zod";var S=e.custom((t)=>typeof t==="function",{message:"authedFn must be a function that returns a Promise"}),X=e.custom((t)=>typeof t==="function",{message:"execute must be a function"}),C=e.union([e.literal("string"),e.literal("number"),e.literal("boolean"),e.literal("any")]),_=e.string().regex(/^(string|number|boolean|any):/),l=e.object({type:C,description:e.string().optional()}),G=e.lazy(()=>e.object({type:e.literal("object"),description:e.string().optional(),properties:e.record(e.string(),e.union([C,l,G,O,_,e.record(e.string(),C),e.array(C)]))})),O=e.lazy(()=>e.object({type:e.literal("array"),description:e.string().optional(),items:e.union([C,l,G,O,_,e.record(e.string(),C),e.array(C)])})),H=e.lazy(()=>e.union([l,G,O,_])),k=e.union([C,l,G,O,e.record(e.string(),C),e.array(C)]),Y=e.object({type:e.string().min(1,"Tool type is required"),description:e.string().optional(),params:k.optional(),outputs:k.optional(),options:e.record(e.string(),e.any()),execute:X.optional()}),T=e.object({name:e.string().min(1,"Name is required"),version:e.string().regex(/^\d+\.\d+\.\d+$/,"Version must be in format x.y.z"),headers:e.array(e.string()).optional(),authedFn:S.optional(),transport:e.object({httpStream:e.object({enableJsonResponse:e.boolean().optional(),endpoint:e.string().regex(/^\/\w+/,"Endpoint must start with /").optional(),eventStore:e.any().optional(),host:e.string().optional(),port:e.number().int().min(1).max(65535),stateless:e.boolean().optional()}).optional(),transportType:e.enum(["httpStream","stdio"]).optional()}).partial(),tools:e.record(e.string(),Y)}).strict(),tt=e.object({}).passthrough(),W=e.object({url:e.string().url("Valid URL is required"),method:e.enum(["GET","POST","PUT","DELETE","PATCH"]).default("POST"),headers:e.record(e.string(),e.string()).default({}),timeout:e.number().int().positive().optional(),retry:e.object({attempts:e.number().int().min(1).max(10).default(3),backoff:e.number().positive().default(1000)}).optional()});function x(t,i,s){let n=t.safeParse(i);if(!n.success){let r=n.error.issues.map((o)=>({path:o.path.join("."),message:o.message,code:o.code,receivedValue:o.received,expected:o.expected})),d=s?`${s} validation failed:
1
+ import{FastMCP as z}from"@kingecg/fastmcp";class _ extends Error{code;statusCode;details;constructor(t,e,i,s){super(t);this.code=e;this.statusCode=i;this.details=s;this.name="MCPError"}}class C extends _{constructor(t,e){super(t,"VALIDATION_ERROR",400,e);this.name="ValidationError"}}class p extends _{constructor(t,e){super(t,"CONFIGURATION_ERROR",500,e);this.name="ConfigurationError"}}class f extends _{adapterName;constructor(t,e,i){super(t,"ADAPTER_ERROR",502,{adapterName:e,...i});this.adapterName=e;this.name="AdapterError"}}import"axios";import F from"axios";import{z as n}from"zod";var X=n.custom((t)=>typeof t==="function",{message:"authedFn must be a function that returns a Promise"}),Y=n.custom((t)=>typeof t==="function",{message:"execute must be a function"}),a=n.union([n.literal("string"),n.literal("number"),n.literal("boolean"),n.literal("any")]),m=n.string().regex(/^(string|number|boolean|any):/),G=n.object({type:a,description:n.string().optional()}),O=n.lazy(()=>n.object({type:n.literal("object"),description:n.string().optional(),properties:n.record(n.string(),n.union([a,G,O,b,m,n.record(n.string(),a),n.array(a)]))})),b=n.lazy(()=>n.object({type:n.literal("array"),description:n.string().optional(),items:n.union([a,G,O,b,m,n.record(n.string(),a),n.array(a)])})),S=n.lazy(()=>n.union([G,O,b,m])),v=n.union([a,G,O,b,n.record(n.string(),a),n.array(a)]),Z=n.object({type:n.string().min(1,"Tool type is required"),description:n.string().optional(),params:v.optional(),outputs:v.optional(),options:n.record(n.string(),n.any()),execute:Y.optional()}),H=n.object({name:n.string().min(1,"Name is required"),version:n.string().regex(/^\d+\.\d+\.\d+$/,"Version must be in format x.y.z"),headers:n.array(n.string()).optional(),authedFn:X.optional(),transport:n.object({httpStream:n.object({enableJsonResponse:n.boolean().optional(),endpoint:n.string().regex(/^\/\w+/,"Endpoint must start with /").optional(),eventStore:n.any().optional(),host:n.string().optional(),port:n.number().int().min(1).max(65535),stateless:n.boolean().optional()}).optional(),transportType:n.enum(["httpStream","stdio"]).optional()}).partial(),tools:n.record(n.string(),Z)}).strict(),rt=n.object({}).passthrough(),W=n.object({url:n.string().url("Valid URL is required"),method:n.enum(["GET","POST","PUT","DELETE","PATCH"]).default("POST"),headers:n.record(n.string(),n.string()).default({}),timeout:n.number().int().positive().optional(),retry:n.object({attempts:n.number().int().min(1).max(10).default(3),backoff:n.number().positive().default(1000)}).optional()});function x(t,e,i){let s=t.safeParse(e);if(!s.success){let r=s.error.issues.map((u)=>({path:u.path.join("."),message:u.message,code:u.code,receivedValue:u.received,expected:u.expected})),o=i?`${i} validation failed:
2
2
  `:`Validation failed:
3
- `;throw d+=n.error.issues.map((o,u)=>` ${u+1}. Field "${o.path.join(".")}" - ${o.message}`).join(`
4
- `),new c(d,{details:r})}return n.data}class b{url="";method="POST";headers={};axiosConfig={};timeout;retryConfig;config(t){let i=x(W,t,"HTTP adapter configuration");this.url=i.url,this.method=i.method,this.headers=i.headers,this.timeout=i.timeout,this.retryConfig=i.retry,this.axiosConfig={method:this.method,url:this.url,headers:this.headers,timeout:this.timeout}}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:i,backoff:s}=this.retryConfig,n;for(let r=1;r<=i;r++)try{return await t()}catch(d){if(n=d,r<i)await new Promise((o)=>setTimeout(o,s*r))}throw n}async call(t,i){let s=async()=>{let n={...this.axiosConfig};if(this.method.toUpperCase()==="GET")n.params=t;else n.data=t;try{return(await v.request(n)).data}catch(r){if(v.isAxiosError(r))throw new h(`HTTP request failed: ${r.message}`,"http",{url:this.url,method:this.method,statusCode:r.response?.status,responseData:r.response?.data});throw new h(`Request failed: ${r.message}`,"http",{url:this.url,method:this.method})}};return this.executeWithRetry(s)}}import D from"axios";import{z as R}from"zod";var Z=R.object({endpoint:R.string().url("Valid GraphQL endpoint URL is required"),headers:R.record(R.string(),R.string()).default({}),timeout:R.number().int().positive().optional(),operationName:R.string().optional(),variables:R.record(R.string(),R.any()).optional(),retry:R.object({attempts:R.number().int().min(1).max(10).default(3),backoff:R.number().positive().default(1000)}).optional()});class Q{adapterConfig=null;endpoint="";headers={};timeout;retryConfig;operationName;defaultVariables;config(t){this.adapterConfig=x(Z,t,"GraphQL adapter configuration"),this.endpoint=this.adapterConfig.endpoint,this.headers=this.adapterConfig.headers,this.timeout=this.adapterConfig.timeout,this.retryConfig=this.adapterConfig.retry,this.operationName=this.adapterConfig.operationName,this.defaultVariables=this.adapterConfig.variables}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:i,backoff:s}=this.retryConfig,n;for(let r=1;r<=i;r++)try{return await t()}catch(d){if(n=d,r<i)await new Promise((o)=>setTimeout(o,s*r))}throw n}async call(t,i){if(!this.adapterConfig)throw new h("GraphQL adapter not configured","graphql");let s=async()=>{try{let n=t.query||t.body||t.data;if(!n)throw new c("GraphQL query is required",{args:t});let r=t.variables||this.defaultVariables||{},d=t.operationName||this.operationName,o={query:typeof n==="string"?n:JSON.stringify(n),variables:r,operationName:d},u=await D.post(this.endpoint,o,{headers:{"Content-Type":"application/json",...this.headers},timeout:this.timeout});if(u.data.errors&&Array.isArray(u.data.errors)&&u.data.errors.length>0)throw new h(`GraphQL errors: ${u.data.errors.map((A)=>A.message).join(", ")}`,"graphql",{endpoint:this.endpoint,errors:u.data.errors});return u.data.data||u.data}catch(n){if(D.isAxiosError(n))throw new h(`GraphQL request failed: ${n.message}`,"graphql",{endpoint:this.endpoint,statusCode:n.response?.status,responseData:n.response?.data});if(n instanceof c||n instanceof h)throw n;throw new h(`GraphQL request failed: ${n.message}`,"graphql",{endpoint:this.endpoint})}};return this.executeWithRetry(s)}}import*as w from"@grpc/grpc-js";import*as F from"@grpc/proto-loader";import{z as g}from"zod";var m=g.object({protoPath:g.string().min(1,"Proto file path is required"),serviceName:g.string().min(1,"Service name is required"),methodName:g.string().min(1,"Method name is required"),address:g.string().min(1,"gRPC server address is required"),credentials:g.enum(["insecure","ssl"]).default("insecure"),timeout:g.number().int().positive().optional(),metadata:g.record(g.string(),g.string()).optional(),retry:g.object({attempts:g.number().int().min(1).max(10).default(3),backoff:g.number().positive().default(1000)}).optional()});class V{adapterConfig=null;client=null;packageDefinition=null;proto=null;config(t){this.adapterConfig=x(m,t,"gRPC adapter configuration"),this._loadProto()}_loadProto(){if(!this.adapterConfig)throw new h("gRPC adapter not configured","grpc");try{let{protoPath:t}=this.adapterConfig,i=F.loadSync(t,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0}),s=w.loadPackageDefinition(i);this.packageDefinition=s}catch(t){throw new h(`Failed to load proto file: ${t.message}`,"grpc",{protoPath:this.adapterConfig.protoPath})}}_getClient(){if(!this.adapterConfig||!this.packageDefinition)throw new h("gRPC adapter not properly configured","grpc");if(this.client)return this.client;let{serviceName:t,address:i,credentials:s}=this.adapterConfig;try{let n=t.split("."),r=this.packageDefinition;for(let o of n)if(r=r[o],!r)throw Error(`Service part '${o}' not found in proto definition`);let d=s==="ssl"?w.credentials.createSsl():w.credentials.createInsecure();return this.client=new r(i,d),this.client}catch(n){throw new h(`Failed to create gRPC client: ${n.message}`,"grpc",{serviceName:t,address:i})}}async executeWithRetry(t){if(!this.adapterConfig?.retry)return t();let{attempts:i,backoff:s}=this.adapterConfig.retry,n;for(let r=1;r<=i;r++)try{return await t()}catch(d){if(n=d,r<i)await new Promise((o)=>setTimeout(o,s*r))}throw n}async call(t,i){if(!this.adapterConfig)throw new h("gRPC adapter not configured","grpc");let s=async()=>{try{let n=this._getClient(),{methodName:r,metadata:d,timeout:o}=this.adapterConfig,u=new w.Metadata;if(d)Object.entries(d).forEach(([f,y])=>{u.add(f,y)});let A=n[r];if(typeof A!=="function")throw Error(`Method '${r}' not found on service`);return new Promise((f,y)=>{let I=o?Date.now()+o:void 0;A.call(n,t,u,{deadline:I},(E,$)=>{if(E)y(new h(`gRPC call failed: ${E.message}`,"grpc",{methodName:r,code:E.code,details:E.details}));else try{f($)}catch(N){f(String($))}})})}catch(n){if(n instanceof h||n instanceof c)throw n;throw new h(`gRPC request failed: ${n.message}`,"grpc",{methodName:this.adapterConfig?.methodName,serviceName:this.adapterConfig?.serviceName})}};return this.executeWithRetry(s)}}class J{adapterRegistry=new Map;constructor(){this.registerDefaultAdapters()}registerDefaultAdapters(){this.registerAdapter("http",b),this.registerAdapter("graphql",Q),this.registerAdapter("grpc",V)}createAdapter(t,i){let s=this.adapterRegistry.get(t);if(!s)throw new p(`Unsupported adapter type: ${t}`,{supportedTypes:this.getSupportedTypes()});try{let n=new s;return n.config(i),n}catch(n){if(n instanceof p)throw n;throw new p(`Failed to create adapter of type '${t}': ${n.message}`,{adapterType:t,options:i})}}registerAdapter(t,i){if(this.adapterRegistry.has(t))throw new p(`Adapter type '${t}' is already registered`);this.adapterRegistry.set(t,i)}getSupportedTypes(){return Array.from(this.adapterRegistry.keys())}}var B=new J;import L from"zod";function K(t){let{name:i,version:s,headers:n,authedFn:r,transport:d,tools:o}=t,u={};if(o&&Object.keys(o).length>0)for(let f in o){let{params:y,outputs:I,...E}=o[f];if(u[f]={...E},y)u[f].params=a(y);if(I)u[f].outputs=a(I)}let A={transportType:"stdio"};if(d&&d.httpStream){if(!d.httpStream.endpoint)throw Error("transport.httpStream.endpoint is required");let f=d.httpStream.endpoint;if(!f.startsWith("/"))A={...d,httpStream:{...d.httpStream,endpoint:`/${f}`}};else A={...d,httpStream:{...d.httpStream,endpoint:f}}}return{name:i,version:s,headers:n,authedFn:r,transport:A,tools:u}}function a(t){if(Array.isArray(t)){if(t.length!==1)throw Error("Only one param is supported for array define");let n=a(t[0]);return L.array(n)}if(typeof t==="object"&&t!==null){if("type"in t)try{let r=H.parse(t),{type:d}=r;if(d==="object"){let o=t;return a(o.properties).describe(o.description||"")}else if(d==="array"){let o=t;return a(o.items).describe(o.description||"")}else return a(d).describe(t.description||"")}catch(r){throw Error(`Invalid param type: ${JSON.stringify(t)}`)}let n={};for(let r in t){let d=r.endsWith("?")?r.slice(0,-1):r,o=t[r],u=a(o);if(r.endsWith("?"))n[d]=u.optional();else n[d]=u}return L.object(n)}let i=t,s="";if(i.startsWith("string"))return s=i.slice(7),L.string().describe(s);if(i.startsWith("number"))return s=i.slice(7),L.number().describe(s);if(i.startsWith("boolean"))return s=i.slice(8),L.boolean().describe(s);if(i.startsWith("any"))return s=i.slice(4),L.any().describe(s);throw Error(`Unsupported param type: ${t}`)}class U{server=void 0;_toolhandlers={};validatedOptions;constructor(t){this.validatedOptions=K(x(T,t,"MCP configuration")),this._createMcpServer()}_createMcpServer(){let t=this.validatedOptions.version;this.server=new M({name:this.validatedOptions.name,version:t,authenticate:async(i)=>{let s={};if(this.validatedOptions.authedFn)s=await this.validatedOptions.authedFn(i);if(this.validatedOptions.headers)s.headers=this.validatedOptions.headers.map((n)=>i.headers[n]);return s}});for(let i in this.validatedOptions.tools){let s=this.validatedOptions.tools[i];if(s)this._registerTool(i,s)}}_registerTool(t,i){if(!i.type)throw new p(`Tool '${t}' must have a type`);try{let s=B.createAdapter(i.type,i.options);this._toolhandlers[t]=s,this.server.addTool({name:t,description:i.description,parameters:i.params,execute:async(n,r)=>{if(i.defaultParams&&typeof n==="object")n={...i.defaultParams,...n};return await s.call(n,r)}})}catch(s){if(s instanceof c||s instanceof p)throw new p(`Invalid configuration for tool '${t}': ${s.message}`,s.details);throw s}}_convertTransportForFastMCP(){let t={...this.validatedOptions.transport};if(t.httpStream){let i={...t.httpStream};if(i.endpoint)i.endpoint=i.endpoint;if(i.eventStore)i.eventStore=i.eventStore;return{...t,httpStream:i}}return t}async start(){if(!this.server)throw new p("Server not created");let t=this._convertTransportForFastMCP();await this.server.start(t)}}export{m as grpcAdapterConfigSchema,Z as graphqlAdapterConfigSchema,B as defaultAdapterFactory,U as McpProxy,b as HttpAdapter,V as GrpcAdapter,Q as GraphQLAdapter,J as DefaultAdapterFactory};
3
+ `;throw o+=s.error.issues.map((u,d)=>` ${d+1}. Field "${u.path.join(".")}" - ${u.message}`).join(`
4
+ `),new C(o,{details:r})}return s.data}import*as E from"lodash";function I(t,e){switch(e.resultType){case"text":return N(t,e);case"struct":return U(t,e);default:return}}function U(t,e){let i={type:"struct",structuredContent:{}};if(e.processMethod==="passThrough")i.structuredContent=t;if(e.processMethod==="selector"){if(typeof e.selector==="string")i.structuredContent=E.get(t,e.selector,null);else if(typeof e.selector==="object"&&e.selector)for(let s in e.selector){let r=e.selector[s]||".",o=E.get(t,r);E.set(i.structuredContent,s,o)}}return i}function N(t,e){let i={text:t,type:"text"};if(e.processMethod==="selector")if(typeof e.selector!=="string")i.text="Error:For text content, selector must be a string";else{let s=E.get(t,e.selector);if(s)i.text=s;else i.text="Error:Selector not found"}else if(e.processMethod==="passThrough")i.text=typeof t==="string"?t:JSON.stringify(t);else if(e.processMethod==="fixedText"){if(e.fixedResponse)i.text=t instanceof Error?e.fixedResponse.error:e.fixedResponse.success}return i}class Q{url="";method="POST";headers={};axiosConfig={};timeout;retryConfig;resultRule;config(t,e=void 0){this.resultRule=e;let i=x(W,t,"HTTP adapter configuration");this.url=i.url,this.method=i.method,this.headers=i.headers,this.timeout=i.timeout,this.retryConfig=i.retry,this.axiosConfig={method:this.method,url:this.url,headers:this.headers,timeout:this.timeout}}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:e,backoff:i}=this.retryConfig,s;for(let r=1;r<=e;r++)try{return await t()}catch(o){if(s=o,r<e)await new Promise((u)=>setTimeout(u,i*r))}throw s}async call(t,e){let i=async()=>{let s={...this.axiosConfig};if(this.method.toUpperCase()==="GET")s.params=t;else s.data=t;try{let o=(await F.request(s)).data;if(this.resultRule)return o=I(o,this.resultRule),o;return}catch(r){if(F.isAxiosError(r))throw new f(`HTTP request failed: ${r.message}`,"http",{url:this.url,method:this.method,statusCode:r.response?.status,responseData:r.response?.data});throw new f(`Request failed: ${r.message}`,"http",{url:this.url,method:this.method})}};return this.executeWithRetry(i)}}import M from"axios";import{z as h}from"zod";var j=h.object({endpoint:h.string().url("Valid GraphQL endpoint URL is required"),headers:h.record(h.string(),h.string()).default({}),timeout:h.number().int().positive().optional(),operationName:h.string().optional(),variables:h.record(h.string(),h.any()).optional(),retry:h.object({attempts:h.number().int().min(1).max(10).default(3),backoff:h.number().positive().default(1000)}).optional()});class T{adapterConfig=null;endpoint="";headers={};timeout;retryConfig;operationName;defaultVariables;resultRule;config(t,e=void 0){this.resultRule=e,this.adapterConfig=x(j,t,"GraphQL adapter configuration"),this.endpoint=this.adapterConfig.endpoint,this.headers=this.adapterConfig.headers,this.timeout=this.adapterConfig.timeout,this.retryConfig=this.adapterConfig.retry,this.operationName=this.adapterConfig.operationName,this.defaultVariables=this.adapterConfig.variables}async executeWithRetry(t){if(!this.retryConfig)return t();let{attempts:e,backoff:i}=this.retryConfig,s;for(let r=1;r<=e;r++)try{return await t()}catch(o){if(s=o,r<e)await new Promise((u)=>setTimeout(u,i*r))}throw s}async call(t,e){if(!this.adapterConfig)throw new f("GraphQL adapter not configured","graphql");let i=async()=>{try{let s=t.query||t.body||t.data;if(!s)throw new C("GraphQL query is required",{args:t});let r=t.variables||this.defaultVariables||{},o=t.operationName||this.operationName,u={query:typeof s==="string"?s:JSON.stringify(s),variables:r,operationName:o},d=await M.post(this.endpoint,u,{headers:{"Content-Type":"application/json",...this.headers},timeout:this.timeout});if(d.data.errors&&Array.isArray(d.data.errors)&&d.data.errors.length>0)throw new f(`GraphQL errors: ${d.data.errors.map((c)=>c.message).join(", ")}`,"graphql",{endpoint:this.endpoint,errors:d.data.errors});let g=d.data.data||d.data;if(this.resultRule)return g=I(g,this.resultRule),g;return}catch(s){if(M.isAxiosError(s))throw new f(`GraphQL request failed: ${s.message}`,"graphql",{endpoint:this.endpoint,statusCode:s.response?.status,responseData:s.response?.data});if(s instanceof C||s instanceof f)throw s;throw new f(`GraphQL request failed: ${s.message}`,"graphql",{endpoint:this.endpoint})}};return this.executeWithRetry(i)}}import*as y from"@grpc/grpc-js";import*as D from"@grpc/proto-loader";import{z as R}from"zod";var P=R.object({protoPath:R.string().min(1,"Proto file path is required"),serviceName:R.string().min(1,"Service name is required"),methodName:R.string().min(1,"Method name is required"),address:R.string().min(1,"gRPC server address is required"),credentials:R.enum(["insecure","ssl"]).default("insecure"),timeout:R.number().int().positive().optional(),metadata:R.record(R.string(),R.string()).optional(),retry:R.object({attempts:R.number().int().min(1).max(10).default(3),backoff:R.number().positive().default(1000)}).optional()});class V{adapterConfig=null;client=null;packageDefinition=null;proto=null;resultRule;config(t,e=void 0){this.resultRule=e,this.adapterConfig=x(P,t,"gRPC adapter configuration"),this._loadProto()}_loadProto(){if(!this.adapterConfig)throw new f("gRPC adapter not configured","grpc");try{let{protoPath:t}=this.adapterConfig,e=D.loadSync(t,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0}),i=y.loadPackageDefinition(e);this.packageDefinition=i}catch(t){throw new f(`Failed to load proto file: ${t.message}`,"grpc",{protoPath:this.adapterConfig.protoPath})}}_getClient(){if(!this.adapterConfig||!this.packageDefinition)throw new f("gRPC adapter not properly configured","grpc");if(this.client)return this.client;let{serviceName:t,address:e,credentials:i}=this.adapterConfig;try{let s=t.split("."),r=this.packageDefinition;for(let u of s)if(r=r[u],!r)throw Error(`Service part '${u}' not found in proto definition`);let o=i==="ssl"?y.credentials.createSsl():y.credentials.createInsecure();return this.client=new r(e,o),this.client}catch(s){throw new f(`Failed to create gRPC client: ${s.message}`,"grpc",{serviceName:t,address:e})}}async executeWithRetry(t){if(!this.adapterConfig?.retry)return t();let{attempts:e,backoff:i}=this.adapterConfig.retry,s;for(let r=1;r<=e;r++)try{return await t()}catch(o){if(s=o,r<e)await new Promise((u)=>setTimeout(u,i*r))}throw s}async call(t,e){if(!this.adapterConfig)throw new f("gRPC adapter not configured","grpc");let i=async()=>{try{let r=this._getClient(),{methodName:o,metadata:u,timeout:d}=this.adapterConfig,g=new y.Metadata;if(u)Object.entries(u).forEach(([A,w])=>{g.add(A,w)});let c=r[o];if(typeof c!=="function")throw Error(`Method '${o}' not found on service`);return new Promise((A,w)=>{let k=d?Date.now()+d:void 0;c.call(r,t,g,{deadline:k},(q,$)=>{if(q)w(new f(`gRPC call failed: ${q.message}`,"grpc",{methodName:o,code:q.code,details:q.details}));else try{A($)}catch(et){A(String($))}})})}catch(r){if(r instanceof f||r instanceof C)throw r;throw new f(`gRPC request failed: ${r.message}`,"grpc",{methodName:this.adapterConfig?.methodName,serviceName:this.adapterConfig?.serviceName})}},s=await this.executeWithRetry(i);if(this.resultRule)return s=I(s,this.resultRule),s;return}}class B{adapterRegistry=new Map;constructor(){this.registerDefaultAdapters()}registerDefaultAdapters(){this.registerAdapter("http",Q),this.registerAdapter("graphql",T),this.registerAdapter("grpc",V)}createAdapter(t,e,i){let s=this.adapterRegistry.get(t);if(!s)throw new p(`Unsupported adapter type: ${t}`,{supportedTypes:this.getSupportedTypes()});try{let r=new s;return r.config(e,i),r}catch(r){if(r instanceof p)throw r;throw new p(`Failed to create adapter of type '${t}': ${r.message}`,{adapterType:t,options:e})}}registerAdapter(t,e){if(this.adapterRegistry.has(t))throw new p(`Adapter type '${t}' is already registered`);this.adapterRegistry.set(t,e)}getSupportedTypes(){return Array.from(this.adapterRegistry.keys())}}var J=new B;import L from"zod";function K(t){let{name:e,version:i,headers:s,authedFn:r,transport:o,tools:u}=t,d={};if(u&&Object.keys(u).length>0)for(let c in u){let{params:A,outputs:w,...k}=u[c];if(d[c]={...k},A)d[c].params=l(A);if(w)d[c].outputs=l(w)}let g={transportType:"stdio"};if(o&&o.httpStream){if(!o.httpStream.endpoint)throw Error("transport.httpStream.endpoint is required");let c=o.httpStream.endpoint;if(!c.startsWith("/"))g={...o,httpStream:{...o.httpStream,endpoint:`/${c}`}};else g={...o,httpStream:{...o.httpStream,endpoint:c}}}return{name:e,version:i,headers:s,authedFn:r,transport:g,tools:d}}function l(t){if(Array.isArray(t)){if(t.length!==1)throw Error("Only one param is supported for array define");let s=l(t[0]);return L.array(s)}if(typeof t==="object"&&t!==null){if("type"in t)try{let r=S.parse(t),{type:o}=r;if(o==="object"){let u=t;return l(u.properties).describe(u.description||"")}else if(o==="array"){let u=t;return l(u.items).describe(u.description||"")}else return l(o).describe(t.description||"")}catch(r){throw Error(`Invalid param type: ${JSON.stringify(t)}`)}let s={};for(let r in t){let o=r.endsWith("?")?r.slice(0,-1):r,u=t[r],d=l(u);if(r.endsWith("?"))s[o]=d.optional();else s[o]=d}return L.object(s)}let e=t,i="";if(e.startsWith("string"))return i=e.slice(7),L.string().describe(i);if(e.startsWith("number"))return i=e.slice(7),L.number().describe(i);if(e.startsWith("boolean"))return i=e.slice(8),L.boolean().describe(i);if(e.startsWith("any"))return i=e.slice(4),L.any().describe(i);throw Error(`Unsupported param type: ${t}`)}class tt{server=void 0;_toolhandlers={};validatedOptions;constructor(t){this.validatedOptions=K(x(H,t,"MCP configuration")),this._createMcpServer()}_createMcpServer(){let t=this.validatedOptions.version;this.server=new z({name:this.validatedOptions.name,version:t,authenticate:async(e)=>{let i={};if(this.validatedOptions.authedFn)i=await this.validatedOptions.authedFn(e);if(this.validatedOptions.headers)i.headers=this.validatedOptions.headers.map((s)=>e.headers[s]);return i}});for(let e in this.validatedOptions.tools){let i=this.validatedOptions.tools[e];if(i)this._registerTool(e,i)}}_registerTool(t,e){if(!e.type)throw new p(`Tool '${t}' must have a type`);try{if(!e.execute){let i=J.createAdapter(e.type,e.options,e.resultProcessRule);this._toolhandlers[t]=i}this.server.addTool({name:t,description:e.description,parameters:e.params,execute:async(i,s)=>{if(e.defaultParams&&typeof i==="object")i={...e.defaultParams,...i};if(e.execute)return await e.execute(i,s);if(this._toolhandlers[t])return await this._toolhandlers[t].call(i,s);return}})}catch(i){if(i instanceof C||i instanceof p)throw new p(`Invalid configuration for tool '${t}': ${i.message}`,i.details);throw i}}_convertTransportForFastMCP(){let t={...this.validatedOptions.transport};if(t.httpStream){let e={...t.httpStream};if(e.endpoint)e.endpoint=e.endpoint;if(e.eventStore)e.eventStore=e.eventStore;return{...t,httpStream:e}}return t}async start(){if(!this.server)throw new p("Server not created");let t=this._convertTransportForFastMCP();await this.server.start(t)}}export{P as grpcAdapterConfigSchema,j as graphqlAdapterConfigSchema,J as defaultAdapterFactory,tt as McpProxy,Q as HttpAdapter,V as GrpcAdapter,T as GraphQLAdapter,B as DefaultAdapterFactory};
5
5
 
6
- //# debugId=ADBD55FD0539B1CE64756E2164756E21
6
+ //# debugId=150EE3AE4BCE3C9864756E2164756E21
7
7
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../mpc-proxy.ts", "../../errors.ts", "../../adapters/http.ts", "../../validation.ts", "../../adapters/graphql.ts", "../../adapters/grpc.ts", "../../adapters/factory.ts", "../../config.ts"],
3
+ "sources": ["../../mpc-proxy.ts", "../../errors.ts", "../../adapters/http.ts", "../../validation.ts", "../../adapters/result.ts", "../../adapters/graphql.ts", "../../adapters/grpc.ts", "../../adapters/factory.ts", "../../config.ts"],
4
4
  "sourcesContent": [
5
- "import { FastMCP } from '@kingecg/fastmcp';\nimport { IncomingMessage } from 'http'\nimport * as types from './types';\nimport { defaultAdapterFactory } from './adapters/factory';\nimport { mcpOptionsSchema, validate, type ValidatedMcpOptions } from './validation';\nimport { ConfigurationError, ValidationError } from './errors';\nimport type { EventStore } from \"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js\";\nimport { convertParamsInConfig } from './config';\nimport type z from 'zod';\nexport class McpProxy {\n server: FastMCP|undefined = undefined\n private _toolhandlers: Record<string, types.ServiceAdapter> = {}\n private validatedOptions: ValidatedMcpOptions;\n \n constructor(options: z.infer<typeof mcpOptionsSchema>) {\n this.validatedOptions = convertParamsInConfig(validate(mcpOptionsSchema, options, 'MCP configuration'));\n this._createMcpServer()\n } \n \n _createMcpServer() { \n // 类型断言:验证已经确保version格式正确\n const version = this.validatedOptions.version as `${number}.${number}.${number}`;\n \n this.server = new FastMCP({\n name: this.validatedOptions.name,\n version: version,\n authenticate: async (req: IncomingMessage) => {\n let ret: Record<string, any> = {};\n if (this.validatedOptions.authedFn) {\n ret = await this.validatedOptions.authedFn(req);\n }\n if (this.validatedOptions.headers) {\n ret.headers = this.validatedOptions.headers.map(h => req.headers[h]);\n }\n return ret;\n }\n })\n \n for (const toolName in this.validatedOptions.tools) {\n const tool = this.validatedOptions.tools[toolName];\n if (tool) {\n this._registerTool(toolName, tool as types.ToolDefine);\n }\n }\n }\n \n private _registerTool(toolName: string, tool: types.ToolDefine) {\n if (!tool.type) {\n throw new ConfigurationError(`Tool '${toolName}' must have a type`);\n }\n \n try {\n const adapter = defaultAdapterFactory.createAdapter(tool.type, tool.options);\n this._toolhandlers[toolName] = adapter;\n \n this.server!.addTool({\n name: toolName,\n description: tool.description,\n parameters: tool.params,\n execute: async (args, context) => {\n if(tool.defaultParams && typeof args === 'object'){\n args = {...tool.defaultParams, ...args};\n }\n return await adapter.call(args, context);\n } \n });\n } catch (error) {\n if (error instanceof ValidationError || error instanceof ConfigurationError) {\n throw new ConfigurationError(\n `Invalid configuration for tool '${toolName}': ${error.message}`,\n (error as any).details\n );\n }\n throw error;\n }\n }\n \n private _convertTransportForFastMCP(): Partial<{\n httpStream: {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n };\n transportType: \"httpStream\" | \"stdio\";\n }> {\n const transport = { ...this.validatedOptions.transport };\n \n if (transport.httpStream) {\n const httpStream = { ...transport.httpStream };\n if (httpStream.endpoint) {\n // 类型转换:验证已经确保endpoint以/开头\n httpStream.endpoint = httpStream.endpoint as `/${string}`;\n }\n if (httpStream.eventStore) {\n httpStream.eventStore = httpStream.eventStore as EventStore;\n }\n \n return {\n ...transport,\n httpStream: httpStream as {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n }\n };\n }\n \n return transport as any;\n }\n \n async start() {\n if(!this.server){\n throw new ConfigurationError('Server not created');\n }\n const convertedTransport = this._convertTransportForFastMCP();\n await this.server.start(convertedTransport);\n }\n}",
5
+ "import { FastMCP } from '@kingecg/fastmcp';\nimport { IncomingMessage } from 'http'\nimport * as types from './types';\nimport { defaultAdapterFactory } from './adapters/factory';\nimport { mcpOptionsSchema, validate, type ValidatedMcpOptions } from './validation';\nimport { ConfigurationError, ValidationError } from './errors';\nimport type { EventStore } from \"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js\";\nimport { convertParamsInConfig } from './config';\nimport type z from 'zod';\nexport class McpProxy {\n server: FastMCP|undefined = undefined\n private _toolhandlers: Record<string, types.ServiceAdapter> = {}\n private validatedOptions: ValidatedMcpOptions;\n \n constructor(options: z.infer<typeof mcpOptionsSchema>) {\n this.validatedOptions = convertParamsInConfig(validate(mcpOptionsSchema, options, 'MCP configuration'));\n this._createMcpServer()\n } \n \n _createMcpServer() { \n // 类型断言:验证已经确保version格式正确\n const version = this.validatedOptions.version as `${number}.${number}.${number}`;\n \n this.server = new FastMCP({\n name: this.validatedOptions.name,\n version: version,\n authenticate: async (req: IncomingMessage) => {\n let ret: Record<string, any> = {};\n if (this.validatedOptions.authedFn) {\n ret = await this.validatedOptions.authedFn(req);\n }\n if (this.validatedOptions.headers) {\n ret.headers = this.validatedOptions.headers.map(h => req.headers[h]);\n }\n return ret;\n }\n })\n \n for (const toolName in this.validatedOptions.tools) {\n const tool = this.validatedOptions.tools[toolName];\n if (tool) {\n this._registerTool(toolName, tool as types.ToolDefine);\n }\n }\n }\n \n private _registerTool(toolName: string, tool: types.ToolDefine) {\n if (!tool.type) {\n throw new ConfigurationError(`Tool '${toolName}' must have a type`);\n }\n \n try {\n if(!tool.execute){\n const adapter = defaultAdapterFactory.createAdapter(tool.type, tool.options, tool.resultProcessRule);\n this._toolhandlers[toolName] = adapter;\n }\n \n \n this.server!.addTool({\n name: toolName,\n description: tool.description,\n parameters: tool.params,\n execute: async (args, context) => {\n if(tool.defaultParams && typeof args === 'object'){\n args = {...tool.defaultParams, ...args};\n }\n if(tool.execute){\n return await tool.execute(args, context);\n }\n if( this._toolhandlers[toolName]){\n const adapter = this._toolhandlers[toolName];\n return await adapter.call(args, context);\n }\n return\n } \n });\n } catch (error) {\n if (error instanceof ValidationError || error instanceof ConfigurationError) {\n throw new ConfigurationError(\n `Invalid configuration for tool '${toolName}': ${error.message}`,\n (error as any).details\n );\n }\n throw error;\n }\n }\n \n private _convertTransportForFastMCP(): Partial<{\n httpStream: {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n };\n transportType: \"httpStream\" | \"stdio\";\n }> {\n const transport = { ...this.validatedOptions.transport };\n \n if (transport.httpStream) {\n const httpStream = { ...transport.httpStream };\n if (httpStream.endpoint) {\n // 类型转换:验证已经确保endpoint以/开头\n httpStream.endpoint = httpStream.endpoint as `/${string}`;\n }\n if (httpStream.eventStore) {\n httpStream.eventStore = httpStream.eventStore as EventStore;\n }\n \n return {\n ...transport,\n httpStream: httpStream as {\n enableJsonResponse?: boolean;\n endpoint?: `/${string}`;\n eventStore?: EventStore;\n host?: string;\n port: number;\n stateless?: boolean;\n }\n };\n }\n \n return transport as any;\n }\n \n async start() {\n if(!this.server){\n throw new ConfigurationError('Server not created');\n }\n const convertedTransport = this._convertTransportForFastMCP();\n await this.server.start(convertedTransport);\n }\n}",
6
6
  "export class MCPError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly statusCode?: number,\n public readonly details?: Record<string, any>\n ) {\n super(message);\n this.name = 'MCPError';\n }\n}\n\nexport class ValidationError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'VALIDATION_ERROR', 400, details);\n this.name = 'ValidationError';\n }\n}\n\nexport class ConfigurationError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'CONFIGURATION_ERROR', 500, details);\n this.name = 'ConfigurationError';\n }\n}\n\nexport class AdapterError extends MCPError {\n constructor(message: string, public readonly adapterName: string, details?: Record<string, any>) {\n super(message, 'ADAPTER_ERROR', 502, { adapterName, ...details });\n this.name = 'AdapterError';\n }\n}\n\nexport class AuthenticationError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'AUTHENTICATION_ERROR', 401, details);\n this.name = 'AuthenticationError';\n }\n}\n\nexport class RateLimitError extends MCPError {\n constructor(message: string, details?: Record<string, any>) {\n super(message, 'RATE_LIMIT_ERROR', 429, details);\n this.name = 'RateLimitError';\n }\n}\n\nexport type ErrorType = \n | 'VALIDATION_ERROR'\n | 'CONFIGURATION_ERROR'\n | 'ADAPTER_ERROR'\n | 'AUTHENTICATION_ERROR'\n | 'RATE_LIMIT_ERROR'\n | 'INTERNAL_ERROR';",
7
- "import 'axios'\nimport type {AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent, ToolParameters} from '@kingecg/fastmcp'\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ServiceAdapter } from '../types';\nimport type { AxiosRequestConfig } from 'axios';\nimport axios from 'axios';\nimport { httpAdapterConfigSchema, validate } from '../validation';\nimport { AdapterError } from '../errors';\n\nexport class HttpAdapter implements ServiceAdapter {\n private url: string = '';\n private method = 'POST';\n private headers: Record<string, string> = {}; \n private axiosConfig :AxiosRequestConfig = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n \n config(option: Record<string, any>) {\n const validatedConfig = validate(httpAdapterConfigSchema, option, 'HTTP adapter configuration');\n \n this.url = validatedConfig.url;\n this.method = validatedConfig.method; \n this.headers = validatedConfig.headers;\n this.timeout = validatedConfig.timeout;\n this.retryConfig = validatedConfig.retry;\n \n this.axiosConfig = {\n method: this.method,\n url: this.url,\n headers: this.headers,\n timeout: this.timeout\n };\n }\n \n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n \n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n \n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n \n if (attempt < attempts) {\n await new Promise(resolve => setTimeout(resolve, backoff * attempt));\n }\n }\n }\n \n throw lastError!;\n }\n \n async call(args: StandardSchemaV1.InferOutput<any>, context: Context<any>): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void> {\n const executeRequest = async () => {\n const axiosConfig = {...this.axiosConfig};\n \n if (this.method.toUpperCase() === 'GET') {\n axiosConfig.params = args;\n } else {\n axiosConfig.data = args;\n }\n \n try {\n const response = await axios.request(axiosConfig);\n return response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `HTTP request failed: ${error.message}`,\n 'http',\n {\n url: this.url,\n method: this.method,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n }\n );\n }\n throw new AdapterError(\n `Request failed: ${(error as Error).message}`,\n 'http',\n { url: this.url, method: this.method }\n );\n }\n };\n \n return this.executeWithRetry(executeRequest);\n }\n}",
7
+ "import \"axios\";\nimport type {\n AudioContent,\n ContentResult,\n Context,\n ImageContent,\n ResourceContent,\n ResourceLink,\n TextContent,\n ToolParameters,\n} from \"@kingecg/fastmcp\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ResultProcessRule, ServiceAdapter } from \"../types\";\nimport type { AxiosRequestConfig } from \"axios\";\nimport axios from \"axios\";\nimport { httpAdapterConfigSchema, validate } from \"../validation\";\nimport { AdapterError } from \"../errors\";\nimport { makeResponseContent } from \"./result\";\n\nexport class HttpAdapter implements ServiceAdapter {\n private url: string = \"\";\n private method = \"POST\";\n private headers: Record<string, string> = {};\n private axiosConfig: AxiosRequestConfig = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n private resultRule?: ResultProcessRule;\n config(\n option: Record<string, any>,\n rule: ResultProcessRule | undefined = undefined,\n ) {\n this.resultRule = rule;\n const validatedConfig = validate(\n httpAdapterConfigSchema,\n option,\n \"HTTP adapter configuration\",\n );\n\n this.url = validatedConfig.url;\n this.method = validatedConfig.method;\n this.headers = validatedConfig.headers;\n this.timeout = validatedConfig.timeout;\n this.retryConfig = validatedConfig.retry;\n\n this.axiosConfig = {\n method: this.method,\n url: this.url,\n headers: this.headers,\n timeout: this.timeout,\n };\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n\n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt < attempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, backoff * attempt),\n );\n }\n }\n }\n\n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>,\n context: Context<any>,\n ): Promise<\n | AudioContent\n | ContentResult\n | ImageContent\n | ResourceContent\n | ResourceLink\n | string\n | TextContent\n | void\n > {\n const executeRequest = async () => {\n const axiosConfig = { ...this.axiosConfig };\n\n if (this.method.toUpperCase() === \"GET\") {\n axiosConfig.params = args;\n } else {\n axiosConfig.data = args;\n }\n\n try {\n const response = await axios.request(axiosConfig);\n let result = response.data;\n if (this.resultRule) {\n result = makeResponseContent(result, this.resultRule);\n return result;\n }\n return;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `HTTP request failed: ${error.message}`,\n \"http\",\n {\n url: this.url,\n method: this.method,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n },\n );\n }\n throw new AdapterError(\n `Request failed: ${(error as Error).message}`,\n \"http\",\n { url: this.url, method: this.method },\n );\n }\n };\n\n return this.executeWithRetry(executeRequest);\n }\n}\n",
8
8
  "import { z } from 'zod';\nimport { ValidationError } from './errors';\nimport type { IncomingMessage } from 'http';\n\n// 自定义验证器用于authenticate函数\nconst authenticateSchema = z.custom<\n (request: IncomingMessage) => Promise<Record<string, any>>\n>((val) => typeof val === 'function', {\n message: 'authedFn must be a function that returns a Promise',\n});\n\n// 自定义验证器用于工具执行函数\nconst toolExecuteSchema = z.custom<\n (args: any, context: any) => Promise<any>\n>((val) => typeof val === 'function', {\n message: 'execute must be a function',\n});\nexport const ParamTypeUnion:z.ZodType= z.union([\n z.literal('string'),\n z.literal('number'),\n z.literal('boolean'),\n z.literal('any')\n])\nexport const AbbToolParamType:z.ZodType= z.string().regex(/^(string|number|boolean|any):/)\nexport const ParamTypObject:z.ZodType= z.object({\n type: ParamTypeUnion,\n description: z.string().optional()\n})\nexport const ParamObjectType:z.ZodType= z.lazy(()=>z.object({\n type: z.literal('object'),\n description: z.string().optional(),\n properties: z.record(z.string(), z.union([ ParamTypeUnion,\n ParamTypObject, \n ParamObjectType,\n ParamArrayType,\n AbbToolParamType,\n z.record(z.string(),ParamTypeUnion),\n z.array(ParamTypeUnion)]))\n}) )\nexport const ParamArrayType:z.ZodType= z.lazy(()=>z.object({\n type: z.literal('array'),\n description: z.string().optional(),\n items: z.union([ ParamTypeUnion,\n ParamTypObject, \n ParamObjectType,\n ParamArrayType,\n AbbToolParamType,\n z.record(z.string(),ParamTypeUnion),\n z.array(ParamTypeUnion)])}));\n\nexport const RegularDefineSchema = z.lazy(()=>z.union([\n ParamTypObject,\n ParamObjectType,\n ParamArrayType,\n AbbToolParamType\n]))\nexport const ToolParamSchema = z.union([\n ParamTypeUnion,\n ParamTypObject, \n ParamObjectType,\n ParamArrayType,\n z.record(z.string(),ParamTypeUnion),\n z.array(ParamTypeUnion)\n])\nexport const ToolDefineSchema = z.object({\n type: z.string().min(1, 'Tool type is required'),\n description: z.string().optional(),\n params: ToolParamSchema.optional(), // ToolParameters from fastmcp\n outputs: ToolParamSchema.optional(),\n options: z.record(z.string(), z.any()),\n execute: toolExecuteSchema.optional(),\n});\n// MCP配置验证\nexport const mcpOptionsSchema = z.object({\n name: z.string().min(1, 'Name is required'),\n version: z.string().regex(/^\\d+\\.\\d+\\.\\d+$/, 'Version must be in format x.y.z'),\n headers: z.array(z.string()).optional(),\n authedFn: authenticateSchema.optional(),\n transport: z.object({\n httpStream: z.object({\n enableJsonResponse: z.boolean().optional(),\n endpoint: z.string().regex(/^\\/\\w+/, 'Endpoint must start with /').optional(),\n eventStore: z.any().optional(),\n host: z.string().optional(),\n port: z.number().int().min(1).max(65535),\n stateless: z.boolean().optional(),\n }).optional(),\n transportType: z.enum(['httpStream', 'stdio']).optional(),\n }).partial(),\n tools: z.record(z.string(), ToolDefineSchema),\n}).strict();\n\n// 工具参数验证基础模式\nexport const toolParamsSchema = z.object({}).passthrough(); // 允许任意参数,但可以进一步约束\n\n// HTTP适配器配置验证\nexport const httpAdapterConfigSchema = z.object({\n url: z.string().url('Valid URL is required'),\n method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).default('POST'),\n headers: z.record(z.string(), z.string()).default({}),\n timeout: z.number().int().positive().optional(),\n retry: z.object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n }).optional(),\n});\n\n// 通用验证函数\nexport function validate<T>(schema: z.ZodSchema<T>, data: unknown, context?: string): T {\n const result = schema.safeParse(data);\n \n if (!result.success) {\n const details = result.error.issues.map((err: any) => ({\n path: err.path.join('.'),\n message: err.message,\n code: err.code,\n receivedValue: err.received,\n expected: err.expected,\n }));\n \n // 构建更友好的错误消息,包含所有错误细节\n let message = context \n ? `${context} validation failed:\\n`\n : 'Validation failed:\\n';\n \n message += result.error.issues.map((err: any, index: number) => \n ` ${index + 1}. Field \"${err.path.join('.')}\" - ${err.message}`\n ).join('\\n');\n \n throw new ValidationError(message, { details });\n }\n \n return result.data;\n}\n\n// 类型推断\nexport type ValidatedMcpOptions = z.infer<typeof mcpOptionsSchema>;\nexport type ValidatedHttpAdapterConfig = z.infer<typeof httpAdapterConfigSchema>;",
9
- "import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '@kingecg/fastmcp';\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ServiceAdapter } from '../types';\nimport axios from 'axios';\nimport { validate } from '../validation';\nimport { AdapterError, ValidationError } from '../errors';\nimport { z } from 'zod';\n\n// GraphQL适配器配置验证\nexport const graphqlAdapterConfigSchema = z.object({\n endpoint: z.string().url('Valid GraphQL endpoint URL is required'),\n headers: z.record(z.string(), z.string()).default({}),\n timeout: z.number().int().positive().optional(),\n // GraphQL特定配置\n operationName: z.string().optional(),\n variables: z.record(z.string(), z.any()).optional(),\n // 重试配置\n retry: z.object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n }).optional(),\n});\n\nexport type GraphQLAdapterConfig = z.infer<typeof graphqlAdapterConfigSchema>;\n\nexport class GraphQLAdapter implements ServiceAdapter {\n private adapterConfig: GraphQLAdapterConfig | null = null;\n private endpoint: string = '';\n private headers: Record<string, string> = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n private operationName?: string;\n private defaultVariables?: Record<string, any>;\n\n config(options: Record<string, any>): void {\n this.adapterConfig = validate(graphqlAdapterConfigSchema, options, 'GraphQL adapter configuration');\n \n this.endpoint = this.adapterConfig.endpoint;\n this.headers = this.adapterConfig.headers;\n this.timeout = this.adapterConfig.timeout;\n this.retryConfig = this.adapterConfig.retry;\n this.operationName = this.adapterConfig.operationName;\n this.defaultVariables = this.adapterConfig.variables;\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n \n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n \n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n \n if (attempt < attempts) {\n await new Promise(resolve => setTimeout(resolve, backoff * attempt));\n }\n }\n }\n \n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>, \n context: Context<any>\n ): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void> {\n if (!this.adapterConfig) {\n throw new AdapterError('GraphQL adapter not configured', 'graphql');\n }\n\n const executeRequest = async () => {\n try {\n // 解析GraphQL查询和变量\n const query = args.query || args.body || args.data;\n if (!query) {\n throw new ValidationError('GraphQL query is required', { args });\n }\n\n const variables = args.variables || this.defaultVariables || {};\n const operationName = args.operationName || this.operationName;\n\n const graphqlRequest = {\n query: typeof query === 'string' ? query : JSON.stringify(query),\n variables,\n operationName,\n };\n\n const response = await axios.post(this.endpoint, graphqlRequest, {\n headers: {\n 'Content-Type': 'application/json',\n ...this.headers,\n },\n timeout: this.timeout,\n });\n\n // 检查GraphQL错误\n if (response.data.errors && Array.isArray(response.data.errors) && response.data.errors.length > 0) {\n throw new AdapterError(\n `GraphQL errors: ${response.data.errors.map((e: any) => e.message).join(', ')}`,\n 'graphql',\n {\n endpoint: this.endpoint,\n errors: response.data.errors,\n }\n );\n }\n\n return response.data.data || response.data;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `GraphQL request failed: ${error.message}`,\n 'graphql',\n {\n endpoint: this.endpoint,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n }\n );\n }\n \n if (error instanceof ValidationError || error instanceof AdapterError) {\n throw error;\n }\n \n throw new AdapterError(\n `GraphQL request failed: ${(error as Error).message}`,\n 'graphql',\n { endpoint: this.endpoint }\n );\n }\n };\n\n return this.executeWithRetry(executeRequest);\n }\n}",
10
- "import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '@kingecg/fastmcp';\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ServiceAdapter } from '../types';\nimport * as grpc from '@grpc/grpc-js';\nimport * as protoLoader from '@grpc/proto-loader';\nimport { validate } from '../validation';\nimport { AdapterError, ValidationError } from '../errors';\nimport { z } from 'zod';\n\n// gRPC适配器配置验证\nexport const grpcAdapterConfigSchema = z.object({\n protoPath: z.string().min(1, 'Proto file path is required'),\n serviceName: z.string().min(1, 'Service name is required'),\n methodName: z.string().min(1, 'Method name is required'),\n address: z.string().min(1, 'gRPC server address is required'),\n // 连接选项\n credentials: z.enum(['insecure', 'ssl']).default('insecure'),\n timeout: z.number().int().positive().optional(),\n // 元数据\n metadata: z.record(z.string(), z.string()).optional(),\n // 重试配置\n retry: z.object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n }).optional(),\n});\n\nexport type GrpcAdapterConfig = z.infer<typeof grpcAdapterConfigSchema>;\n\nexport class GrpcAdapter implements ServiceAdapter {\n private adapterConfig: GrpcAdapterConfig | null = null;\n private client: any = null;\n private packageDefinition: any = null;\n private proto: any = null;\n \n config(options: Record<string, any>): void {\n this.adapterConfig = validate(grpcAdapterConfigSchema, options, 'gRPC adapter configuration');\n this._loadProto();\n }\n \n private _loadProto(): void {\n if (!this.adapterConfig) {\n throw new AdapterError('gRPC adapter not configured', 'grpc');\n }\n \n try {\n const { protoPath } = this.adapterConfig;\n const packageDefinition = protoLoader.loadSync(protoPath, {\n keepCase: true,\n longs: String,\n enums: String,\n defaults: true,\n oneofs: true,\n });\n \n const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);\n this.packageDefinition = protoDescriptor;\n } catch (error) {\n throw new AdapterError(\n `Failed to load proto file: ${(error as Error).message}`,\n 'grpc',\n { protoPath: this.adapterConfig.protoPath }\n );\n }\n }\n \n private _getClient(): any {\n if (!this.adapterConfig || !this.packageDefinition) {\n throw new AdapterError('gRPC adapter not properly configured', 'grpc');\n }\n \n if (this.client) {\n return this.client;\n }\n \n const { serviceName, address, credentials } = this.adapterConfig;\n \n try {\n // 解析服务名称(格式:package.Service)\n const servicePath = serviceName.split('.');\n let service = this.packageDefinition;\n \n for (const part of servicePath) {\n service = service[part];\n if (!service) {\n throw new Error(`Service part '${part}' not found in proto definition`);\n }\n }\n \n // 创建gRPC客户端\n const credentialsType = credentials === 'ssl' \n ? grpc.credentials.createSsl()\n : grpc.credentials.createInsecure();\n \n this.client = new service(address, credentialsType);\n return this.client;\n } catch (error) {\n throw new AdapterError(\n `Failed to create gRPC client: ${(error as Error).message}`,\n 'grpc',\n { serviceName, address }\n );\n }\n }\n \n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.adapterConfig?.retry) {\n return fn();\n }\n \n const { attempts, backoff } = this.adapterConfig.retry;\n let lastError: Error;\n \n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n \n if (attempt < attempts) {\n await new Promise(resolve => setTimeout(resolve, backoff * attempt));\n }\n }\n }\n \n throw lastError!;\n }\n \n async call(\n args: StandardSchemaV1.InferOutput<any>, \n context: Context<any>\n ): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void> {\n if (!this.adapterConfig) {\n throw new AdapterError('gRPC adapter not configured', 'grpc');\n }\n \n const executeRequest = async () => {\n try {\n const client = this._getClient();\n const { methodName, metadata, timeout } = this.adapterConfig!;\n \n // 准备请求元数据\n const grpcMetadata = new grpc.Metadata();\n if (metadata) {\n Object.entries(metadata).forEach(([key, value]) => {\n grpcMetadata.add(key, value);\n });\n }\n \n // 查找方法\n const method = client[methodName];\n if (typeof method !== 'function') {\n throw new Error(`Method '${methodName}' not found on service`);\n }\n \n // 执行gRPC调用\n return new Promise<any>((resolve, reject) => {\n const deadline = timeout ? Date.now() + timeout : undefined;\n \n method.call(\n client,\n args,\n grpcMetadata,\n { deadline },\n (error: any, response: any) => {\n if (error) {\n reject(new AdapterError(\n `gRPC call failed: ${error.message}`,\n 'grpc',\n {\n methodName,\n code: error.code,\n details: error.details,\n }\n ));\n } else {\n // 尝试将响应转换为可序列化的格式\n try {\n // 如果是普通对象或数组,直接返回\n resolve(response);\n } catch (serializationError) {\n // 如果无法序列化,返回字符串表示\n resolve(String(response));\n }\n }\n }\n );\n });\n } catch (error) {\n if (error instanceof AdapterError || error instanceof ValidationError) {\n throw error;\n }\n \n throw new AdapterError(\n `gRPC request failed: ${(error as Error).message}`,\n 'grpc',\n {\n methodName: this.adapterConfig?.methodName,\n serviceName: this.adapterConfig?.serviceName,\n }\n );\n }\n };\n \n return this.executeWithRetry(executeRequest);\n }\n}",
11
- "import type { ServiceAdapter, AdapterFactory } from '../types';\nimport { ConfigurationError } from '../errors';\nimport { HttpAdapter } from './http';\nimport { GraphQLAdapter } from './graphql';\nimport { GrpcAdapter } from './grpc';\n\nexport class DefaultAdapterFactory implements AdapterFactory {\n private adapterRegistry: Map<string, new () => ServiceAdapter> = new Map();\n \n constructor() {\n this.registerDefaultAdapters();\n }\n \n private registerDefaultAdapters() {\n // 默认注册HTTP适配器\n this.registerAdapter('http', HttpAdapter);\n // 注册GraphQL适配器\n this.registerAdapter('graphql', GraphQLAdapter);\n // 注册gRPC适配器\n this.registerAdapter('grpc', GrpcAdapter);\n }\n \n createAdapter(type: string, options: Record<string, any>): ServiceAdapter {\n const AdapterClass = this.adapterRegistry.get(type);\n \n if (!AdapterClass) {\n throw new ConfigurationError(\n `Unsupported adapter type: ${type}`,\n { supportedTypes: this.getSupportedTypes() }\n );\n }\n \n try {\n const adapter = new AdapterClass();\n adapter.config(options);\n return adapter;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n throw new ConfigurationError(\n `Failed to create adapter of type '${type}': ${(error as Error).message}`,\n { adapterType: type, options }\n );\n }\n }\n \n registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void {\n if (this.adapterRegistry.has(type)) {\n throw new ConfigurationError(`Adapter type '${type}' is already registered`);\n }\n this.adapterRegistry.set(type, adapterClass);\n }\n \n getSupportedTypes(): string[] {\n return Array.from(this.adapterRegistry.keys());\n }\n}\n\n// 默认工厂实例\nexport const defaultAdapterFactory = new DefaultAdapterFactory();",
9
+ "import type {\n AudioContent,\n ContentResult,\n TextContent,\n StructContent,\n ImageContent,\n} from \"@kingecg/fastmcp\";\nimport type { ResultProcessRule } from \"../types\";\nimport * as _ from \"lodash\";\n\nexport function makeMediaContent(\n result: string | Buffer,\n mimeType: string,\n): AudioContent | ImageContent {\n return result instanceof Buffer\n ? {\n data: result.toString(\"base64\"),\n mimeType,\n type: mimeType.startsWith(\"image\") ? \"image\" : \"audio\",\n }\n : {\n data: result as string,\n mimeType,\n type: mimeType.startsWith(\"image\") ? \"image\" : \"audio\",\n };\n}\nexport function makeResponseContent(\n result: any,\n rule: ResultProcessRule,\n): TextContent | StructContent | void {\n switch (rule.resultType) {\n case \"text\":\n return makeTextContent(result, rule);\n case \"struct\":\n return makeStructContent(result, rule);\n default:\n return;\n }\n}\nfunction makeStructContent(result: any, rule: ResultProcessRule) {\n const content: StructContent = {\n type: \"struct\",\n structuredContent: {},\n };\n if (rule.processMethod === \"passThrough\") {\n content.structuredContent = result;\n }\n if (rule.processMethod === \"selector\") {\n if (typeof rule.selector === \"string\") {\n content.structuredContent = _.get(result, rule.selector, null);\n } else if (typeof rule.selector === \"object\" && rule.selector) {\n for (const key in rule.selector) {\n const propertyPath = rule.selector[key] || \".\";\n const value = _.get(result, propertyPath);\n _.set(content.structuredContent, key, value);\n }\n }\n }\n return content;\n}\n\nfunction makeTextContent(result: any, rule: ResultProcessRule): TextContent {\n let content: TextContent = {\n text: result,\n type: \"text\" as const,\n };\n if (rule.processMethod === \"selector\") {\n if (typeof rule.selector !== \"string\") {\n content.text = \"Error:For text content, selector must be a string\";\n } else {\n const selector = _.get(result, rule.selector);\n if (selector) {\n content.text = selector;\n } else {\n content.text = \"Error:Selector not found\";\n }\n }\n } else if (rule.processMethod === \"passThrough\") {\n content.text = typeof result === \"string\" ? result : JSON.stringify(result);\n } else if (rule.processMethod === \"fixedText\") {\n if (rule.fixedResponse) {\n content.text =\n result instanceof Error\n ? rule.fixedResponse.error\n : rule.fixedResponse.success;\n }\n }\n return content;\n}\n",
10
+ "import type {\n AudioContent,\n ContentResult,\n Context,\n ImageContent,\n ResourceContent,\n ResourceLink,\n TextContent,\n} from \"@kingecg/fastmcp\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ResultProcessRule, ServiceAdapter } from \"../types\";\nimport axios from \"axios\";\nimport { validate } from \"../validation\";\nimport { AdapterError, ValidationError } from \"../errors\";\nimport { z } from \"zod\";\nimport { makeResponseContent } from \"./result\";\n\n// GraphQL适配器配置验证\nexport const graphqlAdapterConfigSchema = z.object({\n endpoint: z.string().url(\"Valid GraphQL endpoint URL is required\"),\n headers: z.record(z.string(), z.string()).default({}),\n timeout: z.number().int().positive().optional(),\n // GraphQL特定配置\n operationName: z.string().optional(),\n variables: z.record(z.string(), z.any()).optional(),\n // 重试配置\n retry: z\n .object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n })\n .optional(),\n});\n\nexport type GraphQLAdapterConfig = z.infer<typeof graphqlAdapterConfigSchema>;\n\nexport class GraphQLAdapter implements ServiceAdapter {\n private adapterConfig: GraphQLAdapterConfig | null = null;\n private endpoint: string = \"\";\n private headers: Record<string, string> = {};\n private timeout?: number;\n private retryConfig?: { attempts: number; backoff: number };\n private operationName?: string;\n private defaultVariables?: Record<string, any>;\n private resultRule?: ResultProcessRule;\n\n config(\n options: Record<string, any>,\n rule: ResultProcessRule | undefined = undefined,\n ): void {\n this.resultRule = rule;\n this.adapterConfig = validate(\n graphqlAdapterConfigSchema,\n options,\n \"GraphQL adapter configuration\",\n );\n\n this.endpoint = this.adapterConfig.endpoint;\n this.headers = this.adapterConfig.headers;\n this.timeout = this.adapterConfig.timeout;\n this.retryConfig = this.adapterConfig.retry;\n this.operationName = this.adapterConfig.operationName;\n this.defaultVariables = this.adapterConfig.variables;\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.retryConfig) {\n return fn();\n }\n\n const { attempts, backoff } = this.retryConfig;\n let lastError: Error;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt < attempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, backoff * attempt),\n );\n }\n }\n }\n\n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>,\n context: Context<any>,\n ): Promise<\n | AudioContent\n | ContentResult\n | ImageContent\n | ResourceContent\n | ResourceLink\n | string\n | TextContent\n | void\n > {\n if (!this.adapterConfig) {\n throw new AdapterError(\"GraphQL adapter not configured\", \"graphql\");\n }\n\n const executeRequest = async () => {\n try {\n // 解析GraphQL查询和变量\n const query = args.query || args.body || args.data;\n if (!query) {\n throw new ValidationError(\"GraphQL query is required\", { args });\n }\n\n const variables = args.variables || this.defaultVariables || {};\n const operationName = args.operationName || this.operationName;\n\n const graphqlRequest = {\n query: typeof query === \"string\" ? query : JSON.stringify(query),\n variables,\n operationName,\n };\n\n const response = await axios.post(this.endpoint, graphqlRequest, {\n headers: {\n \"Content-Type\": \"application/json\",\n ...this.headers,\n },\n timeout: this.timeout,\n });\n\n // 检查GraphQL错误\n if (\n response.data.errors &&\n Array.isArray(response.data.errors) &&\n response.data.errors.length > 0\n ) {\n throw new AdapterError(\n `GraphQL errors: ${response.data.errors.map((e: any) => e.message).join(\", \")}`,\n \"graphql\",\n {\n endpoint: this.endpoint,\n errors: response.data.errors,\n },\n );\n }\n\n let result = response.data.data || response.data;\n if (this.resultRule) {\n result = makeResponseContent(result, this.resultRule);\n return result;\n }\n return\n } catch (error) {\n if (axios.isAxiosError(error)) {\n throw new AdapterError(\n `GraphQL request failed: ${error.message}`,\n \"graphql\",\n {\n endpoint: this.endpoint,\n statusCode: error.response?.status,\n responseData: error.response?.data,\n },\n );\n }\n\n if (error instanceof ValidationError || error instanceof AdapterError) {\n throw error;\n }\n\n throw new AdapterError(\n `GraphQL request failed: ${(error as Error).message}`,\n \"graphql\",\n { endpoint: this.endpoint },\n );\n }\n };\n\n return this.executeWithRetry(executeRequest);\n }\n}\n",
11
+ "import type {\n AudioContent,\n ContentResult,\n Context,\n ImageContent,\n ResourceContent,\n ResourceLink,\n TextContent,\n} from \"@kingecg/fastmcp\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ResultProcessRule, ServiceAdapter } from \"../types\";\nimport * as grpc from \"@grpc/grpc-js\";\nimport * as protoLoader from \"@grpc/proto-loader\";\nimport { validate } from \"../validation\";\nimport { AdapterError, ValidationError } from \"../errors\";\nimport { z } from \"zod\";\nimport { makeResponseContent } from \"./result\";\n\n// gRPC适配器配置验证\nexport const grpcAdapterConfigSchema = z.object({\n protoPath: z.string().min(1, \"Proto file path is required\"),\n serviceName: z.string().min(1, \"Service name is required\"),\n methodName: z.string().min(1, \"Method name is required\"),\n address: z.string().min(1, \"gRPC server address is required\"),\n // 连接选项\n credentials: z.enum([\"insecure\", \"ssl\"]).default(\"insecure\"),\n timeout: z.number().int().positive().optional(),\n // 元数据\n metadata: z.record(z.string(), z.string()).optional(),\n // 重试配置\n retry: z\n .object({\n attempts: z.number().int().min(1).max(10).default(3),\n backoff: z.number().positive().default(1000),\n })\n .optional(),\n});\n\nexport type GrpcAdapterConfig = z.infer<typeof grpcAdapterConfigSchema>;\n\nexport class GrpcAdapter implements ServiceAdapter {\n private adapterConfig: GrpcAdapterConfig | null = null;\n private client: any = null;\n private packageDefinition: any = null;\n private proto: any = null;\n private resultRule?: ResultProcessRule;\n\n config(\n options: Record<string, any>,\n rule: ResultProcessRule | undefined = undefined,\n ): void {\n this.resultRule = rule;\n this.adapterConfig = validate(\n grpcAdapterConfigSchema,\n options,\n \"gRPC adapter configuration\",\n );\n this._loadProto();\n }\n\n private _loadProto(): void {\n if (!this.adapterConfig) {\n throw new AdapterError(\"gRPC adapter not configured\", \"grpc\");\n }\n\n try {\n const { protoPath } = this.adapterConfig;\n const packageDefinition = protoLoader.loadSync(protoPath, {\n keepCase: true,\n longs: String,\n enums: String,\n defaults: true,\n oneofs: true,\n });\n\n const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);\n this.packageDefinition = protoDescriptor;\n } catch (error) {\n throw new AdapterError(\n `Failed to load proto file: ${(error as Error).message}`,\n \"grpc\",\n { protoPath: this.adapterConfig.protoPath },\n );\n }\n }\n\n private _getClient(): any {\n if (!this.adapterConfig || !this.packageDefinition) {\n throw new AdapterError(\"gRPC adapter not properly configured\", \"grpc\");\n }\n\n if (this.client) {\n return this.client;\n }\n\n const { serviceName, address, credentials } = this.adapterConfig;\n\n try {\n // 解析服务名称(格式:package.Service)\n const servicePath = serviceName.split(\".\");\n let service = this.packageDefinition;\n\n for (const part of servicePath) {\n service = service[part];\n if (!service) {\n throw new Error(\n `Service part '${part}' not found in proto definition`,\n );\n }\n }\n\n // 创建gRPC客户端\n const credentialsType =\n credentials === \"ssl\"\n ? grpc.credentials.createSsl()\n : grpc.credentials.createInsecure();\n\n this.client = new service(address, credentialsType);\n return this.client;\n } catch (error) {\n throw new AdapterError(\n `Failed to create gRPC client: ${(error as Error).message}`,\n \"grpc\",\n { serviceName, address },\n );\n }\n }\n\n private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {\n if (!this.adapterConfig?.retry) {\n return fn();\n }\n\n const { attempts, backoff } = this.adapterConfig.retry;\n let lastError: Error;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt < attempts) {\n await new Promise((resolve) =>\n setTimeout(resolve, backoff * attempt),\n );\n }\n }\n }\n\n throw lastError!;\n }\n\n async call(\n args: StandardSchemaV1.InferOutput<any>,\n context: Context<any>,\n ): Promise<\n | AudioContent\n | ContentResult\n | ImageContent\n | ResourceContent\n | ResourceLink\n | string\n | TextContent\n | void\n > {\n if (!this.adapterConfig) {\n throw new AdapterError(\"gRPC adapter not configured\", \"grpc\");\n }\n\n const executeRequest = async () => {\n try {\n const client = this._getClient();\n const { methodName, metadata, timeout } = this.adapterConfig!;\n\n // 准备请求元数据\n const grpcMetadata = new grpc.Metadata();\n if (metadata) {\n Object.entries(metadata).forEach(([key, value]) => {\n grpcMetadata.add(key, value);\n });\n }\n\n // 查找方法\n const method = client[methodName];\n if (typeof method !== \"function\") {\n throw new Error(`Method '${methodName}' not found on service`);\n }\n\n // 执行gRPC调用\n return new Promise<any>((resolve, reject) => {\n const deadline = timeout ? Date.now() + timeout : undefined;\n\n method.call(\n client,\n args,\n grpcMetadata,\n { deadline },\n (error: any, response: any) => {\n if (error) {\n reject(\n new AdapterError(\n `gRPC call failed: ${error.message}`,\n \"grpc\",\n {\n methodName,\n code: error.code,\n details: error.details,\n },\n ),\n );\n } else {\n // 尝试将响应转换为可序列化的格式\n try {\n // 如果是普通对象或数组,直接返回\n resolve(response);\n } catch (serializationError) {\n // 如果无法序列化,返回字符串表示\n resolve(String(response));\n }\n }\n },\n );\n });\n } catch (error) {\n if (error instanceof AdapterError || error instanceof ValidationError) {\n throw error;\n }\n\n throw new AdapterError(\n `gRPC request failed: ${(error as Error).message}`,\n \"grpc\",\n {\n methodName: this.adapterConfig?.methodName,\n serviceName: this.adapterConfig?.serviceName,\n },\n );\n }\n };\n\n let result = await this.executeWithRetry(executeRequest);\n if (this.resultRule) {\n result = makeResponseContent(result, this.resultRule);\n return result;\n }\n return ;\n }\n}\n",
12
+ "import type { ServiceAdapter, AdapterFactory, ResultProcessRule } from '../types';\nimport { ConfigurationError } from '../errors';\nimport { HttpAdapter } from './http';\nimport { GraphQLAdapter } from './graphql';\nimport { GrpcAdapter } from './grpc';\n\nexport class DefaultAdapterFactory implements AdapterFactory {\n private adapterRegistry: Map<string, new () => ServiceAdapter> = new Map();\n \n constructor() {\n this.registerDefaultAdapters();\n }\n \n private registerDefaultAdapters() {\n // 默认注册HTTP适配器\n this.registerAdapter('http', HttpAdapter);\n // 注册GraphQL适配器\n this.registerAdapter('graphql', GraphQLAdapter);\n // 注册gRPC适配器\n this.registerAdapter('grpc', GrpcAdapter);\n }\n \n createAdapter(type: string, options: Record<string, any>, rule: ResultProcessRule|undefined): ServiceAdapter {\n const AdapterClass = this.adapterRegistry.get(type);\n \n if (!AdapterClass) {\n throw new ConfigurationError(\n `Unsupported adapter type: ${type}`,\n { supportedTypes: this.getSupportedTypes() }\n );\n }\n \n try {\n const adapter = new AdapterClass();\n adapter.config(options, rule);\n return adapter;\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n throw new ConfigurationError(\n `Failed to create adapter of type '${type}': ${(error as Error).message}`,\n { adapterType: type, options }\n );\n }\n }\n \n registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void {\n if (this.adapterRegistry.has(type)) {\n throw new ConfigurationError(`Adapter type '${type}' is already registered`);\n }\n this.adapterRegistry.set(type, adapterClass);\n }\n \n getSupportedTypes(): string[] {\n return Array.from(this.adapterRegistry.keys());\n }\n}\n\n// 默认工厂实例\nexport const defaultAdapterFactory = new DefaultAdapterFactory();",
12
13
  "import z from \"zod\";\nimport { mcpOptionsSchema, RegularDefineSchema, ToolDefineSchema, ToolParamSchema } from \"./validation\";\nimport type { McpOptions } from \"./types\";\nimport type { ToolParameters } from \"@kingecg/fastmcp\";\n\n\nexport function convertParamsInConfig(config: z.infer<typeof mcpOptionsSchema>): McpOptions {\n const { name, version, headers, authedFn, transport, tools } = config;\n const ntools: any = {}\n if (tools && Object.keys(tools).length > 0) {\n for (const toolName in tools) {\n const { params, outputs, ...remainDef } = (tools[toolName] as z.infer<typeof ToolDefineSchema>)\n ntools[toolName] = {\n ...remainDef\n }\n if (params) {\n ntools[toolName].params = convertParams(params)\n }\n if (outputs) {\n ntools[toolName].outputs = convertParams(outputs)\n }\n }\n }\n\n // 处理 transport 对象,确保 endpoint 符合类型要求\n let processedTransport: any = {\n transportType: 'stdio'\n };\n if (transport && transport.httpStream) {\n if (!transport.httpStream.endpoint) {\n throw new Error('transport.httpStream.endpoint is required');\n }\n // 确保 endpoint 是以 \"/\" 开头的字符串格式\n const endpoint = transport.httpStream.endpoint as string;\n if (!endpoint.startsWith('/')) {\n processedTransport = {\n ...transport,\n httpStream: {\n ...transport.httpStream,\n endpoint: `/${endpoint}` as `/${string}`\n }\n };\n } else {\n processedTransport = {\n ...transport,\n httpStream: {\n ...transport.httpStream,\n endpoint: endpoint as `/${string}`\n }\n };\n }\n }\n\n return {\n name,\n version: version as `${number}.${number}.${number}`,\n headers,\n authedFn,\n transport: processedTransport,\n tools: ntools\n }\n}\n\nexport function convertParams(params: z.infer<typeof ToolParamSchema>): ToolParameters {\n if (Array.isArray(params)) {\n if (params.length !== 1) {\n throw new Error('Only one param is supported for array define');\n }\n const zType = convertParams(params[0]);\n return z.array(zType as z.ZodType)\n }\n if (typeof params === 'object' && params !== null) {\n\n // 处理对象类型定义\n if ('type' in params) {\n try {\n const parsedparams = RegularDefineSchema.parse(params)\n const { type } = (parsedparams as any)\n\n if (type === 'object') {\n \n const objParam = params as { type: 'object', properties: Record<string, any>,description?:string }\n const p = convertParams(objParam.properties);\n \n return (p as z.ZodObject).describe(objParam.description||'');\n } else if (type === 'array') {\n \n const arrParam = params as { type: 'array', items: any,description?:string }\n const p = convertParams(arrParam.items);\n \n return (p as z.ZodType).describe(arrParam.description||'');\n } else {\n const p = convertParams(type);\n return (p as z.ZodType).describe((params as any).description||'');\n }\n } catch (e) {\n throw new Error(`Invalid param type: ${JSON.stringify(params)}`)\n }\n\n\n }\n\n // 处理普通对象(参数定义)\n const rshape: any = {}\n for (const paramName in params) {\n let pname = paramName.endsWith('?') ? paramName.slice(0, -1) : paramName\n const param = (params as any)[paramName]\n const p = convertParams(param)\n if (paramName.endsWith('?')) {\n rshape[pname] = (p as z.ZodType).optional()\n } else {\n rshape[pname] = p\n }\n }\n return z.object(rshape)\n }\n\n const typeStr = params as string // type string maybe '<type>' or '<type>:<description>'\n let desc = ''\n if (typeStr.startsWith('string')) {\n desc = typeStr.slice(7)\n return z.string().describe(desc)\n }\n if (typeStr.startsWith('number')) {\n desc = typeStr.slice(7)\n return z.number().describe(desc)\n }\n if (typeStr.startsWith('boolean')) {\n desc = typeStr.slice(8)\n return z.boolean().describe(desc)\n }\n if(typeStr.startsWith('any')){\n desc = typeStr.slice(4)\n return z.any().describe(desc)\n }\n throw new Error(`Unsupported param type: ${params}`)\n}"
13
14
  ],
14
- "mappings": "AAAA,kBAAU,yBCAH,MAAM,UAAiB,KAAM,CAGhB,KACA,WACA,QAJlB,WAAW,CACT,EACgB,EACA,EACA,EAChB,CACA,MAAM,CAAO,EAJG,YACA,kBACA,eAGhB,KAAK,KAAO,WAEhB,CAEO,MAAM,UAAwB,CAAS,CAC5C,WAAW,CAAC,EAAiB,EAA+B,CAC1D,MAAM,EAAS,mBAAoB,IAAK,CAAO,EAC/C,KAAK,KAAO,kBAEhB,CAEO,MAAM,UAA2B,CAAS,CAC/C,WAAW,CAAC,EAAiB,EAA+B,CAC1D,MAAM,EAAS,sBAAuB,IAAK,CAAO,EAClD,KAAK,KAAO,qBAEhB,CAEO,MAAM,UAAqB,CAAS,CACI,YAA7C,WAAW,CAAC,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C,GAAI,KAAK,cAAc,GAEnB,OAAO,MADS,KAAK,cAAc,GACd,KAAK,EAAM,CAAO,EAE3C,OAER,CAAC,EACH,MAAO,EAAO,CACZ,GAAI,aAAiB,GAAmB,aAAiB,EACrD,MAAM,IAAI,EACN,mCAAmC,OAAc,EAAM,UACtD,EAAc,OACnB,EAEJ,MAAM,GAIN,2BAA2B,EAUhC,CACC,IAAM,EAAY,IAAK,KAAK,iBAAiB,SAAU,EAEvD,GAAI,EAAU,WAAY,CACtB,IAAM,EAAa,IAAK,EAAU,UAAW,EAC7C,GAAI,EAAW,SAEX,EAAW,SAAW,EAAW,SAErC,GAAI,EAAW,WACX,EAAW,WAAa,EAAW,WAGvC,MAAO,IACA,EACH,WAAY,CAQhB,EAGJ,OAAO,OAGL,MAAK,EAAG,CACV,GAAG,CAAC,KAAK,OACL,MAAM,IAAI,EAAmB,oBAAoB,EAErD,IAAM,EAAqB,KAAK,4BAA4B,EAC5D,MAAM,KAAK,OAAO,MAAM,CAAkB,EAElD",
16
+ "debugId": "150EE3AE4BCE3C9864756E2164756E21",
16
17
  "names": []
17
18
  }
@@ -1,9 +1,9 @@
1
- import type { ServiceAdapter, AdapterFactory } from '../types';
1
+ import type { ServiceAdapter, AdapterFactory, ResultProcessRule } from '../types';
2
2
  export declare class DefaultAdapterFactory implements AdapterFactory {
3
3
  private adapterRegistry;
4
4
  constructor();
5
5
  private registerDefaultAdapters;
6
- createAdapter(type: string, options: Record<string, any>): ServiceAdapter;
6
+ createAdapter(type: string, options: Record<string, any>, rule: ResultProcessRule | undefined): ServiceAdapter;
7
7
  registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void;
8
8
  getSupportedTypes(): string[];
9
9
  }
@@ -1,7 +1,7 @@
1
- import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '@kingecg/fastmcp';
1
+ import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from "@kingecg/fastmcp";
2
2
  import type { StandardSchemaV1 } from "@standard-schema/spec";
3
- import type { ServiceAdapter } from '../types';
4
- import { z } from 'zod';
3
+ import type { ResultProcessRule, ServiceAdapter } from "../types";
4
+ import { z } from "zod";
5
5
  export declare const graphqlAdapterConfigSchema: z.ZodObject<{
6
6
  endpoint: z.ZodString;
7
7
  headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -22,7 +22,8 @@ export declare class GraphQLAdapter implements ServiceAdapter {
22
22
  private retryConfig?;
23
23
  private operationName?;
24
24
  private defaultVariables?;
25
- config(options: Record<string, any>): void;
25
+ private resultRule?;
26
+ config(options: Record<string, any>, rule?: ResultProcessRule | undefined): void;
26
27
  private executeWithRetry;
27
28
  call(args: StandardSchemaV1.InferOutput<any>, context: Context<any>): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void>;
28
29
  }
@@ -1,7 +1,7 @@
1
- import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '@kingecg/fastmcp';
1
+ import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from "@kingecg/fastmcp";
2
2
  import type { StandardSchemaV1 } from "@standard-schema/spec";
3
- import type { ServiceAdapter } from '../types';
4
- import { z } from 'zod';
3
+ import type { ResultProcessRule, ServiceAdapter } from "../types";
4
+ import { z } from "zod";
5
5
  export declare const grpcAdapterConfigSchema: z.ZodObject<{
6
6
  protoPath: z.ZodString;
7
7
  serviceName: z.ZodString;
@@ -24,7 +24,8 @@ export declare class GrpcAdapter implements ServiceAdapter {
24
24
  private client;
25
25
  private packageDefinition;
26
26
  private proto;
27
- config(options: Record<string, any>): void;
27
+ private resultRule?;
28
+ config(options: Record<string, any>, rule?: ResultProcessRule | undefined): void;
28
29
  private _loadProto;
29
30
  private _getClient;
30
31
  private executeWithRetry;
@@ -1,7 +1,7 @@
1
- import 'axios';
2
- import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '@kingecg/fastmcp';
1
+ import "axios";
2
+ import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from "@kingecg/fastmcp";
3
3
  import type { StandardSchemaV1 } from "@standard-schema/spec";
4
- import type { ServiceAdapter } from '../types';
4
+ import type { ResultProcessRule, ServiceAdapter } from "../types";
5
5
  export declare class HttpAdapter implements ServiceAdapter {
6
6
  private url;
7
7
  private method;
@@ -9,7 +9,8 @@ export declare class HttpAdapter implements ServiceAdapter {
9
9
  private axiosConfig;
10
10
  private timeout?;
11
11
  private retryConfig?;
12
- config(option: Record<string, any>): void;
12
+ private resultRule?;
13
+ config(option: Record<string, any>, rule?: ResultProcessRule | undefined): void;
13
14
  private executeWithRetry;
14
15
  call(args: StandardSchemaV1.InferOutput<any>, context: Context<any>): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void>;
15
16
  }
@@ -0,0 +1,4 @@
1
+ import type { AudioContent, TextContent, StructContent, ImageContent } from "@kingecg/fastmcp";
2
+ import type { ResultProcessRule } from "../types";
3
+ export declare function makeMediaContent(result: string | Buffer, mimeType: string): AudioContent | ImageContent;
4
+ export declare function makeResponseContent(result: any, rule: ResultProcessRule): TextContent | StructContent | void;
@@ -25,6 +25,15 @@ export interface McpOptions {
25
25
  };
26
26
  }
27
27
  export type ValidatedMcpOptions = _ValidatedMcpOptions;
28
+ export interface ResultProcessRule {
29
+ resultType: "audio" | "image" | "resource" | "resourceLink" | "text" | "struct";
30
+ processMethod: 'passThrough' | 'selector' | 'fixedText';
31
+ selector?: string | Record<string, string>;
32
+ fixedResponse?: {
33
+ success: string;
34
+ error: string;
35
+ };
36
+ }
28
37
  export interface ToolDefine {
29
38
  type: string;
30
39
  description?: string;
@@ -33,14 +42,15 @@ export interface ToolDefine {
33
42
  outputs?: ToolParameters;
34
43
  options: Record<string, any>;
35
44
  execute?: ToolFn;
45
+ resultProcessRule?: ResultProcessRule;
36
46
  }
37
47
  export type ToolFn = (args: StandardSchemaV1.InferOutput<any>, context: Context<any>) => Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void>;
38
48
  export interface ServiceAdapter {
39
- config(option: Record<string, any>): void;
49
+ config(option: Record<string, any>, rule: ResultProcessRule | undefined): void;
40
50
  call: ToolFn;
41
51
  }
42
52
  export interface AdapterFactory {
43
- createAdapter(type: string, options: Record<string, any>): ServiceAdapter;
53
+ createAdapter(type: string, options: Record<string, any>, rule: ResultProcessRule | undefined): ServiceAdapter;
44
54
  registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void;
45
55
  getSupportedTypes(): string[];
46
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp2service",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Model Context Protocol代理服务,支持通过多种适配器将工具调用代理到后端服务",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -68,11 +68,13 @@
68
68
  "dependencies": {
69
69
  "@grpc/grpc-js": "^1.14.3",
70
70
  "@grpc/proto-loader": "^0.8.0",
71
- "@kingecg/fastmcp": "^3.30.1",
71
+ "@kingecg/fastmcp": "^3.30.2",
72
+ "@types/lodash": "^4.17.23",
72
73
  "@valibot/to-json-schema": "^1.5.0",
73
74
  "axios": "^1.13.2",
74
75
  "commander": "^12.0.0",
75
76
  "effect": "^3.19.15",
77
+ "lodash": "^4.17.23",
76
78
  "sury": "^11.0.0-alpha.4",
77
79
  "yaml": "^2.0.0",
78
80
  "zod": "^4.3.6"