@haven_ai/mcp 0.1.0-alpha

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.
@@ -0,0 +1,80 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { HavenClient } from '@haven_ai/sdk';
3
+ import { z } from 'zod/v3';
4
+
5
+ interface HavenCredentialFile {
6
+ apiKey: string;
7
+ delegateKey: string;
8
+ agentId?: string;
9
+ safeAddress?: string;
10
+ apiUrl?: string;
11
+ /**
12
+ * Absolute path the credentials were loaded from, if any. Set when the
13
+ * caller pointed at a JSON file via `--credentials` or `HAVEN_CREDENTIALS`;
14
+ * left undefined when credentials came purely from environment variables.
15
+ * The MCP server uses this to locate the consent sidecar
16
+ * (`<sourcePath>.ack.json`) so `--ack` works regardless of how the
17
+ * credential path was supplied.
18
+ */
19
+ sourcePath?: string;
20
+ }
21
+ /**
22
+ * Load Haven agent credentials for the MCP server.
23
+ *
24
+ * Resolution order — earlier sources win, later sources are fallbacks:
25
+ *
26
+ * 1. Explicit `path` argument (typically from `--credentials <path>`).
27
+ * 2. `HAVEN_CREDENTIALS` env var pointing at a credential JSON file.
28
+ * 3. Inline env vars: `HAVEN_API_KEY` + `HAVEN_DELEGATE_KEY` (+ optional
29
+ * `HAVEN_AGENT_ID`, `HAVEN_SAFE_ADDRESS`, `HAVEN_API_URL`).
30
+ *
31
+ * The inline-env path exists so that runtime config snippets emitted by the
32
+ * Haven dashboard (Claude Desktop / Cursor / generic MCP configs) can be a
33
+ * single self-contained block — paste the snippet, restart the runtime, done.
34
+ * The values still live only in the agent operator's process environment;
35
+ * Haven's backend never sees the delegate key either way.
36
+ */
37
+ declare function loadCredentials(path?: string | undefined): Promise<HavenCredentialFile>;
38
+
39
+ type HavenMcpToolName = 'haven_quote_x402' | 'haven_pay_x402_quote' | 'haven_resume_x402_payment' | 'haven_quote_mpp' | 'haven_pay_mpp_challenge' | 'haven_resume_mpp_payment' | 'haven_get_payment_status' | 'haven_get_resume_state' | 'haven_get_agent' | 'haven_get_allowances' | 'haven_list_receipts';
40
+ declare const toolSchemas: Record<HavenMcpToolName, z.ZodRawShape>;
41
+ declare const toolDescriptions: Record<HavenMcpToolName, string>;
42
+ interface ToolSuccess<T> {
43
+ success: true;
44
+ data: T;
45
+ }
46
+ interface ToolFailure {
47
+ success: false;
48
+ code: string;
49
+ message: string;
50
+ statusCode?: number;
51
+ paymentId?: string;
52
+ status?: string;
53
+ phase?: string;
54
+ nextAction?: string;
55
+ resume_state?: unknown;
56
+ body?: unknown;
57
+ }
58
+ type ToolPayload<T = unknown> = ToolSuccess<T> | ToolFailure;
59
+ declare function createToolHandlers(haven: HavenClient): Record<HavenMcpToolName, (input: unknown) => Promise<ToolPayload>>;
60
+
61
+ interface HavenMcpServerOptions {
62
+ credentialsPath?: string;
63
+ credentials?: HavenCredentialFile;
64
+ /**
65
+ * When true, write the consent sidecar file (`<credentials>.ack.json`)
66
+ * with the current consent hash and proceed. Surfaced via the `--ack`
67
+ * CLI flag.
68
+ */
69
+ writeAck?: boolean;
70
+ /**
71
+ * When true, skip the consent gate entirely. Reserved for tests and
72
+ * controlled embedding — production CLIs should not set this.
73
+ */
74
+ skipConsent?: boolean;
75
+ }
76
+ declare function createHavenClient(options?: HavenMcpServerOptions): Promise<HavenClient>;
77
+ declare function createHavenMcpServer(options?: HavenMcpServerOptions): Promise<McpServer>;
78
+ declare function runStdioServer(options?: HavenMcpServerOptions): Promise<void>;
79
+
80
+ export { type HavenCredentialFile, type HavenMcpServerOptions, type HavenMcpToolName, type ToolFailure, type ToolPayload, type ToolSuccess, createHavenClient, createHavenMcpServer, createToolHandlers, loadCredentials, runStdioServer, toolDescriptions, toolSchemas };
@@ -0,0 +1,80 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { HavenClient } from '@haven_ai/sdk';
3
+ import { z } from 'zod/v3';
4
+
5
+ interface HavenCredentialFile {
6
+ apiKey: string;
7
+ delegateKey: string;
8
+ agentId?: string;
9
+ safeAddress?: string;
10
+ apiUrl?: string;
11
+ /**
12
+ * Absolute path the credentials were loaded from, if any. Set when the
13
+ * caller pointed at a JSON file via `--credentials` or `HAVEN_CREDENTIALS`;
14
+ * left undefined when credentials came purely from environment variables.
15
+ * The MCP server uses this to locate the consent sidecar
16
+ * (`<sourcePath>.ack.json`) so `--ack` works regardless of how the
17
+ * credential path was supplied.
18
+ */
19
+ sourcePath?: string;
20
+ }
21
+ /**
22
+ * Load Haven agent credentials for the MCP server.
23
+ *
24
+ * Resolution order — earlier sources win, later sources are fallbacks:
25
+ *
26
+ * 1. Explicit `path` argument (typically from `--credentials <path>`).
27
+ * 2. `HAVEN_CREDENTIALS` env var pointing at a credential JSON file.
28
+ * 3. Inline env vars: `HAVEN_API_KEY` + `HAVEN_DELEGATE_KEY` (+ optional
29
+ * `HAVEN_AGENT_ID`, `HAVEN_SAFE_ADDRESS`, `HAVEN_API_URL`).
30
+ *
31
+ * The inline-env path exists so that runtime config snippets emitted by the
32
+ * Haven dashboard (Claude Desktop / Cursor / generic MCP configs) can be a
33
+ * single self-contained block — paste the snippet, restart the runtime, done.
34
+ * The values still live only in the agent operator's process environment;
35
+ * Haven's backend never sees the delegate key either way.
36
+ */
37
+ declare function loadCredentials(path?: string | undefined): Promise<HavenCredentialFile>;
38
+
39
+ type HavenMcpToolName = 'haven_quote_x402' | 'haven_pay_x402_quote' | 'haven_resume_x402_payment' | 'haven_quote_mpp' | 'haven_pay_mpp_challenge' | 'haven_resume_mpp_payment' | 'haven_get_payment_status' | 'haven_get_resume_state' | 'haven_get_agent' | 'haven_get_allowances' | 'haven_list_receipts';
40
+ declare const toolSchemas: Record<HavenMcpToolName, z.ZodRawShape>;
41
+ declare const toolDescriptions: Record<HavenMcpToolName, string>;
42
+ interface ToolSuccess<T> {
43
+ success: true;
44
+ data: T;
45
+ }
46
+ interface ToolFailure {
47
+ success: false;
48
+ code: string;
49
+ message: string;
50
+ statusCode?: number;
51
+ paymentId?: string;
52
+ status?: string;
53
+ phase?: string;
54
+ nextAction?: string;
55
+ resume_state?: unknown;
56
+ body?: unknown;
57
+ }
58
+ type ToolPayload<T = unknown> = ToolSuccess<T> | ToolFailure;
59
+ declare function createToolHandlers(haven: HavenClient): Record<HavenMcpToolName, (input: unknown) => Promise<ToolPayload>>;
60
+
61
+ interface HavenMcpServerOptions {
62
+ credentialsPath?: string;
63
+ credentials?: HavenCredentialFile;
64
+ /**
65
+ * When true, write the consent sidecar file (`<credentials>.ack.json`)
66
+ * with the current consent hash and proceed. Surfaced via the `--ack`
67
+ * CLI flag.
68
+ */
69
+ writeAck?: boolean;
70
+ /**
71
+ * When true, skip the consent gate entirely. Reserved for tests and
72
+ * controlled embedding — production CLIs should not set this.
73
+ */
74
+ skipConsent?: boolean;
75
+ }
76
+ declare function createHavenClient(options?: HavenMcpServerOptions): Promise<HavenClient>;
77
+ declare function createHavenMcpServer(options?: HavenMcpServerOptions): Promise<McpServer>;
78
+ declare function runStdioServer(options?: HavenMcpServerOptions): Promise<void>;
79
+
80
+ export { type HavenCredentialFile, type HavenMcpServerOptions, type HavenMcpToolName, type ToolFailure, type ToolPayload, type ToolSuccess, createHavenClient, createHavenMcpServer, createToolHandlers, loadCredentials, runStdioServer, toolDescriptions, toolSchemas };