| Function | Description |
|---|
handleMcpRequest(config, input) | Dispatch one JSON-RPC message (initialize, notifications/initialized, ping, tools/list, tools/call). input is { authHeader, body }; returns Promise<{ statusCode, response }> |
zodToJsonSchema(schema) | Serialize a Zod 4 schema to the JSON Schema object advertised in tools/list |
McpServerConfig<TContext, TPrincipal>
| Field | Description |
|---|
serverInfo | { name, version } returned by initialize |
tools | McpToolRegistry<TContext> — Record<string, McpTool> |
protocolVersion? | Override the advertised MCP protocol version |
authenticate(authHeader) | Required. Returns McpAuthResult — { allowedTools: ReadonlySet<string> | null, principal } |
createContext(principal, toolName) | Required. Builds the context passed to run (sync or async) |
rateLimit?(principal, toolName) | Throw to reject before dispatch |
wrapToolCall?(info, run) | Wrap each tool invocation; info is McpToolCallInfo<TPrincipal> |
McpTool<TInput, TContext, TOutput> — { name, description, inputSchema: ZodType<TInput>, run(args, ctx) }.
| Export | Description |
|---|
McpError | class McpError extends Error — new McpError(message, { statusCode?, rpcCode?, data? }). Thrown from hooks it becomes the JSON-RPC error; a retryAfterSec in data is surfaced to the client |
McpErrorOptions | The options bag above |
| Function | Description |
|---|
generateBearerToken(options) | Mint vk_<scope>_<secret> (24 random bytes by default); returns { token, prefix } (GeneratedBearerToken) |
parseScopedToken(token) | Split a token into { scheme, scope, secret } (ParsedScopedToken) or null |
parseBearer(header) | Extract the token from an Authorization: Bearer … header, or null |
bearerTokenPrefix(token, length?) | The lookup prefix persisted alongside the hash (DEFAULT_PREFIX_LENGTH = 10) |
hashTokenSecret(plaintext) | scrypt hash (Promise<string>) |
verifyTokenSecret(plaintext, stored) | Constant-time scrypt verification (Promise<boolean>) |
| Function | Description |
|---|
createMcpToken(q, input) | Insert a token for { scope, label, allowedTools?, createdBy? }; returns { row, token } — token is the plaintext, surfaced once |
listMcpTokens(q, scope) | McpTokenRow[] for an owner key |
revokeMcpToken(q, scope, id) | Set revoked_at; returns the row or null |
verifyMcpToken(q, plaintext) | Resolve an active (non-revoked) row by scope + prefix, then scrypt-check the secret; touches last_used_at best-effort. null when unknown, revoked or mismatched |
getMcpMigrationsDir() | Absolute path of the shipped vk_mcp_0001_tokens.sql migration (auto-discovered by vk migrate) |
McpTokenRow: id, scope, label, prefix, tokenHash, allowedTools (comma-separated string or null), lastUsedAt, revokedAt, createdAt, createdBy.
JsonRpcRequest, JsonRpcResponse, JsonRpcError, JsonSchema, McpHandlerInput, McpHandlerOutput, McpServerInfo, McpAuthResult, McpToolCallInfo, McpToolRegistry, GenerateBearerTokenOptions, CreateMcpTokenInput, CreatedMcpToken, Querier (<T>(sql: string, params?: unknown[]) => Promise<T> — @venturekit/data’s query satisfies it).