@vapi-network/mcp 0.1.1 → 0.2.0-dev.2
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 +201 -0
- package/README.md +163 -140
- package/dist/index.d.ts +4 -0
- package/dist/{server.js → index.js} +30919 -41044
- package/dist/index.js.map +6 -0
- package/dist/server.d.ts +70 -0
- package/dist/tools/call.d.ts +73 -0
- package/dist/tools/inspect.d.ts +11 -0
- package/dist/tools/search.d.ts +1 -0
- package/dist/tools/wallet.d.ts +13 -0
- package/dist/x402.d.ts +19 -0
- package/package.json +15 -19
- package/dist/cli.js +0 -53262
- package/dist/cli.js.map +0 -6
- package/dist/server.js.map +0 -6
- package/dist/x402.js +0 -1339
- package/dist/x402.js.map +0 -6
- package/types/server.d.ts +0 -78
- package/types/x402.d.ts +0 -137
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
import type { PrivateKeyAccount } from "viem/accounts";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { callService, type CallToolInput, type CallToolResult } from "./tools/call.js";
|
|
5
|
+
export { callService, type CallToolInput, type CallToolResult };
|
|
6
|
+
export type VapiServerOptions = {
|
|
7
|
+
account: PrivateKeyAccount;
|
|
8
|
+
config: VapiConfig;
|
|
9
|
+
fetchImpl?: typeof fetch;
|
|
10
|
+
ledgerPath?: string;
|
|
11
|
+
receiptsPath?: string;
|
|
12
|
+
searchesPath?: string;
|
|
13
|
+
};
|
|
14
|
+
type ToolResult = {
|
|
15
|
+
isError?: boolean;
|
|
16
|
+
structuredContent?: Record<string, unknown>;
|
|
17
|
+
content: Array<{
|
|
18
|
+
type: "text";
|
|
19
|
+
text: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
type ToolDefinition<Shape extends z.ZodRawShape> = {
|
|
23
|
+
description?: string;
|
|
24
|
+
deprecatedReplacement?: string;
|
|
25
|
+
inputSchema: Shape;
|
|
26
|
+
outputSchema?: z.ZodType;
|
|
27
|
+
};
|
|
28
|
+
type ListedTool = {
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
inputSchema: unknown;
|
|
32
|
+
outputSchema?: unknown;
|
|
33
|
+
};
|
|
34
|
+
/** Minimal MCP server implementation for stdio and deterministic in-memory tests. */
|
|
35
|
+
export declare class VapiMcpServer {
|
|
36
|
+
#private;
|
|
37
|
+
registerTool<Shape extends z.ZodRawShape>(name: string, definition: ToolDefinition<Shape>, handler: (input: z.infer<z.ZodObject<Shape>>) => Promise<ToolResult>): void;
|
|
38
|
+
listTools(): Promise<{
|
|
39
|
+
tools: ListedTool[];
|
|
40
|
+
}>;
|
|
41
|
+
callTool(request: {
|
|
42
|
+
name: string;
|
|
43
|
+
arguments?: Record<string, unknown>;
|
|
44
|
+
}): Promise<ToolResult>;
|
|
45
|
+
connectStdio(): void;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export declare function createVapiServer(options: VapiServerOptions): VapiMcpServer;
|
|
49
|
+
export declare function startStdioServer(options: VapiServerOptions): Promise<VapiMcpServer>;
|
|
50
|
+
export declare function loadServerConfig(): Promise<{
|
|
51
|
+
discoveryUrl: string;
|
|
52
|
+
marketplaceDiscoveryUrl: string;
|
|
53
|
+
networks: Record<string, {
|
|
54
|
+
rpcUrl: string;
|
|
55
|
+
usdc: `0x${string}`;
|
|
56
|
+
eip712Domain?: {
|
|
57
|
+
name: string;
|
|
58
|
+
version: string;
|
|
59
|
+
} | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
spendCaps: {
|
|
62
|
+
perCallAtomic: string;
|
|
63
|
+
perDayAtomic: string;
|
|
64
|
+
};
|
|
65
|
+
registryFallbacks?: {
|
|
66
|
+
discoveryUrl: string;
|
|
67
|
+
marketplaceDiscoveryUrl: string;
|
|
68
|
+
}[] | undefined;
|
|
69
|
+
allowPrivateNetwork?: boolean | undefined;
|
|
70
|
+
}>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type LookupFn, type MarketplaceHit, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
import type { PrivateKeyAccount } from "viem/accounts";
|
|
3
|
+
export type CallToolInput = {
|
|
4
|
+
id?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
method?: string;
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
body?: unknown;
|
|
9
|
+
maxPriceUsd?: number | string;
|
|
10
|
+
network?: string;
|
|
11
|
+
expectedPayTo?: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
};
|
|
14
|
+
export type PossibleSettlement = {
|
|
15
|
+
network: string;
|
|
16
|
+
asset: string;
|
|
17
|
+
amountAtomic: string;
|
|
18
|
+
payTo: string;
|
|
19
|
+
payer: string;
|
|
20
|
+
authorizationNonce: string;
|
|
21
|
+
authorizationExpiresAt: string;
|
|
22
|
+
receipt: unknown | null;
|
|
23
|
+
};
|
|
24
|
+
export type PaymentRejection = {
|
|
25
|
+
httpStatus: number;
|
|
26
|
+
receipt: unknown;
|
|
27
|
+
};
|
|
28
|
+
export type ConfirmedSettlement = {
|
|
29
|
+
httpStatus: number;
|
|
30
|
+
receipt: unknown;
|
|
31
|
+
};
|
|
32
|
+
export declare class VapiCallError extends Error {
|
|
33
|
+
readonly code: "invalid_request" | "payment_rejected" | "receipt_write_failed" | "response_unreadable" | "settlement_unknown";
|
|
34
|
+
readonly possibleSettlement?: PossibleSettlement | undefined;
|
|
35
|
+
readonly name = "VapiCallError";
|
|
36
|
+
readonly paymentRejection?: PaymentRejection;
|
|
37
|
+
readonly confirmedSettlement?: ConfirmedSettlement;
|
|
38
|
+
constructor(code: "invalid_request" | "payment_rejected" | "receipt_write_failed" | "response_unreadable" | "settlement_unknown", message: string, possibleSettlement?: PossibleSettlement | undefined, options?: ErrorOptions & {
|
|
39
|
+
paymentRejection?: PaymentRejection;
|
|
40
|
+
confirmedSettlement?: ConfirmedSettlement;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export type CallToolResult = {
|
|
44
|
+
status: number;
|
|
45
|
+
body: unknown;
|
|
46
|
+
payment: null | {
|
|
47
|
+
network: string;
|
|
48
|
+
amountAtomic: string;
|
|
49
|
+
amountUsd: string;
|
|
50
|
+
asset: string;
|
|
51
|
+
payTo: string;
|
|
52
|
+
settlement: unknown | null;
|
|
53
|
+
proof: string | null;
|
|
54
|
+
};
|
|
55
|
+
expectedRequest?: {
|
|
56
|
+
contentType?: string;
|
|
57
|
+
schema?: unknown;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type CallServiceArgs = {
|
|
61
|
+
input: CallToolInput;
|
|
62
|
+
marketplaceHit?: MarketplaceHit;
|
|
63
|
+
account: PrivateKeyAccount;
|
|
64
|
+
config: VapiConfig;
|
|
65
|
+
fetchImpl?: typeof fetch;
|
|
66
|
+
lookup?: LookupFn;
|
|
67
|
+
ledgerPath?: string;
|
|
68
|
+
receiptsPath?: string;
|
|
69
|
+
now?: Date;
|
|
70
|
+
nowMs?: () => number;
|
|
71
|
+
timeoutMs?: number;
|
|
72
|
+
};
|
|
73
|
+
export declare function callService(args: CallServiceArgs): Promise<CallToolResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DiscoveryEndpoint, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
export type InspectToolInput = {
|
|
3
|
+
id: string;
|
|
4
|
+
endpoint?: string;
|
|
5
|
+
};
|
|
6
|
+
export type InspectToolResult = Omit<Pick<DiscoveryEndpoint, "name" | "method" | "url" | "price" | "description" | "operationId" | "requestContentType" | "requestSchema" | "responseContentType">, "method"> & {
|
|
7
|
+
method: string | null;
|
|
8
|
+
network?: string;
|
|
9
|
+
payment: DiscoveryEndpoint["payment"] | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function inspectService(input: InspectToolInput, config: VapiConfig, fetchImpl?: typeof fetch): Promise<InspectToolResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { findMarketplaceApiByRef, resolveServiceEndpoint, searchMarketplace, type MarketplaceSearchInput, } from "@vapi-network/sources";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
export type WalletBalance = {
|
|
4
|
+
network: string;
|
|
5
|
+
name: string;
|
|
6
|
+
usdcAtomic: string | null;
|
|
7
|
+
usdc: string | null;
|
|
8
|
+
error?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function getWallet(address: Address, config: VapiConfig): Promise<{
|
|
11
|
+
address: Address;
|
|
12
|
+
balances: WalletBalance[];
|
|
13
|
+
}>;
|
package/dist/x402.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EIP3009_AUTHORIZATION_TYPES, X402Error, assertMaxPrice, buildEip3009TypedData, classifySettlement, parseSettlementResponse, usdToAtomic, type Eip3009Authorization, type X402PaymentHeaders as SharedX402PaymentHeaders, type X402PaymentPayload, type X402PaymentRequirements, type X402Quote, type X402Resource, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import type { PrivateKeyAccount } from "viem/accounts";
|
|
4
|
+
export { EIP3009_AUTHORIZATION_TYPES, X402Error, assertMaxPrice, buildEip3009TypedData, classifySettlement, parseSettlementResponse, usdToAtomic, };
|
|
5
|
+
export type { Eip3009Authorization, X402PaymentPayload, X402PaymentRequirements, X402Quote, X402Resource, };
|
|
6
|
+
export type X402PaymentHeaders = SharedX402PaymentHeaders & {
|
|
7
|
+
"X-PAYMENT": string;
|
|
8
|
+
};
|
|
9
|
+
export declare function parse402Challenge(challenge: unknown, configuredNetworks: VapiConfig["networks"], fallbackResourceUrl?: string, requiredNetwork?: string, expectedPayTo?: string): X402Quote;
|
|
10
|
+
export declare function parse402Response(response: Response, configuredNetworks: VapiConfig["networks"], requiredNetwork?: string, expectedPayTo?: string): Promise<X402Quote>;
|
|
11
|
+
export declare function buildX402Payment(args: {
|
|
12
|
+
account: Pick<PrivateKeyAccount, "address" | "signTypedData">;
|
|
13
|
+
quote: X402Quote;
|
|
14
|
+
nowSeconds?: number;
|
|
15
|
+
nonce?: Hex;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
payload: X402PaymentPayload;
|
|
18
|
+
headers: X402PaymentHeaders;
|
|
19
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vapi-network/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "0.2.0-dev.2",
|
|
4
|
+
"description": "Local, non-custodial MCP server for discovering and paying x402 APIs",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/vAPI-Network/vapi-
|
|
9
|
-
"directory": "packages/
|
|
8
|
+
"url": "git+https://github.com/vAPI-Network/vapi-network.git",
|
|
9
|
+
"directory": "packages/mcp"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/vAPI-Network/vapi-network#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/vAPI-Network/vapi-network/issues"
|
|
10
14
|
},
|
|
11
15
|
"type": "module",
|
|
12
16
|
"sideEffects": false,
|
|
13
17
|
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
"types",
|
|
16
|
-
"README.md"
|
|
18
|
+
"dist"
|
|
17
19
|
],
|
|
18
|
-
"bin": {
|
|
19
|
-
"vapi-mcp": "dist/cli.js"
|
|
20
|
-
},
|
|
21
20
|
"exports": {
|
|
22
21
|
".": {
|
|
23
|
-
"types": "./
|
|
24
|
-
"import": "./dist/
|
|
25
|
-
},
|
|
26
|
-
"./x402": {
|
|
27
|
-
"types": "./types/x402.d.ts",
|
|
28
|
-
"import": "./dist/x402.js"
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
29
24
|
}
|
|
30
25
|
},
|
|
31
26
|
"dependencies": {},
|
|
32
27
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
28
|
+
"node": ">=22"
|
|
34
29
|
},
|
|
35
30
|
"publishConfig": {
|
|
36
|
-
"access": "public"
|
|
31
|
+
"access": "public",
|
|
32
|
+
"tag": "next"
|
|
37
33
|
}
|
|
38
34
|
}
|