@lucern/mcp 0.3.0-alpha.17 → 0.3.0-alpha.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/dist/runtime.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AuthContext } from '@lucern/contracts';
2
2
  export { AuthContext } from '@lucern/contracts';
3
+ import { ConvexHttpClient } from 'convex/browser';
3
4
 
4
5
  /**
5
6
  * Handler Types — shared types for MCP tool handlers.
@@ -33,13 +34,13 @@ declare function buildHandlerMap(): Record<string, AuthenticatedHandler>;
33
34
  * Write Policy — S2-13K Graph Compounding
34
35
  *
35
36
  * Policy enforcement for MCP mutation tools.
36
- * Queries gateway-owned write policies and tracks per-session write counts.
37
+ * Queries Convex write policies and tracks per-session write counts.
37
38
  */
38
39
 
39
40
  /**
40
41
  * Check if a tool name is a mutation (write) tool.
41
42
  */
42
- declare const isMutationTool: (toolName: string) => boolean;
43
+ declare function isMutationTool(toolName: string): boolean;
43
44
  /**
44
45
  * Record a write operation for the current session.
45
46
  */
@@ -76,4 +77,35 @@ type PolicyCheckResult = {
76
77
  */
77
78
  declare function checkWritePolicy(toolName: string, topicId: string | undefined, authCtx: AuthContext): Promise<PolicyCheckResult>;
78
79
 
79
- export { type AuthenticatedHandler, buildHandlerMap, checkWritePolicy, isMutationTool, recordWrite };
80
+ /**
81
+ * Convex Clients — Lazy-initialized admin-authed ConvexHttpClients for MCP server.
82
+ *
83
+ * LAZY INITIALIZATION: Clients are created on first use, not at import time.
84
+ * This allows index.ts loadLucernEnv() to decode LUCERN_API_KEY and
85
+ * STACK_API_KEY into their respective URL and deploy key env vars before
86
+ * any Convex calls are made.
87
+ *
88
+ * Three clients:
89
+ * - Lucern client → reasoning graph (good-blackbird / precious-dog) [required]
90
+ * - Stack client → StackOS platform (sincere-shepherd / sleek-mink) [optional]
91
+ * - Master Control client → control plane (utmost-ox / successful-clam) [optional]
92
+ *
93
+ * Lucern + Stack are decoded from API keys by index.ts resolveCredentials() at startup.
94
+ * Master Control is resolved from MC_CONVEX_URL + MC_DEPLOY_KEY (set in ~/.lucern/credentials).
95
+ * Uses deploy key auth to call internal mutations/queries directly,
96
+ * bypassing Clerk (standard Convex server-to-server pattern).
97
+ */
98
+
99
+ /**
100
+ * Run a function with a request-scoped Convex client.
101
+ * All `adminQuery`/`adminMutation`/`adminAction` calls within `fn` will
102
+ * use the provided client instead of the process-level singleton.
103
+ */
104
+ declare function runWithScopedClient<T>(client: ConvexHttpClient, fn: () => T | Promise<T>): T | Promise<T>;
105
+ /**
106
+ * Create an admin-authed ConvexHttpClient for a specific deployment.
107
+ * Used by the hosted route to create per-instance clients.
108
+ */
109
+ declare function createAdminClient(url: string, deployKey: string): ConvexHttpClient;
110
+
111
+ export { type AuthenticatedHandler, buildHandlerMap, checkWritePolicy, createAdminClient, isMutationTool, recordWrite, runWithScopedClient };