@vectros-ai/mcp-server 0.5.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.
@@ -0,0 +1,215 @@
1
+ import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
2
+ import { Logger } from 'pino';
3
+ export { Logger } from 'pino';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+
6
+ /**
7
+ * Structured logger — pino, always to stderr.
8
+ *
9
+ * CRITICAL: stdout is reserved for the MCP JSON-RPC stream when the
10
+ * server runs over stdio transport. Anything written to stdout that
11
+ * is not a valid JSON-RPC message corrupts the protocol and the
12
+ * client disconnects.
13
+ *
14
+ * Every log line goes to stderr. There are no exceptions.
15
+ */
16
+
17
+ interface LogContext {
18
+ debug?: boolean;
19
+ }
20
+ /**
21
+ * Build a stderr-destined logger.
22
+ *
23
+ * Pass `debug: true` (or set `VECTROS_MCP_DEBUG=1`) to lower the
24
+ * level to `debug`. Default is `info`.
25
+ */
26
+ declare function createLogger(ctx?: LogContext): Logger;
27
+
28
+ /**
29
+ * Shared tool-definition shape.
30
+ *
31
+ * Each tool is built as a factory that takes the Vectros SDK client
32
+ * (already authenticated) + a logger, and returns the registration
33
+ * payload for `server.registerTool()` plus the handler. The server
34
+ * class iterates the array and registers each one.
35
+ */
36
+
37
+ /**
38
+ * Names of all REGISTERED tools — the contract for what
39
+ * `tools: [...]` accepts and what default construction registers.
40
+ *
41
+ * MUST stay in lockstep with `ALL_TOOL_FACTORIES` in `./index.ts` —
42
+ * every name here needs a factory there, and vice versa. The server
43
+ * iterates this list at construction; an unimplemented name throws.
44
+ *
45
+ * v0.1 (shipped 2026-05-30): hybrid_search, record_query, rag_ask, document_ask
46
+ * v0.2 (shipped): list_schemas, document_get, current_identity, document_ingest
47
+ * launch data-plane I/O: record_get, record_create, record_update, record_delete (tier 1);
48
+ * document_query (tier 2);
49
+ * document_update, document_delete, folder_query,
50
+ * folder_create, folder_update, folder_delete (tier 3)
51
+ * (see the data-plane surface doc)
52
+ * parity sweep: lookup_principal (identity resolution for the
53
+ * ownership filters), version_history (record/document
54
+ * audit trail)
55
+ */
56
+ declare const TOOL_NAMES: readonly ["hybrid_search", "record_query", "record_get", "record_create", "record_update", "record_delete", "rag_ask", "document_ask", "list_schemas", "document_get", "document_query", "document_update", "document_delete", "folder_query", "folder_create", "folder_update", "folder_delete", "current_identity", "document_ingest", "lookup_principal", "version_history"];
57
+ type ToolName = (typeof TOOL_NAMES)[number];
58
+
59
+ /**
60
+ * Shared resource-definition shape — mirror of the tool factory
61
+ * pattern in ../tools/types.ts.
62
+ *
63
+ * MCP resources are read-only data discoverable via resources/list +
64
+ * resources/read JSON-RPC calls. Each resource has a stable URI,
65
+ * a human-readable name + description, a MIME type, and a `read()`
66
+ * function that returns its text content.
67
+ */
68
+
69
+ /**
70
+ * Names of all REGISTERED resources — the contract for what
71
+ * `resources: [...]` filter accepts.
72
+ *
73
+ * MUST stay in lockstep with `ALL_RESOURCE_FACTORIES` in
74
+ * `./index.ts` — every name here needs a factory there, and vice
75
+ * versa. The server iterates this list at construction; an
76
+ * unimplemented name throws.
77
+ */
78
+ declare const RESOURCE_NAMES: readonly ["schemas", "identity"];
79
+ type ResourceName = (typeof RESOURCE_NAMES)[number];
80
+
81
+ interface VectrosMCPServerOptions {
82
+ /** Vectros API key. REQUIRED. Recommended shape: ssk_live_... or ssk_test_.... */
83
+ apiKey: string;
84
+ /** Opt-in tool filter. Default: all v0.1 tools enabled. */
85
+ tools?: ToolName[];
86
+ /**
87
+ * Opt-in resource filter (v0.2+). Default: all resources enabled.
88
+ * Pass `[]` to register zero resources (server advertises no
89
+ * resources capability via tools/list).
90
+ */
91
+ resources?: ResourceName[];
92
+ /**
93
+ * Vectros API base URL. Default: https://api.vectros.ai. The SDK
94
+ * calls this `environment`; we keep the docs-aligned name on our
95
+ * surface to match the design doc.
96
+ */
97
+ apiBaseUrl?: string;
98
+ /** Provide a logger to capture server output. Default: pino → stderr. */
99
+ logger?: Logger;
100
+ /**
101
+ * Which transport this server will be wired up with. Optional; only
102
+ * affects tool behavior that depends on partner-local-fs access
103
+ * (currently `document_ingest`'s filePath mode is stdio-only). The
104
+ * CLI entry points set this — `cli.ts` passes 'stdio', the v0.2
105
+ * `cli-http.ts` passes 'http'. Programmatic embedders default to
106
+ * 'stdio' semantics if omitted.
107
+ */
108
+ transport?: 'stdio' | 'http';
109
+ /**
110
+ * If true (default in v0.2), perform a GET /v1/ping check during
111
+ * `connect()` to fail-fast on bad credentials BEFORE the MCP
112
+ * client sends its first tool call. The default is safe — partners
113
+ * who don't want the network roundtrip on startup can set false,
114
+ * but the trade-off is "credential failures surface mid-tool-call
115
+ * rather than at startup."
116
+ *
117
+ * The CLI honors `VECTROS_MCP_SKIP_PING_VALIDATION=1` env var as
118
+ * an explicit opt-out (sets this to false). Useful in CI / dev
119
+ * environments where the API isn't reachable.
120
+ */
121
+ validateOnStart?: boolean;
122
+ /**
123
+ * Filesystem root that `document_ingest`'s stdio `filePath` mode is
124
+ * jailed to. Overrides `VECTROS_MCP_INGEST_ROOT`; when both are
125
+ * absent the tool defaults to `process.cwd()`.
126
+ */
127
+ ingestRoot?: string;
128
+ }
129
+ declare class VectrosMCPServer {
130
+ private readonly server;
131
+ private readonly log;
132
+ private readonly tools;
133
+ private readonly resources;
134
+ private readonly apiKey;
135
+ private readonly environment;
136
+ private readonly validateOnStart;
137
+ constructor(opts: VectrosMCPServerOptions);
138
+ /**
139
+ * Wire `tools/list` and `tools/call` JSON-RPC handlers on the
140
+ * underlying MCP Server. Each tool's handler is wrapped to convert
141
+ * thrown errors into `isError: true` tool results.
142
+ */
143
+ private wireHandlers;
144
+ /**
145
+ * Connect the underlying MCP Server to a transport (stdio, HTTP,
146
+ * etc.). Returns when the connection is established; the server
147
+ * continues serving until the transport closes.
148
+ *
149
+ * If `validateOnStart` (default true) is enabled, performs a
150
+ * GET /v1/ping check BEFORE wiring the transport. On failure,
151
+ * throws — the partner's MCP client sees a startup error instead
152
+ * of a confusing "tools work but the first call 401s" experience.
153
+ */
154
+ connect(transport: Transport): Promise<void>;
155
+ /**
156
+ * GET /v1/ping with the configured credential. Throws on non-2xx.
157
+ * Called by `connect()` if `validateOnStart` is true.
158
+ *
159
+ * Uses `resolveIdentity` so it stays in lockstep with the
160
+ * graceful-degradation contract (works whether backend has shipped
161
+ * the extended ping shape or not — we only care about the 2xx vs
162
+ * non-2xx signal for validation).
163
+ */
164
+ private validateCredentials;
165
+ /** Close the underlying MCP Server. Idempotent. */
166
+ close(): Promise<void>;
167
+ /**
168
+ * Names of the tools registered on this server, in registration
169
+ * order. Useful for tests + diagnostic logs. Read-only — the
170
+ * registered set is fixed at construction time.
171
+ */
172
+ get registeredToolNames(): readonly ToolName[];
173
+ /**
174
+ * Names of the resources registered on this server, in
175
+ * registration order. Read-only.
176
+ */
177
+ get registeredResourceNames(): readonly ResourceName[];
178
+ }
179
+
180
+ /**
181
+ * Stdio transport wiring.
182
+ *
183
+ * Re-exports the MCP SDK's `StdioServerTransport` so consumers don't
184
+ * need to know the SDK's internal module path. In v0.2 the HTTP
185
+ * transport will land alongside as `transport/http.ts`.
186
+ *
187
+ * Convention: this module ONLY constructs and returns the transport.
188
+ * Connecting it to the server is the caller's responsibility (see
189
+ * `cli.ts` for the standard wiring).
190
+ */
191
+
192
+ declare function createStdioTransport(): StdioServerTransport;
193
+
194
+ /**
195
+ * API key format validation + credential-type warnings.
196
+ *
197
+ * Vectros has three credential types:
198
+ * sk_* — root API key. Wildcard scope. Too broad for desktop MCP;
199
+ * warn the user on accept.
200
+ * ssk_* — server-side scoped key. Long-lived, narrowable scope.
201
+ * The RECOMMENDED credential for MCP. Accept silently.
202
+ * st_* — short-lived KMS-signed JWT (1h default / 24h max).
203
+ * Will expire mid-session; warn the user on accept.
204
+ *
205
+ * See the Vectros developer documentation on the auth model and
206
+ * scoped tokens ("When ssk_* is the right call") for the full rationale.
207
+ */
208
+
209
+ type KeyPrefix = 'sk' | 'ssk' | 'st';
210
+ type KeyEnv = 'live' | 'test';
211
+ declare class InvalidApiKeyError extends Error {
212
+ constructor(reason: string);
213
+ }
214
+
215
+ export { InvalidApiKeyError, type KeyEnv, type KeyPrefix, RESOURCE_NAMES, type ResourceName, TOOL_NAMES, type ToolName, VectrosMCPServer, type VectrosMCPServerOptions, createLogger, createStdioTransport };
@@ -0,0 +1,215 @@
1
+ import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
2
+ import { Logger } from 'pino';
3
+ export { Logger } from 'pino';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+
6
+ /**
7
+ * Structured logger — pino, always to stderr.
8
+ *
9
+ * CRITICAL: stdout is reserved for the MCP JSON-RPC stream when the
10
+ * server runs over stdio transport. Anything written to stdout that
11
+ * is not a valid JSON-RPC message corrupts the protocol and the
12
+ * client disconnects.
13
+ *
14
+ * Every log line goes to stderr. There are no exceptions.
15
+ */
16
+
17
+ interface LogContext {
18
+ debug?: boolean;
19
+ }
20
+ /**
21
+ * Build a stderr-destined logger.
22
+ *
23
+ * Pass `debug: true` (or set `VECTROS_MCP_DEBUG=1`) to lower the
24
+ * level to `debug`. Default is `info`.
25
+ */
26
+ declare function createLogger(ctx?: LogContext): Logger;
27
+
28
+ /**
29
+ * Shared tool-definition shape.
30
+ *
31
+ * Each tool is built as a factory that takes the Vectros SDK client
32
+ * (already authenticated) + a logger, and returns the registration
33
+ * payload for `server.registerTool()` plus the handler. The server
34
+ * class iterates the array and registers each one.
35
+ */
36
+
37
+ /**
38
+ * Names of all REGISTERED tools — the contract for what
39
+ * `tools: [...]` accepts and what default construction registers.
40
+ *
41
+ * MUST stay in lockstep with `ALL_TOOL_FACTORIES` in `./index.ts` —
42
+ * every name here needs a factory there, and vice versa. The server
43
+ * iterates this list at construction; an unimplemented name throws.
44
+ *
45
+ * v0.1 (shipped 2026-05-30): hybrid_search, record_query, rag_ask, document_ask
46
+ * v0.2 (shipped): list_schemas, document_get, current_identity, document_ingest
47
+ * launch data-plane I/O: record_get, record_create, record_update, record_delete (tier 1);
48
+ * document_query (tier 2);
49
+ * document_update, document_delete, folder_query,
50
+ * folder_create, folder_update, folder_delete (tier 3)
51
+ * (see the data-plane surface doc)
52
+ * parity sweep: lookup_principal (identity resolution for the
53
+ * ownership filters), version_history (record/document
54
+ * audit trail)
55
+ */
56
+ declare const TOOL_NAMES: readonly ["hybrid_search", "record_query", "record_get", "record_create", "record_update", "record_delete", "rag_ask", "document_ask", "list_schemas", "document_get", "document_query", "document_update", "document_delete", "folder_query", "folder_create", "folder_update", "folder_delete", "current_identity", "document_ingest", "lookup_principal", "version_history"];
57
+ type ToolName = (typeof TOOL_NAMES)[number];
58
+
59
+ /**
60
+ * Shared resource-definition shape — mirror of the tool factory
61
+ * pattern in ../tools/types.ts.
62
+ *
63
+ * MCP resources are read-only data discoverable via resources/list +
64
+ * resources/read JSON-RPC calls. Each resource has a stable URI,
65
+ * a human-readable name + description, a MIME type, and a `read()`
66
+ * function that returns its text content.
67
+ */
68
+
69
+ /**
70
+ * Names of all REGISTERED resources — the contract for what
71
+ * `resources: [...]` filter accepts.
72
+ *
73
+ * MUST stay in lockstep with `ALL_RESOURCE_FACTORIES` in
74
+ * `./index.ts` — every name here needs a factory there, and vice
75
+ * versa. The server iterates this list at construction; an
76
+ * unimplemented name throws.
77
+ */
78
+ declare const RESOURCE_NAMES: readonly ["schemas", "identity"];
79
+ type ResourceName = (typeof RESOURCE_NAMES)[number];
80
+
81
+ interface VectrosMCPServerOptions {
82
+ /** Vectros API key. REQUIRED. Recommended shape: ssk_live_... or ssk_test_.... */
83
+ apiKey: string;
84
+ /** Opt-in tool filter. Default: all v0.1 tools enabled. */
85
+ tools?: ToolName[];
86
+ /**
87
+ * Opt-in resource filter (v0.2+). Default: all resources enabled.
88
+ * Pass `[]` to register zero resources (server advertises no
89
+ * resources capability via tools/list).
90
+ */
91
+ resources?: ResourceName[];
92
+ /**
93
+ * Vectros API base URL. Default: https://api.vectros.ai. The SDK
94
+ * calls this `environment`; we keep the docs-aligned name on our
95
+ * surface to match the design doc.
96
+ */
97
+ apiBaseUrl?: string;
98
+ /** Provide a logger to capture server output. Default: pino → stderr. */
99
+ logger?: Logger;
100
+ /**
101
+ * Which transport this server will be wired up with. Optional; only
102
+ * affects tool behavior that depends on partner-local-fs access
103
+ * (currently `document_ingest`'s filePath mode is stdio-only). The
104
+ * CLI entry points set this — `cli.ts` passes 'stdio', the v0.2
105
+ * `cli-http.ts` passes 'http'. Programmatic embedders default to
106
+ * 'stdio' semantics if omitted.
107
+ */
108
+ transport?: 'stdio' | 'http';
109
+ /**
110
+ * If true (default in v0.2), perform a GET /v1/ping check during
111
+ * `connect()` to fail-fast on bad credentials BEFORE the MCP
112
+ * client sends its first tool call. The default is safe — partners
113
+ * who don't want the network roundtrip on startup can set false,
114
+ * but the trade-off is "credential failures surface mid-tool-call
115
+ * rather than at startup."
116
+ *
117
+ * The CLI honors `VECTROS_MCP_SKIP_PING_VALIDATION=1` env var as
118
+ * an explicit opt-out (sets this to false). Useful in CI / dev
119
+ * environments where the API isn't reachable.
120
+ */
121
+ validateOnStart?: boolean;
122
+ /**
123
+ * Filesystem root that `document_ingest`'s stdio `filePath` mode is
124
+ * jailed to. Overrides `VECTROS_MCP_INGEST_ROOT`; when both are
125
+ * absent the tool defaults to `process.cwd()`.
126
+ */
127
+ ingestRoot?: string;
128
+ }
129
+ declare class VectrosMCPServer {
130
+ private readonly server;
131
+ private readonly log;
132
+ private readonly tools;
133
+ private readonly resources;
134
+ private readonly apiKey;
135
+ private readonly environment;
136
+ private readonly validateOnStart;
137
+ constructor(opts: VectrosMCPServerOptions);
138
+ /**
139
+ * Wire `tools/list` and `tools/call` JSON-RPC handlers on the
140
+ * underlying MCP Server. Each tool's handler is wrapped to convert
141
+ * thrown errors into `isError: true` tool results.
142
+ */
143
+ private wireHandlers;
144
+ /**
145
+ * Connect the underlying MCP Server to a transport (stdio, HTTP,
146
+ * etc.). Returns when the connection is established; the server
147
+ * continues serving until the transport closes.
148
+ *
149
+ * If `validateOnStart` (default true) is enabled, performs a
150
+ * GET /v1/ping check BEFORE wiring the transport. On failure,
151
+ * throws — the partner's MCP client sees a startup error instead
152
+ * of a confusing "tools work but the first call 401s" experience.
153
+ */
154
+ connect(transport: Transport): Promise<void>;
155
+ /**
156
+ * GET /v1/ping with the configured credential. Throws on non-2xx.
157
+ * Called by `connect()` if `validateOnStart` is true.
158
+ *
159
+ * Uses `resolveIdentity` so it stays in lockstep with the
160
+ * graceful-degradation contract (works whether backend has shipped
161
+ * the extended ping shape or not — we only care about the 2xx vs
162
+ * non-2xx signal for validation).
163
+ */
164
+ private validateCredentials;
165
+ /** Close the underlying MCP Server. Idempotent. */
166
+ close(): Promise<void>;
167
+ /**
168
+ * Names of the tools registered on this server, in registration
169
+ * order. Useful for tests + diagnostic logs. Read-only — the
170
+ * registered set is fixed at construction time.
171
+ */
172
+ get registeredToolNames(): readonly ToolName[];
173
+ /**
174
+ * Names of the resources registered on this server, in
175
+ * registration order. Read-only.
176
+ */
177
+ get registeredResourceNames(): readonly ResourceName[];
178
+ }
179
+
180
+ /**
181
+ * Stdio transport wiring.
182
+ *
183
+ * Re-exports the MCP SDK's `StdioServerTransport` so consumers don't
184
+ * need to know the SDK's internal module path. In v0.2 the HTTP
185
+ * transport will land alongside as `transport/http.ts`.
186
+ *
187
+ * Convention: this module ONLY constructs and returns the transport.
188
+ * Connecting it to the server is the caller's responsibility (see
189
+ * `cli.ts` for the standard wiring).
190
+ */
191
+
192
+ declare function createStdioTransport(): StdioServerTransport;
193
+
194
+ /**
195
+ * API key format validation + credential-type warnings.
196
+ *
197
+ * Vectros has three credential types:
198
+ * sk_* — root API key. Wildcard scope. Too broad for desktop MCP;
199
+ * warn the user on accept.
200
+ * ssk_* — server-side scoped key. Long-lived, narrowable scope.
201
+ * The RECOMMENDED credential for MCP. Accept silently.
202
+ * st_* — short-lived KMS-signed JWT (1h default / 24h max).
203
+ * Will expire mid-session; warn the user on accept.
204
+ *
205
+ * See the Vectros developer documentation on the auth model and
206
+ * scoped tokens ("When ssk_* is the right call") for the full rationale.
207
+ */
208
+
209
+ type KeyPrefix = 'sk' | 'ssk' | 'st';
210
+ type KeyEnv = 'live' | 'test';
211
+ declare class InvalidApiKeyError extends Error {
212
+ constructor(reason: string);
213
+ }
214
+
215
+ export { InvalidApiKeyError, type KeyEnv, type KeyPrefix, RESOURCE_NAMES, type ResourceName, TOOL_NAMES, type ToolName, VectrosMCPServer, type VectrosMCPServerOptions, createLogger, createStdioTransport };