mcp2service 1.0.1 → 1.0.3
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/README.md +16 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +10 -9
- package/dist/cli/cli.js +12 -12
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +10 -9
- package/dist/types/adapters/factory.d.ts +10 -0
- package/dist/types/adapters/graphql.d.ts +28 -0
- package/dist/types/adapters/grpc.d.ts +32 -0
- package/dist/types/adapters/http.d.ts +15 -0
- package/dist/types/adapters/index.d.ts +4 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/config.d.ts +6 -0
- package/dist/types/errors.d.ts +23 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/mpc-proxy.d.ts +12 -0
- package/dist/types/types.d.ts +47 -0
- package/dist/types/validation.d.ts +64 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -42,7 +42,22 @@ const proxy = new McpProxy({
|
|
|
42
42
|
'http-example': {
|
|
43
43
|
type: 'http',
|
|
44
44
|
description: '示例HTTP工具',
|
|
45
|
-
params: {
|
|
45
|
+
params: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
description: '请求参数',
|
|
48
|
+
properties: {
|
|
49
|
+
name:'string:姓名',
|
|
50
|
+
age:{
|
|
51
|
+
type: 'number',
|
|
52
|
+
description: '年龄'
|
|
53
|
+
},
|
|
54
|
+
classes:{
|
|
55
|
+
type: 'array',
|
|
56
|
+
description: '课程列表',
|
|
57
|
+
items: 'string:课程名称'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
46
61
|
options: {
|
|
47
62
|
url: 'https://api.example.com/data',
|
|
48
63
|
method: 'GET',
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var N=Object.create;var{getPrototypeOf:F,defineProperty:R,getOwnPropertyNames:_,getOwnPropertyDescriptor:W}=Object,S=Object.prototype.hasOwnProperty;var x=(t,e,i)=>{i=t!=null?N(F(t)):{};let r=e||!t||!t.__esModule?R(i,"default",{value:t,enumerable:!0}):i;for(let s of _(t))if(!S.call(r,s))R(r,s,{get:()=>t[s],enumerable:!0});return r},v=new WeakMap,j=(t)=>{var e=v.get(t),i;if(e)return e;if(e=R({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")_(t).map((r)=>!S.call(e,r)&&R(e,r,{get:()=>t[r],enumerable:!(i=W(t,r))||i.enumerable}));return v.set(t,e),e};var J=(t,e)=>{for(var i in e)R(t,i,{get:e[i],enumerable:!0,configurable:!0,set:(r)=>e[i]=()=>r})};var X={};J(X,{grpcAdapterConfigSchema:()=>U,graphqlAdapterConfigSchema:()=>$,defaultAdapterFactory:()=>q,McpProxy:()=>D,HttpAdapter:()=>T,GrpcAdapter:()=>b,GraphQLAdapter:()=>w,DefaultAdapterFactory:()=>O});module.exports=j(X);var k=require("fastmcp");class l extends Error{code;statusCode;details;constructor(t,e,i,r){super(t);this.code=e;this.statusCode=i;this.details=r;this.name="MCPError"}}class c extends l{constructor(t,e){super(t,"VALIDATION_ERROR",400,e);this.name="ValidationError"}}class u extends l{constructor(t,e){super(t,"CONFIGURATION_ERROR",500,e);this.name="ConfigurationError"}}class a extends l{adapterName;constructor(t,e,i){super(t,"ADAPTER_ERROR",502,{adapterName:e,...i});this.adapterName=e;this.name="AdapterError"}}var rt=require("axios"),I=x(require("axios"));var n=require("zod");var B=n.z.custom((t)=>typeof t==="function",{message:"authedFn must be a function that returns a Promise"}),K=n.z.custom((t)=>typeof t==="function",{message:"execute must be a function"}),Q=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:B.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(),n.z.object({type:n.z.string().min(1,"Tool type is required"),description:n.z.string().optional(),params:n.z.any(),options:n.z.record(n.z.string(),n.z.any()),execute:K.optional()}))}).strict(),tt=n.z.object({}).passthrough(),V=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 m(t,e,i){let r=t.safeParse(e);if(!r.success){let s=r.error.issues.map((o)=>({path:o.path.join("."),message:o.message,code:o.code})),p=i?`${i} validation failed`:"Validation failed";throw new c(p,{details:s})}return r.data}class T{url="";method="POST";headers={};axiosConfig={};timeout;retryConfig;config(t){let e=m(V,t,"HTTP adapter configuration");this.url=e.url,this.method=e.method,this.headers=e.headers,this.timeout=e.timeout,this.retryConfig=e.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,r;for(let s=1;s<=e;s++)try{return await t()}catch(p){if(r=p,s<e)await new Promise((o)=>setTimeout(o,i*s))}throw r}async call(t,e){let i=async()=>{let r={...this.axiosConfig};if(this.method.toUpperCase()==="GET")r.params=t;else r.data=t;try{return(await I.default.request(r)).data}catch(s){if(I.default.isAxiosError(s))throw new a(`HTTP request failed: ${s.message}`,"http",{url:this.url,method:this.method,statusCode:s.response?.status,responseData:s.response?.data});throw new a(`Request failed: ${s.message}`,"http",{url:this.url,method:this.method})}};return this.executeWithRetry(i)}}var L=x(require("axios"));var d=require("zod"),$=d.z.object({endpoint:d.z.string().url("Valid GraphQL endpoint URL is required"),headers:d.z.record(d.z.string(),d.z.string()).default({}),timeout:d.z.number().int().positive().optional(),operationName:d.z.string().optional(),variables:d.z.record(d.z.string(),d.z.any()).optional(),retry:d.z.object({attempts:d.z.number().int().min(1).max(10).default(3),backoff:d.z.number().positive().default(1000)}).optional()});class w{adapterConfig=null;endpoint="";headers={};timeout;retryConfig;operationName;defaultVariables;config(t){this.adapterConfig=m($,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,r;for(let s=1;s<=e;s++)try{return await t()}catch(p){if(r=p,s<e)await new Promise((o)=>setTimeout(o,i*s))}throw r}async call(t,e){if(!this.adapterConfig)throw new a("GraphQL adapter not configured","graphql");let i=async()=>{try{let r=t.query||t.body||t.data;if(!r)throw new c("GraphQL query is required",{args:t});let s=t.variables||this.defaultVariables||{},p=t.operationName||this.operationName,o={query:typeof r==="string"?r:JSON.stringify(r),variables:s,operationName:p},f=await L.default.post(this.endpoint,o,{headers:{"Content-Type":"application/json",...this.headers},timeout:this.timeout});if(f.data.errors&&Array.isArray(f.data.errors)&&f.data.errors.length>0)throw new a(`GraphQL errors: ${f.data.errors.map((y)=>y.message).join(", ")}`,"graphql",{endpoint:this.endpoint,errors:f.data.errors});return f.data.data||f.data}catch(r){if(L.default.isAxiosError(r))throw new a(`GraphQL request failed: ${r.message}`,"graphql",{endpoint:this.endpoint,statusCode:r.response?.status,responseData:r.response?.data});if(r instanceof c||r instanceof a)throw r;throw new a(`GraphQL request failed: ${r.message}`,"graphql",{endpoint:this.endpoint})}};return this.executeWithRetry(i)}}var g=x(require("@grpc/grpc-js")),P=x(require("@grpc/proto-loader"));var h=require("zod"),U=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 b{adapterConfig=null;client=null;packageDefinition=null;proto=null;config(t){this.adapterConfig=m(U,t,"gRPC adapter configuration"),this._loadProto()}_loadProto(){if(!this.adapterConfig)throw new a("gRPC adapter not configured","grpc");try{let{protoPath:t}=this.adapterConfig,e=P.loadSync(t,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0}),i=g.loadPackageDefinition(e);this.packageDefinition=i}catch(t){throw new a(`Failed to load proto file: ${t.message}`,"grpc",{protoPath:this.adapterConfig.protoPath})}}_getClient(){if(!this.adapterConfig||!this.packageDefinition)throw new a("gRPC adapter not properly configured","grpc");if(this.client)return this.client;let{serviceName:t,address:e,credentials:i}=this.adapterConfig;try{let r=t.split("."),s=this.packageDefinition;for(let o of r)if(s=s[o],!s)throw Error(`Service part '${o}' not found in proto definition`);let p=i==="ssl"?g.credentials.createSsl():g.credentials.createInsecure();return this.client=new s(e,p),this.client}catch(r){throw new a(`Failed to create gRPC client: ${r.message}`,"grpc",{serviceName:t,address:e})}}async executeWithRetry(t){if(!this.adapterConfig?.retry)return t();let{attempts:e,backoff:i}=this.adapterConfig.retry,r;for(let s=1;s<=e;s++)try{return await t()}catch(p){if(r=p,s<e)await new Promise((o)=>setTimeout(o,i*s))}throw r}async call(t,e){if(!this.adapterConfig)throw new a("gRPC adapter not configured","grpc");let i=async()=>{try{let r=this._getClient(),{methodName:s,metadata:p,timeout:o}=this.adapterConfig,f=new g.Metadata;if(p)Object.entries(p).forEach(([C,E])=>{f.add(C,E)});let y=r[s];if(typeof y!=="function")throw Error(`Method '${s}' not found on service`);return new Promise((C,E)=>{let H=o?Date.now()+o:void 0;y.call(r,t,f,{deadline:H},(A,G)=>{if(A)E(new a(`gRPC call failed: ${A.message}`,"grpc",{methodName:s,code:A.code,details:A.details}));else try{C(G)}catch(Y){C(String(G))}})})}catch(r){if(r instanceof a||r instanceof c)throw r;throw new a(`gRPC request failed: ${r.message}`,"grpc",{methodName:this.adapterConfig?.methodName,serviceName:this.adapterConfig?.serviceName})}};return this.executeWithRetry(i)}}class O{adapterRegistry=new Map;constructor(){this.registerDefaultAdapters()}registerDefaultAdapters(){this.registerAdapter("http",T),this.registerAdapter("graphql",w),this.registerAdapter("grpc",b)}createAdapter(t,e){let i=this.adapterRegistry.get(t);if(!i)throw new u(`Unsupported adapter type: ${t}`,{supportedTypes:this.getSupportedTypes()});try{let r=new i;return r.config(e),r}catch(r){if(r instanceof u)throw r;throw new u(`Failed to create adapter of type '${t}': ${r.message}`,{adapterType:t,options:e})}}registerAdapter(t,e){if(this.adapterRegistry.has(t))throw new u(`Adapter type '${t}' is already registered`);this.adapterRegistry.set(t,e)}getSupportedTypes(){return Array.from(this.adapterRegistry.keys())}}var q=new O;class D{server=void 0;_toolhandlers={};validatedOptions;constructor(t){this.validatedOptions=m(Q,t,"MCP configuration"),this._createMcpServer()}_createMcpServer(){let t=this.validatedOptions.version;this.server=new k.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((r)=>e.headers[r]);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 u(`Tool '${t}' must have a type`);try{let i=q.createAdapter(e.type,e.options);this._toolhandlers[t]=i,this.server.addTool({name:t,description:e.description,parameters:e.params,execute:async(r,s)=>{return await i.call(r,s)}})}catch(i){if(i instanceof c||i instanceof u)throw new u(`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 u("Server not created");let t=this._convertTransportForFastMCP();await this.server.start(t)}}
|
|
1
|
+
var j=Object.create;var{getPrototypeOf:P,defineProperty:I,getOwnPropertyNames:D,getOwnPropertyDescriptor:z}=Object,F=Object.prototype.hasOwnProperty;var l=(t,e,r)=>{r=t!=null?j(P(t)):{};let i=e||!t||!t.__esModule?I(r,"default",{value:t,enumerable:!0}):r;for(let s of D(t))if(!F.call(i,s))I(i,s,{get:()=>t[s],enumerable:!0});return i},v=new WeakMap,tt=(t)=>{var e=v.get(t),r;if(e)return e;if(e=I({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")D(t).map((i)=>!F.call(e,i)&&I(e,i,{get:()=>t[i],enumerable:!(r=z(t,i))||r.enumerable}));return v.set(t,e),e};var et=(t,e)=>{for(var r in e)I(t,r,{get:e[r],enumerable:!0,configurable:!0,set:(i)=>e[r]=()=>i})};var st={};et(st,{grpcAdapterConfigSchema:()=>Z,graphqlAdapterConfigSchema:()=>X,defaultAdapterFactory:()=>W,McpProxy:()=>N,HttpAdapter:()=>Q,GrpcAdapter:()=>T,GraphQLAdapter:()=>V,DefaultAdapterFactory:()=>H});module.exports=tt(st);var U=require("@kingecg/fastmcp");class b extends Error{code;statusCode;details;constructor(t,e,r,i){super(t);this.code=e;this.statusCode=r;this.details=i;this.name="MCPError"}}class c extends b{constructor(t,e){super(t,"VALIDATION_ERROR",400,e);this.name="ValidationError"}}class p extends b{constructor(t,e){super(t,"CONFIGURATION_ERROR",500,e);this.name="ConfigurationError"}}class h extends b{adapterName;constructor(t,e,r){super(t,"ADAPTER_ERROR",502,{adapterName:e,...r});this.adapterName=e;this.name="AdapterError"}}var gt=require("axios"),$=l(require("axios"));var n=require("zod");var it=n.z.custom((t)=>typeof t==="function",{message:"authedFn must be a function that returns a Promise"}),nt=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")]),G=n.z.object({type:C,description:n.z.string().optional()}),O=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,G,O,_,n.z.record(n.z.string(),C),n.z.array(C)]))})),_=n.z.lazy(()=>n.z.object({type:n.z.literal("array"),description:n.z.string().optional(),items:n.z.union([C,G,O,_,n.z.record(n.z.string(),C),n.z.array(C)])})),J=n.z.lazy(()=>n.z.union([G,O,_])),S=n.z.union([C,G,O,_,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:S.optional(),outputs:S.optional(),options:n.z.record(n.z.string(),n.z.any()),execute:nt.optional()}),B=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:it.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(),ft=n.z.object({}).passthrough(),K=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,e,r){let i=t.safeParse(e);if(!i.success){let s=i.error.issues.map((o)=>({path:o.path.join("."),message:o.message,code:o.code})),d=r?`${r} validation failed`:"Validation failed";throw new c(d,{details:s})}return i.data}class Q{url="";method="POST";headers={};axiosConfig={};timeout;retryConfig;config(t){let e=x(K,t,"HTTP adapter configuration");this.url=e.url,this.method=e.method,this.headers=e.headers,this.timeout=e.timeout,this.retryConfig=e.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:r}=this.retryConfig,i;for(let s=1;s<=e;s++)try{return await t()}catch(d){if(i=d,s<e)await new Promise((o)=>setTimeout(o,r*s))}throw i}async call(t,e){let r=async()=>{let i={...this.axiosConfig};if(this.method.toUpperCase()==="GET")i.params=t;else i.data=t;try{return(await $.default.request(i)).data}catch(s){if($.default.isAxiosError(s))throw new h(`HTTP request failed: ${s.message}`,"http",{url:this.url,method:this.method,statusCode:s.response?.status,responseData:s.response?.data});throw new h(`Request failed: ${s.message}`,"http",{url:this.url,method:this.method})}};return this.executeWithRetry(r)}}var k=l(require("axios"));var f=require("zod"),X=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(X,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:r}=this.retryConfig,i;for(let s=1;s<=e;s++)try{return await t()}catch(d){if(i=d,s<e)await new Promise((o)=>setTimeout(o,r*s))}throw i}async call(t,e){if(!this.adapterConfig)throw new h("GraphQL adapter not configured","graphql");let r=async()=>{try{let i=t.query||t.body||t.data;if(!i)throw new c("GraphQL query is required",{args:t});let s=t.variables||this.defaultVariables||{},d=t.operationName||this.operationName,o={query:typeof i==="string"?i:JSON.stringify(i),variables:s,operationName:d},u=await k.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(i){if(k.default.isAxiosError(i))throw new h(`GraphQL request failed: ${i.message}`,"graphql",{endpoint:this.endpoint,statusCode:i.response?.status,responseData:i.response?.data});if(i instanceof c||i instanceof h)throw i;throw new h(`GraphQL request failed: ${i.message}`,"graphql",{endpoint:this.endpoint})}};return this.executeWithRetry(r)}}var a=l(require("@grpc/grpc-js")),Y=l(require("@grpc/proto-loader"));var R=require("zod"),Z=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 T{adapterConfig=null;client=null;packageDefinition=null;proto=null;config(t){this.adapterConfig=x(Z,t,"gRPC adapter configuration"),this._loadProto()}_loadProto(){if(!this.adapterConfig)throw new h("gRPC adapter not configured","grpc");try{let{protoPath:t}=this.adapterConfig,e=Y.loadSync(t,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0}),r=a.loadPackageDefinition(e);this.packageDefinition=r}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:e,credentials:r}=this.adapterConfig;try{let i=t.split("."),s=this.packageDefinition;for(let o of i)if(s=s[o],!s)throw Error(`Service part '${o}' not found in proto definition`);let d=r==="ssl"?a.credentials.createSsl():a.credentials.createInsecure();return this.client=new s(e,d),this.client}catch(i){throw new h(`Failed to create gRPC client: ${i.message}`,"grpc",{serviceName:t,address:e})}}async executeWithRetry(t){if(!this.adapterConfig?.retry)return t();let{attempts:e,backoff:r}=this.adapterConfig.retry,i;for(let s=1;s<=e;s++)try{return await t()}catch(d){if(i=d,s<e)await new Promise((o)=>setTimeout(o,r*s))}throw i}async call(t,e){if(!this.adapterConfig)throw new h("gRPC adapter not configured","grpc");let r=async()=>{try{let i=this._getClient(),{methodName:s,metadata:d,timeout:o}=this.adapterConfig,u=new a.Metadata;if(d)Object.entries(d).forEach(([g,w])=>{u.add(g,w)});let A=i[s];if(typeof A!=="function")throw Error(`Method '${s}' not found on service`);return new Promise((g,w)=>{let q=o?Date.now()+o:void 0;A.call(i,t,u,{deadline:q},(E,m)=>{if(E)w(new h(`gRPC call failed: ${E.message}`,"grpc",{methodName:s,code:E.code,details:E.details}));else try{g(m)}catch(ot){g(String(m))}})})}catch(i){if(i instanceof h||i instanceof c)throw i;throw new h(`gRPC request failed: ${i.message}`,"grpc",{methodName:this.adapterConfig?.methodName,serviceName:this.adapterConfig?.serviceName})}};return this.executeWithRetry(r)}}class H{adapterRegistry=new Map;constructor(){this.registerDefaultAdapters()}registerDefaultAdapters(){this.registerAdapter("http",Q),this.registerAdapter("graphql",V),this.registerAdapter("grpc",T)}createAdapter(t,e){let r=this.adapterRegistry.get(t);if(!r)throw new p(`Unsupported adapter type: ${t}`,{supportedTypes:this.getSupportedTypes()});try{let i=new r;return i.config(e),i}catch(i){if(i instanceof p)throw i;throw new p(`Failed to create adapter of type '${t}': ${i.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 W=new H;var L=l(require("zod"));function M(t){let{name:e,version:r,headers:i,authedFn:s,transport:d,tools:o}=t,u={};if(o&&Object.keys(o).length>0)for(let g in o){let{params:w,outputs:q,...E}=o[g];if(u[g]={...E},w)u[g].params=y(w);if(q)u[g].outputs=y(q)}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:e,version:r,headers:i,authedFn:s,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 i=y(t[0]);return L.default.array(i)}if(typeof t==="object"&&t!==null){if("type"in t)try{let s=J.parse(t),{type:d}=s;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(s){throw Error(`Invalid param type: ${JSON.stringify(t)}`)}let i={};for(let s in t){let d=s.endsWith("?")?s.slice(0,-1):s,o=t[s],u=y(o);if(s.endsWith("?"))i[d]=u.optional();else i[d]=u}return L.default.object(i)}let e=t,r="";if(e.startsWith("string"))return r=e.slice(7),L.default.string().describe(r);if(e.startsWith("number"))return r=e.slice(7),L.default.number().describe(r);if(e.startsWith("boolean"))return r=e.slice(8),L.default.boolean().describe(r);throw Error(`Unsupported param type: ${t}`)}class N{server=void 0;_toolhandlers={};validatedOptions;constructor(t){this.validatedOptions=M(x(B,t,"MCP configuration")),this._createMcpServer()}_createMcpServer(){let t=this.validatedOptions.version;this.server=new U.FastMCP({name:this.validatedOptions.name,version:t,authenticate:async(e)=>{let r={};if(this.validatedOptions.authedFn)r=await this.validatedOptions.authedFn(e);if(this.validatedOptions.headers)r.headers=this.validatedOptions.headers.map((i)=>e.headers[i]);return r}});for(let e in this.validatedOptions.tools){let r=this.validatedOptions.tools[e];if(r)this._registerTool(e,r)}}_registerTool(t,e){if(!e.type)throw new p(`Tool '${t}' must have a type`);try{let r=W.createAdapter(e.type,e.options);this._toolhandlers[t]=r,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};return await r.call(i,s)}})}catch(r){if(r instanceof c||r instanceof p)throw new p(`Invalid configuration for tool '${t}': ${r.message}`,r.details);throw r}}_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)}}
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=53F86035929153E364756E2164756E21
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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"],
|
|
3
|
+
"sources": ["../../mpc-proxy.ts", "../../errors.ts", "../../adapters/http.ts", "../../validation.ts", "../../adapters/graphql.ts", "../../adapters/grpc.ts", "../../adapters/factory.ts", "../../config.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { FastMCP } from '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\";\
|
|
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';\nexport class McpProxy {\n server: FastMCP|undefined = undefined\n private _toolhandlers: Record<string, types.ServiceAdapter> = {}\n private validatedOptions: ValidatedMcpOptions;\n \n constructor(options: types.McpOptions) {\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}",
|
|
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 '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}",
|
|
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});\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(),
|
|
9
|
-
"import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from '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 '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();"
|
|
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}",
|
|
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])\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 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 z.record(z.string(),ParamTypeUnion),\n z.array(ParamTypeUnion)])}));\n\nexport const RegularDefineSchema = z.lazy(()=>z.union([\n ParamTypObject,\n ParamObjectType,\n ParamArrayType\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 }));\n \n const message = context \n ? `${context} validation failed`\n : 'Validation failed';\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();",
|
|
12
|
+
"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 throw new Error(`Unsupported param type: ${params}`)\n}"
|
|
12
13
|
],
|
|
13
|
-
"mappings": "s4BAAyB,IAAzB,qBCAO,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,oBAKA,sBCLkB,IAAlB,iBAKA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