@nuberea/sdk 0.0.1

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/mcp.js ADDED
@@ -0,0 +1,255 @@
1
+ /**
2
+ * NuBerea MCP Client — Full MCP protocol implementation.
3
+ *
4
+ * Implements MCP Streamable HTTP transport:
5
+ * - POST /mcp: JSON-RPC requests (initialize, tools/list, tools/call, resources/list, resources/read)
6
+ * - Session tracking via mcp-session-id header
7
+ * - Stateless mode (no session) and session-based mode
8
+ *
9
+ * Can be used standalone or through the higher-level NuBerea client class.
10
+ */
11
+ // ============================================================================
12
+ // MCP Client
13
+ // ============================================================================
14
+ export class McpClient {
15
+ mcpUrl;
16
+ accessToken;
17
+ protocolVersion;
18
+ sessionId = null;
19
+ initialized = false;
20
+ serverInfo = null;
21
+ capabilities = null;
22
+ useSession;
23
+ requestId = 0;
24
+ constructor(config) {
25
+ this.mcpUrl = config.mcpUrl;
26
+ this.accessToken = config.accessToken;
27
+ this.protocolVersion = config.protocolVersion ?? '2025-03-26';
28
+ this.useSession = config.useSession ?? false;
29
+ }
30
+ // ==========================================================================
31
+ // Core JSON-RPC transport
32
+ // ==========================================================================
33
+ /**
34
+ * Send a JSON-RPC request to the MCP server.
35
+ * Handles both plain JSON and SSE response formats.
36
+ */
37
+ async request(method, params) {
38
+ const id = ++this.requestId;
39
+ const headers = {
40
+ 'Content-Type': 'application/json',
41
+ Accept: 'application/json, text/event-stream',
42
+ Authorization: `Bearer ${this.accessToken}`,
43
+ };
44
+ if (this.sessionId) {
45
+ headers['mcp-session-id'] = this.sessionId;
46
+ }
47
+ const body = {
48
+ jsonrpc: '2.0',
49
+ method,
50
+ id,
51
+ ...(params ? { params } : {}),
52
+ };
53
+ const res = await fetch(this.mcpUrl, {
54
+ method: 'POST',
55
+ headers,
56
+ body: JSON.stringify(body),
57
+ });
58
+ if (!res.ok) {
59
+ const text = await res.text();
60
+ throw new McpError(`MCP request failed: HTTP ${res.status} — ${text}`, res.status);
61
+ }
62
+ // Capture session ID from response
63
+ const newSessionId = res.headers.get('mcp-session-id');
64
+ if (newSessionId) {
65
+ this.sessionId = newSessionId;
66
+ }
67
+ // Parse response (may be SSE or plain JSON)
68
+ const text = await res.text();
69
+ return this.parseResponse(text, res.headers.get('content-type') ?? '');
70
+ }
71
+ /**
72
+ * Send a JSON-RPC notification (no id, no response expected).
73
+ */
74
+ async notify(method, params) {
75
+ const headers = {
76
+ 'Content-Type': 'application/json',
77
+ Accept: 'application/json, text/event-stream',
78
+ Authorization: `Bearer ${this.accessToken}`,
79
+ };
80
+ if (this.sessionId) {
81
+ headers['mcp-session-id'] = this.sessionId;
82
+ }
83
+ const body = {
84
+ jsonrpc: '2.0',
85
+ method,
86
+ ...(params ? { params } : {}),
87
+ };
88
+ await fetch(this.mcpUrl, {
89
+ method: 'POST',
90
+ headers,
91
+ body: JSON.stringify(body),
92
+ });
93
+ }
94
+ // ==========================================================================
95
+ // MCP Protocol Methods
96
+ // ==========================================================================
97
+ /**
98
+ * Initialize the MCP session.
99
+ * Must be called before other methods in session-based mode.
100
+ */
101
+ async initialize() {
102
+ const res = await this.request('initialize', {
103
+ protocolVersion: this.protocolVersion,
104
+ clientInfo: {
105
+ name: '@nuberea/sdk',
106
+ version: '0.1.0',
107
+ },
108
+ capabilities: {},
109
+ });
110
+ if (res.error) {
111
+ throw new McpError(`Initialize failed: ${res.error.message}`, res.error.code);
112
+ }
113
+ const result = res.result;
114
+ this.serverInfo = result.serverInfo;
115
+ this.capabilities = result.capabilities;
116
+ this.initialized = true;
117
+ // Send initialized notification
118
+ await this.notify('notifications/initialized');
119
+ return result;
120
+ }
121
+ /**
122
+ * List available tools.
123
+ */
124
+ async listTools() {
125
+ await this.ensureReady();
126
+ const res = await this.request('tools/list');
127
+ if (res.error) {
128
+ throw new McpError(`tools/list failed: ${res.error.message}`, res.error.code);
129
+ }
130
+ const result = res.result;
131
+ return result.tools;
132
+ }
133
+ /**
134
+ * Call a tool by name.
135
+ */
136
+ async callTool(name, args = {}) {
137
+ await this.ensureReady();
138
+ const res = await this.request('tools/call', { name, arguments: args });
139
+ if (res.error) {
140
+ throw new McpError(`tools/call failed: ${res.error.message}`, res.error.code);
141
+ }
142
+ return res.result;
143
+ }
144
+ /**
145
+ * List available resources.
146
+ */
147
+ async listResources() {
148
+ await this.ensureReady();
149
+ const res = await this.request('resources/list');
150
+ if (res.error) {
151
+ throw new McpError(`resources/list failed: ${res.error.message}`, res.error.code);
152
+ }
153
+ const result = res.result;
154
+ return result.resources;
155
+ }
156
+ /**
157
+ * Read a resource by URI.
158
+ */
159
+ async readResource(uri) {
160
+ await this.ensureReady();
161
+ const res = await this.request('resources/read', { uri });
162
+ if (res.error) {
163
+ throw new McpError(`resources/read failed: ${res.error.message}`, res.error.code);
164
+ }
165
+ const result = res.result;
166
+ return result.contents;
167
+ }
168
+ /**
169
+ * Close the MCP session (sends DELETE request).
170
+ */
171
+ async close() {
172
+ if (!this.sessionId)
173
+ return;
174
+ const headers = {
175
+ Authorization: `Bearer ${this.accessToken}`,
176
+ 'mcp-session-id': this.sessionId,
177
+ };
178
+ try {
179
+ await fetch(this.mcpUrl, { method: 'DELETE', headers });
180
+ }
181
+ catch {
182
+ // Best-effort cleanup
183
+ }
184
+ this.sessionId = null;
185
+ this.initialized = false;
186
+ }
187
+ // ==========================================================================
188
+ // Accessors
189
+ // ==========================================================================
190
+ getSessionId() {
191
+ return this.sessionId;
192
+ }
193
+ getServerInfo() {
194
+ return this.serverInfo;
195
+ }
196
+ getCapabilities() {
197
+ return this.capabilities;
198
+ }
199
+ isInitialized() {
200
+ return this.initialized;
201
+ }
202
+ /**
203
+ * Update the access token (e.g., after refresh).
204
+ */
205
+ setAccessToken(token) {
206
+ this.accessToken = token;
207
+ }
208
+ // ==========================================================================
209
+ // Internal
210
+ // ==========================================================================
211
+ async ensureReady() {
212
+ if (this.useSession && !this.initialized) {
213
+ await this.initialize();
214
+ }
215
+ }
216
+ parseResponse(text, contentType) {
217
+ // SSE format: extract last "data:" line with a parseable JSON-RPC response
218
+ if (contentType.includes('text/event-stream')) {
219
+ const lines = text.split('\n');
220
+ for (let i = lines.length - 1; i >= 0; i--) {
221
+ const line = lines[i];
222
+ if (line.startsWith('data: ')) {
223
+ try {
224
+ const parsed = JSON.parse(line.slice(6));
225
+ if (parsed.jsonrpc === '2.0')
226
+ return parsed;
227
+ }
228
+ catch {
229
+ continue;
230
+ }
231
+ }
232
+ }
233
+ throw new McpError('No valid JSON-RPC response in SSE stream', -1);
234
+ }
235
+ // Plain JSON
236
+ try {
237
+ return JSON.parse(text);
238
+ }
239
+ catch {
240
+ throw new McpError(`Invalid JSON response: ${text.substring(0, 200)}`, -1);
241
+ }
242
+ }
243
+ }
244
+ // ============================================================================
245
+ // Error class
246
+ // ============================================================================
247
+ export class McpError extends Error {
248
+ code;
249
+ constructor(message, code) {
250
+ super(message);
251
+ this.name = 'McpError';
252
+ this.code = code;
253
+ }
254
+ }
255
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiEH,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,MAAM,OAAO,SAAS;IACZ,MAAM,CAAS;IACf,WAAW,CAAS;IACpB,eAAe,CAAS;IACxB,SAAS,GAAkB,IAAI,CAAC;IAChC,WAAW,GAAG,KAAK,CAAC;IACpB,UAAU,GAAyB,IAAI,CAAC;IACxC,YAAY,GAA2B,IAAI,CAAC;IAC5C,UAAU,CAAU;IACpB,SAAS,GAAG,CAAC,CAAC;IAEtB,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,YAAY,CAAC;QAC9D,IA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MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;wBACzC,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;4BAAE,OAAO,MAAM,CAAC;oBAC9C,CAAC;oBAAC,MAAM,CAAC;wBACP,SAAS;oBACX,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,IAAI,QAAQ,CAAC,0CAA0C,EAAE,CAAC,CAAC,CAAC,CAAC;QACrE,CAAC;QAED,aAAa;QACb,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAuB,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,QAAQ,CAAC,0BAA0B,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;CACF;AAED,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAS;IAEb,YAAY,OAAe,EAAE,IAAY;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Shared types for the NuBerea SDK.
3
+ */
4
+ export interface ToolInfo {
5
+ name: string;
6
+ description?: string;
7
+ inputSchema?: Record<string, unknown>;
8
+ }
9
+ export interface ToolResult {
10
+ content: Array<{
11
+ type: string;
12
+ text: string;
13
+ }>;
14
+ isError?: boolean;
15
+ }
16
+ export interface QueryResult {
17
+ columns: string[];
18
+ rows: Record<string, unknown>[];
19
+ rowCount: number;
20
+ executionTimeMs: number;
21
+ truncated: boolean;
22
+ offset: number;
23
+ }
24
+ export type QueryFormat = 'json' | 'ndjson' | 'csv';
25
+ export interface TableInfo {
26
+ table: string;
27
+ columns: number;
28
+ rowCount?: number;
29
+ }
30
+ export interface DatabaseInfo {
31
+ name: string;
32
+ description: string;
33
+ tables: TableInfo[];
34
+ }
35
+ export interface ColumnInfo {
36
+ column_name: string;
37
+ column_type: string;
38
+ null: string;
39
+ key: string | null;
40
+ default: string | null;
41
+ extra: string | null;
42
+ }
43
+ export interface SchemaIntrospection {
44
+ schema: string;
45
+ description: string;
46
+ tables: Array<{
47
+ table: string;
48
+ rowCount: number;
49
+ columns: ColumnInfo[];
50
+ sampleRows: Record<string, unknown>[];
51
+ }>;
52
+ }
53
+ export interface StatsEntry {
54
+ database: string;
55
+ table: string;
56
+ rowCount: number;
57
+ }
58
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEpD,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,UAAU,EAAE,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;KACvC,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Shared types for the NuBerea SDK.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@nuberea/sdk",
3
+ "version": "0.0.1",
4
+ "description": "NuBerea SDK — Client library for the NuBerea biblical data platform. Query morphological corpora, lexicons, Bible texts, manuscripts, and scrolls.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./cli": {
14
+ "import": "./dist/cli/index.js",
15
+ "types": "./dist/cli/index.d.ts"
16
+ }
17
+ },
18
+ "bin": {
19
+ "nuberea": "./dist/cli/index.js"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc",
28
+ "dev": "tsc --watch",
29
+ "lint": "eslint src/",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest",
32
+ "prepublishOnly": "npm run build",
33
+ "cli": "tsx src/cli/index.ts"
34
+ },
35
+ "keywords": [
36
+ "bible",
37
+ "biblical",
38
+ "hebrew",
39
+ "greek",
40
+ "morphology",
41
+ "lexicon",
42
+ "mcp",
43
+ "model-context-protocol",
44
+ "nuberea",
45
+ "theology",
46
+ "duckdb",
47
+ "ducklake",
48
+ "analytics"
49
+ ],
50
+ "author": "NuBerea <blake@streamsapps.com>",
51
+ "license": "MIT",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "https://github.com/streamsapps/nuberea-sdk"
55
+ },
56
+ "homepage": "https://nuberea.com",
57
+ "engines": {
58
+ "node": ">=18"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^22.0.0",
62
+ "tsx": "^4.19.0",
63
+ "typescript": "^5.7.0",
64
+ "vitest": "^3.0.0"
65
+ }
66
+ }