mcp2service 1.0.0 → 1.0.1
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/LICENSE +21 -0
- package/dist/cjs/index.js +3 -423
- package/dist/cjs/index.js.map +16 -0
- package/dist/cli/cli.js +49 -2010
- package/dist/cli/cli.js.map +18 -0
- package/dist/esm/index.js +3 -423
- package/dist/esm/index.js.map +16 -0
- package/package.json +5 -22
- package/dist/cjs/adapters/factory.js +0 -51901
- package/dist/cjs/adapters/graphql.js +0 -28866
- package/dist/cjs/adapters/grpc.js +0 -36898
- package/dist/cjs/adapters/http.js +0 -28835
- package/dist/cjs/adapters/index.js +0 -51906
- package/dist/cjs/cli.js +0 -2283
- package/dist/cjs/errors.js +0 -88
- package/dist/cjs/mpc-proxy.js +0 -188884
- package/dist/cjs/types.js +0 -29
- package/dist/cjs/validation.js +0 -13971
- package/dist/types/adapters/factory.d.ts +0 -10
- package/dist/types/adapters/graphql.d.ts +0 -28
- package/dist/types/adapters/grpc.d.ts +0 -32
- package/dist/types/adapters/http.d.ts +0 -15
- package/dist/types/adapters/index.d.ts +0 -4
- package/dist/types/cli.d.ts +0 -2
- package/dist/types/errors.d.ts +0 -23
- package/dist/types/index.d.ts +0 -3
- package/dist/types/mpc-proxy.d.ts +0 -12
- package/dist/types/types.d.ts +0 -45
- package/dist/types/validation.d.ts +0 -49
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ServiceAdapter, AdapterFactory } from '../types';
|
|
2
|
-
export declare class DefaultAdapterFactory implements AdapterFactory {
|
|
3
|
-
private adapterRegistry;
|
|
4
|
-
constructor();
|
|
5
|
-
private registerDefaultAdapters;
|
|
6
|
-
createAdapter(type: string, options: Record<string, any>): ServiceAdapter;
|
|
7
|
-
registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void;
|
|
8
|
-
getSupportedTypes(): string[];
|
|
9
|
-
}
|
|
10
|
-
export declare const defaultAdapterFactory: DefaultAdapterFactory;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from 'fastmcp';
|
|
2
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
import type { ServiceAdapter } from '../types';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
export declare const graphqlAdapterConfigSchema: z.ZodObject<{
|
|
6
|
-
endpoint: z.ZodString;
|
|
7
|
-
headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
8
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
operationName: z.ZodOptional<z.ZodString>;
|
|
10
|
-
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
11
|
-
retry: z.ZodOptional<z.ZodObject<{
|
|
12
|
-
attempts: z.ZodDefault<z.ZodNumber>;
|
|
13
|
-
backoff: z.ZodDefault<z.ZodNumber>;
|
|
14
|
-
}, z.core.$strip>>;
|
|
15
|
-
}, z.core.$strip>;
|
|
16
|
-
export type GraphQLAdapterConfig = z.infer<typeof graphqlAdapterConfigSchema>;
|
|
17
|
-
export declare class GraphQLAdapter implements ServiceAdapter {
|
|
18
|
-
private adapterConfig;
|
|
19
|
-
private endpoint;
|
|
20
|
-
private headers;
|
|
21
|
-
private timeout?;
|
|
22
|
-
private retryConfig?;
|
|
23
|
-
private operationName?;
|
|
24
|
-
private defaultVariables?;
|
|
25
|
-
config(options: Record<string, any>): void;
|
|
26
|
-
private executeWithRetry;
|
|
27
|
-
call(args: StandardSchemaV1.InferOutput<any>, context: Context<any>): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void>;
|
|
28
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from 'fastmcp';
|
|
2
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
import type { ServiceAdapter } from '../types';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
export declare const grpcAdapterConfigSchema: z.ZodObject<{
|
|
6
|
-
protoPath: z.ZodString;
|
|
7
|
-
serviceName: z.ZodString;
|
|
8
|
-
methodName: z.ZodString;
|
|
9
|
-
address: z.ZodString;
|
|
10
|
-
credentials: z.ZodDefault<z.ZodEnum<{
|
|
11
|
-
insecure: "insecure";
|
|
12
|
-
ssl: "ssl";
|
|
13
|
-
}>>;
|
|
14
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
15
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
16
|
-
retry: z.ZodOptional<z.ZodObject<{
|
|
17
|
-
attempts: z.ZodDefault<z.ZodNumber>;
|
|
18
|
-
backoff: z.ZodDefault<z.ZodNumber>;
|
|
19
|
-
}, z.core.$strip>>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
export type GrpcAdapterConfig = z.infer<typeof grpcAdapterConfigSchema>;
|
|
22
|
-
export declare class GrpcAdapter implements ServiceAdapter {
|
|
23
|
-
private adapterConfig;
|
|
24
|
-
private client;
|
|
25
|
-
private packageDefinition;
|
|
26
|
-
private proto;
|
|
27
|
-
config(options: Record<string, any>): void;
|
|
28
|
-
private _loadProto;
|
|
29
|
-
private _getClient;
|
|
30
|
-
private executeWithRetry;
|
|
31
|
-
call(args: StandardSchemaV1.InferOutput<any>, context: Context<any>): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void>;
|
|
32
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import 'axios';
|
|
2
|
-
import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent } from 'fastmcp';
|
|
3
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
import type { ServiceAdapter } from '../types';
|
|
5
|
-
export declare class HttpAdapter implements ServiceAdapter {
|
|
6
|
-
private url;
|
|
7
|
-
private method;
|
|
8
|
-
private headers;
|
|
9
|
-
private axiosConfig;
|
|
10
|
-
private timeout?;
|
|
11
|
-
private retryConfig?;
|
|
12
|
-
config(option: Record<string, any>): void;
|
|
13
|
-
private executeWithRetry;
|
|
14
|
-
call(args: StandardSchemaV1.InferOutput<any>, context: Context<any>): Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void>;
|
|
15
|
-
}
|
package/dist/types/cli.d.ts
DELETED
package/dist/types/errors.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export declare class MCPError extends Error {
|
|
2
|
-
readonly code: string;
|
|
3
|
-
readonly statusCode?: number | undefined;
|
|
4
|
-
readonly details?: Record<string, any> | undefined;
|
|
5
|
-
constructor(message: string, code: string, statusCode?: number | undefined, details?: Record<string, any> | undefined);
|
|
6
|
-
}
|
|
7
|
-
export declare class ValidationError extends MCPError {
|
|
8
|
-
constructor(message: string, details?: Record<string, any>);
|
|
9
|
-
}
|
|
10
|
-
export declare class ConfigurationError extends MCPError {
|
|
11
|
-
constructor(message: string, details?: Record<string, any>);
|
|
12
|
-
}
|
|
13
|
-
export declare class AdapterError extends MCPError {
|
|
14
|
-
readonly adapterName: string;
|
|
15
|
-
constructor(message: string, adapterName: string, details?: Record<string, any>);
|
|
16
|
-
}
|
|
17
|
-
export declare class AuthenticationError extends MCPError {
|
|
18
|
-
constructor(message: string, details?: Record<string, any>);
|
|
19
|
-
}
|
|
20
|
-
export declare class RateLimitError extends MCPError {
|
|
21
|
-
constructor(message: string, details?: Record<string, any>);
|
|
22
|
-
}
|
|
23
|
-
export type ErrorType = 'VALIDATION_ERROR' | 'CONFIGURATION_ERROR' | 'ADAPTER_ERROR' | 'AUTHENTICATION_ERROR' | 'RATE_LIMIT_ERROR' | 'INTERNAL_ERROR';
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FastMCP } from 'fastmcp';
|
|
2
|
-
import * as types from './types';
|
|
3
|
-
export declare class McpProxy {
|
|
4
|
-
server: FastMCP | undefined;
|
|
5
|
-
private _toolhandlers;
|
|
6
|
-
private validatedOptions;
|
|
7
|
-
constructor(options: types.McpOptions);
|
|
8
|
-
_createMcpServer(): void;
|
|
9
|
-
private _registerTool;
|
|
10
|
-
private _convertTransportForFastMCP;
|
|
11
|
-
start(): Promise<void>;
|
|
12
|
-
}
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as http from "http";
|
|
2
|
-
import type { AudioContent, ContentResult, Context, ImageContent, ResourceContent, ResourceLink, TextContent, ToolParameters } from 'fastmcp';
|
|
3
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
-
import type { EventStore } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
5
|
-
import type { ValidatedMcpOptions as _ValidatedMcpOptions } from './validation';
|
|
6
|
-
type Authenticate<T> = (request: http.IncomingMessage) => Promise<T>;
|
|
7
|
-
export interface McpOptions {
|
|
8
|
-
name: string;
|
|
9
|
-
version: `${number}.${number}.${number}`;
|
|
10
|
-
headers?: Array<string>;
|
|
11
|
-
authedFn?: Authenticate<Record<string, any>>;
|
|
12
|
-
transport: Partial<{
|
|
13
|
-
httpStream: {
|
|
14
|
-
enableJsonResponse?: boolean;
|
|
15
|
-
endpoint?: `/${string}`;
|
|
16
|
-
eventStore?: EventStore;
|
|
17
|
-
host?: string;
|
|
18
|
-
port: number;
|
|
19
|
-
stateless?: boolean;
|
|
20
|
-
};
|
|
21
|
-
transportType: "httpStream" | "stdio";
|
|
22
|
-
}>;
|
|
23
|
-
tools: {
|
|
24
|
-
[toolName: string]: ToolDefine;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export type ValidatedMcpOptions = _ValidatedMcpOptions;
|
|
28
|
-
export interface ToolDefine {
|
|
29
|
-
type: string;
|
|
30
|
-
description?: string;
|
|
31
|
-
params: ToolParameters;
|
|
32
|
-
options: Record<string, any>;
|
|
33
|
-
execute?: ToolFn;
|
|
34
|
-
}
|
|
35
|
-
export type ToolFn = (args: StandardSchemaV1.InferOutput<any>, context: Context<any>) => Promise<AudioContent | ContentResult | ImageContent | ResourceContent | ResourceLink | string | TextContent | void>;
|
|
36
|
-
export interface ServiceAdapter {
|
|
37
|
-
config(option: Record<string, any>): void;
|
|
38
|
-
call: ToolFn;
|
|
39
|
-
}
|
|
40
|
-
export interface AdapterFactory {
|
|
41
|
-
createAdapter(type: string, options: Record<string, any>): ServiceAdapter;
|
|
42
|
-
registerAdapter(type: string, adapterClass: new () => ServiceAdapter): void;
|
|
43
|
-
getSupportedTypes(): string[];
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { IncomingMessage } from 'http';
|
|
3
|
-
export declare const mcpOptionsSchema: z.ZodObject<{
|
|
4
|
-
name: z.ZodString;
|
|
5
|
-
version: z.ZodString;
|
|
6
|
-
headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
-
authedFn: z.ZodOptional<z.ZodCustom<(request: IncomingMessage) => Promise<Record<string, any>>, (request: IncomingMessage) => Promise<Record<string, any>>>>;
|
|
8
|
-
transport: z.ZodObject<{
|
|
9
|
-
httpStream: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
10
|
-
enableJsonResponse: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
-
endpoint: z.ZodOptional<z.ZodString>;
|
|
12
|
-
eventStore: z.ZodOptional<z.ZodAny>;
|
|
13
|
-
host: z.ZodOptional<z.ZodString>;
|
|
14
|
-
port: z.ZodNumber;
|
|
15
|
-
stateless: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
-
}, z.core.$strip>>>;
|
|
17
|
-
transportType: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
18
|
-
httpStream: "httpStream";
|
|
19
|
-
stdio: "stdio";
|
|
20
|
-
}>>>;
|
|
21
|
-
}, z.core.$strip>;
|
|
22
|
-
tools: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
23
|
-
type: z.ZodString;
|
|
24
|
-
description: z.ZodOptional<z.ZodString>;
|
|
25
|
-
params: z.ZodAny;
|
|
26
|
-
options: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
27
|
-
execute: z.ZodOptional<z.ZodCustom<(args: any, context: any) => Promise<any>, (args: any, context: any) => Promise<any>>>;
|
|
28
|
-
}, z.core.$strip>>;
|
|
29
|
-
}, z.core.$strict>;
|
|
30
|
-
export declare const toolParamsSchema: z.ZodObject<{}, z.core.$loose>;
|
|
31
|
-
export declare const httpAdapterConfigSchema: z.ZodObject<{
|
|
32
|
-
url: z.ZodString;
|
|
33
|
-
method: z.ZodDefault<z.ZodEnum<{
|
|
34
|
-
GET: "GET";
|
|
35
|
-
POST: "POST";
|
|
36
|
-
PUT: "PUT";
|
|
37
|
-
DELETE: "DELETE";
|
|
38
|
-
PATCH: "PATCH";
|
|
39
|
-
}>>;
|
|
40
|
-
headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
41
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
42
|
-
retry: z.ZodOptional<z.ZodObject<{
|
|
43
|
-
attempts: z.ZodDefault<z.ZodNumber>;
|
|
44
|
-
backoff: z.ZodDefault<z.ZodNumber>;
|
|
45
|
-
}, z.core.$strip>>;
|
|
46
|
-
}, z.core.$strip>;
|
|
47
|
-
export declare function validate<T>(schema: z.ZodSchema<T>, data: unknown, context?: string): T;
|
|
48
|
-
export type ValidatedMcpOptions = z.infer<typeof mcpOptionsSchema>;
|
|
49
|
-
export type ValidatedHttpAdapterConfig = z.infer<typeof httpAdapterConfigSchema>;
|