@vapi-network/mcp 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +273 -125
- package/dist/index.d.ts +5 -0
- package/dist/{server.js → index.js} +41463 -45444
- package/dist/index.js.map +6 -0
- package/dist/server.d.ts +72 -0
- package/dist/siwx.d.ts +12 -0
- package/dist/tools/call.d.ts +74 -0
- package/dist/tools/inspect.d.ts +14 -0
- package/dist/tools/search.d.ts +1 -0
- package/dist/tools/wallet.d.ts +16 -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,72 @@
|
|
|
1
|
+
import { type VapiPaymentAccount, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { callService, type CallToolInput, type CallToolResult } from "./tools/call.js";
|
|
4
|
+
export { callService, type CallToolInput, type CallToolResult };
|
|
5
|
+
export type VapiServerOptions = {
|
|
6
|
+
account: VapiPaymentAccount;
|
|
7
|
+
config: VapiConfig;
|
|
8
|
+
fetchImpl?: typeof fetch;
|
|
9
|
+
ledgerPath?: string;
|
|
10
|
+
receiptsPath?: string;
|
|
11
|
+
searchesPath?: string;
|
|
12
|
+
reportsDirectory?: 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: string;
|
|
56
|
+
depositUrl?: string | undefined;
|
|
57
|
+
depositInstructions?: string | undefined;
|
|
58
|
+
eip712Domain?: {
|
|
59
|
+
name: string;
|
|
60
|
+
version: string;
|
|
61
|
+
} | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
spendCaps: {
|
|
64
|
+
perCallAtomic: string;
|
|
65
|
+
perDayAtomic: string;
|
|
66
|
+
};
|
|
67
|
+
registryFallbacks?: {
|
|
68
|
+
discoveryUrl: string;
|
|
69
|
+
marketplaceDiscoveryUrl: string;
|
|
70
|
+
}[] | undefined;
|
|
71
|
+
allowPrivateNetwork?: boolean | undefined;
|
|
72
|
+
}>;
|
package/dist/siwx.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type SIWxChallenge, type SIWxSigner, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
export declare function parseSIWxResponse(response: Response, configuredNetworks: VapiConfig["networks"], responseUrl: string, requiredNetwork?: string): Promise<SIWxChallenge | null>;
|
|
3
|
+
export declare function buildSIWxProof(args: {
|
|
4
|
+
signer: SIWxSigner;
|
|
5
|
+
challenge: SIWxChallenge;
|
|
6
|
+
responseUrl: string;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
payload: import("@vapi-network/core").SIWxPayload;
|
|
9
|
+
headers: Readonly<{
|
|
10
|
+
"SIGN-IN-WITH-X": string;
|
|
11
|
+
}>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type LookupFn, type MarketplaceHit, type VapiPaymentAccount, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
export type CallToolInput = {
|
|
3
|
+
id?: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
method?: string;
|
|
6
|
+
endpoint?: string;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
maxPriceUsd?: number | string;
|
|
9
|
+
network?: string;
|
|
10
|
+
expectedPayTo?: string;
|
|
11
|
+
contentType?: string;
|
|
12
|
+
};
|
|
13
|
+
export type PossibleSettlement = {
|
|
14
|
+
network: string;
|
|
15
|
+
asset: string;
|
|
16
|
+
amountAtomic: string;
|
|
17
|
+
payTo: string;
|
|
18
|
+
payer: string;
|
|
19
|
+
authorizationNonce?: string;
|
|
20
|
+
authorizationExpiresAt?: string;
|
|
21
|
+
authorizationTransaction?: 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
|
+
outcome?: "signed_in";
|
|
47
|
+
payment: null | {
|
|
48
|
+
network: string;
|
|
49
|
+
amountAtomic: string;
|
|
50
|
+
amountUsd: string;
|
|
51
|
+
asset: string;
|
|
52
|
+
payTo: string;
|
|
53
|
+
settlement: unknown | null;
|
|
54
|
+
proof: string | null;
|
|
55
|
+
};
|
|
56
|
+
expectedRequest?: {
|
|
57
|
+
contentType?: string;
|
|
58
|
+
schema?: unknown;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export type CallServiceArgs = {
|
|
62
|
+
input: CallToolInput;
|
|
63
|
+
marketplaceHit?: MarketplaceHit;
|
|
64
|
+
account: VapiPaymentAccount;
|
|
65
|
+
config: VapiConfig;
|
|
66
|
+
fetchImpl?: typeof fetch;
|
|
67
|
+
lookup?: LookupFn;
|
|
68
|
+
ledgerPath?: string;
|
|
69
|
+
receiptsPath?: string;
|
|
70
|
+
now?: Date;
|
|
71
|
+
nowMs?: () => number;
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
};
|
|
74
|
+
export declare function callService(args: CallServiceArgs): Promise<CallToolResult>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DiscoveryEndpoint, type ListingFee, type ListingGroup, 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
|
+
/** Registry-owned listing disclosures; absent when the registry omits them. */
|
|
10
|
+
group?: ListingGroup;
|
|
11
|
+
fee?: ListingFee;
|
|
12
|
+
payment: DiscoveryEndpoint["payment"] | null;
|
|
13
|
+
};
|
|
14
|
+
export declare function inspectService(input: InspectToolInput, config: VapiConfig, fetchImpl?: typeof fetch): Promise<InspectToolResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { findMarketplaceApiByRef, resolveServiceEndpoint, resolveServiceListing, searchMarketplace, type MarketplaceSearchInput, } from "@vapi-network/sources";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type LookupFn, type VapiPaymentAccount, 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(account: Address | VapiPaymentAccount, config: VapiConfig, options?: {
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
lookup?: LookupFn;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
address: Address;
|
|
15
|
+
balances: WalletBalance[];
|
|
16
|
+
}>;
|
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 X402Signer, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
export { EIP3009_AUTHORIZATION_TYPES, X402Error, assertMaxPrice, buildEip3009TypedData, classifySettlement, parseSettlementResponse, usdToAtomic, };
|
|
4
|
+
export type { Eip3009Authorization, X402PaymentPayload, X402PaymentRequirements, X402Quote, X402Resource, };
|
|
5
|
+
export type X402PaymentHeaders = SharedX402PaymentHeaders & {
|
|
6
|
+
"X-PAYMENT": string;
|
|
7
|
+
};
|
|
8
|
+
export declare function parse402Challenge(challenge: unknown, configuredNetworks: VapiConfig["networks"], fallbackResourceUrl?: string, requiredNetwork?: string, expectedPayTo?: string): X402Quote;
|
|
9
|
+
export declare function parse402Response(response: Response, configuredNetworks: VapiConfig["networks"], requiredNetwork?: string, expectedPayTo?: string): Promise<X402Quote>;
|
|
10
|
+
export declare function buildX402Payment(args: {
|
|
11
|
+
account: X402Signer;
|
|
12
|
+
quote: X402Quote;
|
|
13
|
+
nowSeconds?: number;
|
|
14
|
+
nonce?: Hex;
|
|
15
|
+
fetchImpl?: typeof fetch;
|
|
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",
|
|
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": "latest"
|
|
37
33
|
}
|
|
38
34
|
}
|