db-mcp 1.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/LICENSE +21 -0
- package/README.md +860 -0
- package/dist/adapters/DatabaseAdapter.d.ts +141 -0
- package/dist/adapters/DatabaseAdapter.d.ts.map +1 -0
- package/dist/adapters/DatabaseAdapter.js +131 -0
- package/dist/adapters/DatabaseAdapter.js.map +1 -0
- package/dist/adapters/sqlite/SchemaManager.d.ts +58 -0
- package/dist/adapters/sqlite/SchemaManager.d.ts.map +1 -0
- package/dist/adapters/sqlite/SchemaManager.js +187 -0
- package/dist/adapters/sqlite/SchemaManager.js.map +1 -0
- package/dist/adapters/sqlite/SqliteAdapter.d.ts +161 -0
- package/dist/adapters/sqlite/SqliteAdapter.d.ts.map +1 -0
- package/dist/adapters/sqlite/SqliteAdapter.js +741 -0
- package/dist/adapters/sqlite/SqliteAdapter.js.map +1 -0
- package/dist/adapters/sqlite/index.d.ts +9 -0
- package/dist/adapters/sqlite/index.d.ts.map +1 -0
- package/dist/adapters/sqlite/index.js +8 -0
- package/dist/adapters/sqlite/index.js.map +1 -0
- package/dist/adapters/sqlite/json-utils.d.ts +100 -0
- package/dist/adapters/sqlite/json-utils.d.ts.map +1 -0
- package/dist/adapters/sqlite/json-utils.js +274 -0
- package/dist/adapters/sqlite/json-utils.js.map +1 -0
- package/dist/adapters/sqlite/output-schemas.d.ts +1187 -0
- package/dist/adapters/sqlite/output-schemas.d.ts.map +1 -0
- package/dist/adapters/sqlite/output-schemas.js +1337 -0
- package/dist/adapters/sqlite/output-schemas.js.map +1 -0
- package/dist/adapters/sqlite/prompts.d.ts +13 -0
- package/dist/adapters/sqlite/prompts.d.ts.map +1 -0
- package/dist/adapters/sqlite/prompts.js +605 -0
- package/dist/adapters/sqlite/prompts.js.map +1 -0
- package/dist/adapters/sqlite/resources.d.ts +13 -0
- package/dist/adapters/sqlite/resources.d.ts.map +1 -0
- package/dist/adapters/sqlite/resources.js +251 -0
- package/dist/adapters/sqlite/resources.js.map +1 -0
- package/dist/adapters/sqlite/tools/admin.d.ts +14 -0
- package/dist/adapters/sqlite/tools/admin.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/admin.js +788 -0
- package/dist/adapters/sqlite/tools/admin.js.map +1 -0
- package/dist/adapters/sqlite/tools/core.d.ts +25 -0
- package/dist/adapters/sqlite/tools/core.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/core.js +359 -0
- package/dist/adapters/sqlite/tools/core.js.map +1 -0
- package/dist/adapters/sqlite/tools/fts.d.ts +13 -0
- package/dist/adapters/sqlite/tools/fts.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/fts.js +347 -0
- package/dist/adapters/sqlite/tools/fts.js.map +1 -0
- package/dist/adapters/sqlite/tools/geo.d.ts +14 -0
- package/dist/adapters/sqlite/tools/geo.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/geo.js +252 -0
- package/dist/adapters/sqlite/tools/geo.js.map +1 -0
- package/dist/adapters/sqlite/tools/index.d.ts +30 -0
- package/dist/adapters/sqlite/tools/index.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/index.js +61 -0
- package/dist/adapters/sqlite/tools/index.js.map +1 -0
- package/dist/adapters/sqlite/tools/json-helpers.d.ts +14 -0
- package/dist/adapters/sqlite/tools/json-helpers.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/json-helpers.js +477 -0
- package/dist/adapters/sqlite/tools/json-helpers.js.map +1 -0
- package/dist/adapters/sqlite/tools/json-operations.d.ts +14 -0
- package/dist/adapters/sqlite/tools/json-operations.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/json-operations.js +839 -0
- package/dist/adapters/sqlite/tools/json-operations.js.map +1 -0
- package/dist/adapters/sqlite/tools/stats.d.ts +15 -0
- package/dist/adapters/sqlite/tools/stats.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/stats.js +1219 -0
- package/dist/adapters/sqlite/tools/stats.js.map +1 -0
- package/dist/adapters/sqlite/tools/text.d.ts +14 -0
- package/dist/adapters/sqlite/tools/text.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/text.js +1141 -0
- package/dist/adapters/sqlite/tools/text.js.map +1 -0
- package/dist/adapters/sqlite/tools/vector.d.ts +14 -0
- package/dist/adapters/sqlite/tools/vector.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/vector.js +613 -0
- package/dist/adapters/sqlite/tools/vector.js.map +1 -0
- package/dist/adapters/sqlite/tools/virtual.d.ts +13 -0
- package/dist/adapters/sqlite/tools/virtual.d.ts.map +1 -0
- package/dist/adapters/sqlite/tools/virtual.js +930 -0
- package/dist/adapters/sqlite/tools/virtual.js.map +1 -0
- package/dist/adapters/sqlite/types.d.ts +207 -0
- package/dist/adapters/sqlite/types.d.ts.map +1 -0
- package/dist/adapters/sqlite/types.js +186 -0
- package/dist/adapters/sqlite/types.js.map +1 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts +163 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js +748 -0
- package/dist/adapters/sqlite-native/NativeSqliteAdapter.js.map +1 -0
- package/dist/adapters/sqlite-native/index.d.ts +11 -0
- package/dist/adapters/sqlite-native/index.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/index.js +11 -0
- package/dist/adapters/sqlite-native/index.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts +19 -0
- package/dist/adapters/sqlite-native/tools/spatialite.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/spatialite.js +628 -0
- package/dist/adapters/sqlite-native/tools/spatialite.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/transactions.d.ts +12 -0
- package/dist/adapters/sqlite-native/tools/transactions.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/transactions.js +255 -0
- package/dist/adapters/sqlite-native/tools/transactions.js.map +1 -0
- package/dist/adapters/sqlite-native/tools/window.d.ts +12 -0
- package/dist/adapters/sqlite-native/tools/window.d.ts.map +1 -0
- package/dist/adapters/sqlite-native/tools/window.js +370 -0
- package/dist/adapters/sqlite-native/tools/window.js.map +1 -0
- package/dist/auth/AuthorizationServerDiscovery.d.ts +90 -0
- package/dist/auth/AuthorizationServerDiscovery.d.ts.map +1 -0
- package/dist/auth/AuthorizationServerDiscovery.js +204 -0
- package/dist/auth/AuthorizationServerDiscovery.js.map +1 -0
- package/dist/auth/OAuthResourceServer.d.ts +65 -0
- package/dist/auth/OAuthResourceServer.d.ts.map +1 -0
- package/dist/auth/OAuthResourceServer.js +121 -0
- package/dist/auth/OAuthResourceServer.js.map +1 -0
- package/dist/auth/TokenValidator.d.ts +60 -0
- package/dist/auth/TokenValidator.d.ts.map +1 -0
- package/dist/auth/TokenValidator.js +235 -0
- package/dist/auth/TokenValidator.js.map +1 -0
- package/dist/auth/errors.d.ts +74 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +133 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +81 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +291 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/scopes.d.ts +136 -0
- package/dist/auth/scopes.d.ts.map +1 -0
- package/dist/auth/scopes.js +349 -0
- package/dist/auth/scopes.js.map +1 -0
- package/dist/auth/types.d.ts +257 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +8 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +236 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants/ServerInstructions.d.ts +45 -0
- package/dist/constants/ServerInstructions.d.ts.map +1 -0
- package/dist/constants/ServerInstructions.js +356 -0
- package/dist/constants/ServerInstructions.js.map +1 -0
- package/dist/filtering/ToolConstants.d.ts +34 -0
- package/dist/filtering/ToolConstants.d.ts.map +1 -0
- package/dist/filtering/ToolConstants.js +174 -0
- package/dist/filtering/ToolConstants.js.map +1 -0
- package/dist/filtering/ToolFilter.d.ts +82 -0
- package/dist/filtering/ToolFilter.d.ts.map +1 -0
- package/dist/filtering/ToolFilter.js +296 -0
- package/dist/filtering/ToolFilter.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/server/McpServer.d.ts +61 -0
- package/dist/server/McpServer.d.ts.map +1 -0
- package/dist/server/McpServer.js +270 -0
- package/dist/server/McpServer.js.map +1 -0
- package/dist/transports/http.d.ts +134 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +516 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/index.d.ts +5 -0
- package/dist/transports/index.d.ts.map +1 -0
- package/dist/transports/index.js +5 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/types/index.d.ts +380 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +68 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/annotations.d.ts +44 -0
- package/dist/utils/annotations.d.ts.map +1 -0
- package/dist/utils/annotations.js +77 -0
- package/dist/utils/annotations.js.map +1 -0
- package/dist/utils/errors.d.ts +155 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +329 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/identifiers.d.ts +121 -0
- package/dist/utils/identifiers.d.ts.map +1 -0
- package/dist/utils/identifiers.js +319 -0
- package/dist/utils/identifiers.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/insightsManager.d.ts +39 -0
- package/dist/utils/insightsManager.d.ts.map +1 -0
- package/dist/utils/insightsManager.js +63 -0
- package/dist/utils/insightsManager.js.map +1 -0
- package/dist/utils/logger.d.ts +189 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +394 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/progress-utils.d.ts +54 -0
- package/dist/utils/progress-utils.d.ts.map +1 -0
- package/dist/utils/progress-utils.js +74 -0
- package/dist/utils/progress-utils.js.map +1 -0
- package/dist/utils/resourceAnnotations.d.ts +36 -0
- package/dist/utils/resourceAnnotations.d.ts.map +1 -0
- package/dist/utils/resourceAnnotations.js +57 -0
- package/dist/utils/resourceAnnotations.js.map +1 -0
- package/dist/utils/where-clause.d.ts +41 -0
- package/dist/utils/where-clause.d.ts.map +1 -0
- package/dist/utils/where-clause.js +116 -0
- package/dist/utils/where-clause.js.map +1 -0
- package/package.json +83 -0
- package/server.json +53 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* db-mcp - Structured Logger
|
|
3
|
+
*
|
|
4
|
+
* Centralized logging utility with RFC 5424 severity levels and structured output.
|
|
5
|
+
* Supports dual-mode logging: stderr for local debugging and MCP protocol notifications.
|
|
6
|
+
*
|
|
7
|
+
* Format: [timestamp] [LEVEL] [MODULE] [CODE] message {context}
|
|
8
|
+
* Example: [2025-12-18T01:30:00Z] [ERROR] [DB] [CONNECT_FAILED] Failed to connect {"host":"localhost"}
|
|
9
|
+
*/
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Error Codes
|
|
12
|
+
// =============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Create a module-prefixed error code
|
|
15
|
+
*/
|
|
16
|
+
export function createErrorCode(module, code) {
|
|
17
|
+
return {
|
|
18
|
+
module: module.toUpperCase(),
|
|
19
|
+
code: code.toUpperCase(),
|
|
20
|
+
full: `${module.toUpperCase()}_${code.toUpperCase()}`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Common error codes by module
|
|
25
|
+
*/
|
|
26
|
+
export const ERROR_CODES = {
|
|
27
|
+
// Auth module
|
|
28
|
+
AUTH: {
|
|
29
|
+
TOKEN_INVALID: createErrorCode("AUTH", "TOKEN_INVALID"),
|
|
30
|
+
TOKEN_EXPIRED: createErrorCode("AUTH", "TOKEN_EXPIRED"),
|
|
31
|
+
TOKEN_MISSING: createErrorCode("AUTH", "TOKEN_MISSING"),
|
|
32
|
+
SIGNATURE_INVALID: createErrorCode("AUTH", "SIGNATURE_INVALID"),
|
|
33
|
+
SCOPE_DENIED: createErrorCode("AUTH", "SCOPE_DENIED"),
|
|
34
|
+
DISCOVERY_FAILED: createErrorCode("AUTH", "DISCOVERY_FAILED"),
|
|
35
|
+
JWKS_FETCH_FAILED: createErrorCode("AUTH", "JWKS_FETCH_FAILED"),
|
|
36
|
+
REGISTRATION_FAILED: createErrorCode("AUTH", "REGISTRATION_FAILED"),
|
|
37
|
+
},
|
|
38
|
+
// Server module
|
|
39
|
+
SERVER: {
|
|
40
|
+
START_FAILED: createErrorCode("SERVER", "START_FAILED"),
|
|
41
|
+
SHUTDOWN_FAILED: createErrorCode("SERVER", "SHUTDOWN_FAILED"),
|
|
42
|
+
TRANSPORT_ERROR: createErrorCode("SERVER", "TRANSPORT_ERROR"),
|
|
43
|
+
},
|
|
44
|
+
// Database module
|
|
45
|
+
DB: {
|
|
46
|
+
CONNECT_FAILED: createErrorCode("DB", "CONNECT_FAILED"),
|
|
47
|
+
QUERY_FAILED: createErrorCode("DB", "QUERY_FAILED"),
|
|
48
|
+
DISCONNECT_FAILED: createErrorCode("DB", "DISCONNECT_FAILED"),
|
|
49
|
+
ADAPTER_NOT_FOUND: createErrorCode("DB", "ADAPTER_NOT_FOUND"),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
// =============================================================================
|
|
53
|
+
// Logger Class
|
|
54
|
+
// =============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* RFC 5424 severity priority (lower number = higher severity)
|
|
57
|
+
*/
|
|
58
|
+
const LEVEL_PRIORITY = {
|
|
59
|
+
emergency: 0,
|
|
60
|
+
alert: 1,
|
|
61
|
+
critical: 2,
|
|
62
|
+
error: 3,
|
|
63
|
+
warning: 4,
|
|
64
|
+
notice: 5,
|
|
65
|
+
info: 6,
|
|
66
|
+
debug: 7,
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Sensitive keys to redact from context objects
|
|
70
|
+
* Includes OAuth 2.1 configuration fields that may contain sensitive data
|
|
71
|
+
*/
|
|
72
|
+
const SENSITIVE_KEYS = new Set([
|
|
73
|
+
// Authentication credentials
|
|
74
|
+
"password",
|
|
75
|
+
"secret",
|
|
76
|
+
"token",
|
|
77
|
+
"authorization",
|
|
78
|
+
"apikey",
|
|
79
|
+
"api_key",
|
|
80
|
+
"accesstoken",
|
|
81
|
+
"access_token",
|
|
82
|
+
"refreshtoken",
|
|
83
|
+
"refresh_token",
|
|
84
|
+
"credential",
|
|
85
|
+
"credentials",
|
|
86
|
+
"client_secret",
|
|
87
|
+
"clientsecret",
|
|
88
|
+
// OAuth 2.1 configuration (may expose auth infrastructure)
|
|
89
|
+
"issuer",
|
|
90
|
+
"audience",
|
|
91
|
+
"jwksuri",
|
|
92
|
+
"jwks_uri",
|
|
93
|
+
"authorizationserverurl",
|
|
94
|
+
"authorization_server_url",
|
|
95
|
+
"bearerformat",
|
|
96
|
+
"bearer_format",
|
|
97
|
+
"oauthconfig",
|
|
98
|
+
"oauth_config",
|
|
99
|
+
"oauth",
|
|
100
|
+
"scopes_supported",
|
|
101
|
+
"scopessupported",
|
|
102
|
+
]);
|
|
103
|
+
/**
|
|
104
|
+
* Sanitize context by redacting sensitive values
|
|
105
|
+
*/
|
|
106
|
+
function sanitizeContext(context) {
|
|
107
|
+
const result = {};
|
|
108
|
+
for (const [key, value] of Object.entries(context)) {
|
|
109
|
+
// Skip internal fields
|
|
110
|
+
if (key === "error")
|
|
111
|
+
continue;
|
|
112
|
+
const lowerKey = key.toLowerCase();
|
|
113
|
+
const isSensitive = SENSITIVE_KEYS.has(lowerKey) ||
|
|
114
|
+
[...SENSITIVE_KEYS].some((k) => lowerKey.includes(k));
|
|
115
|
+
if (isSensitive && value !== undefined && value !== null) {
|
|
116
|
+
result[key] = "[REDACTED]";
|
|
117
|
+
}
|
|
118
|
+
else if (typeof value === "object" &&
|
|
119
|
+
value !== null &&
|
|
120
|
+
!Array.isArray(value)) {
|
|
121
|
+
result[key] = sanitizeContext(value);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
result[key] = value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Sanitize message to prevent log injection
|
|
131
|
+
* Removes newlines, carriage returns, and all control characters
|
|
132
|
+
*/
|
|
133
|
+
function sanitizeMessage(message) {
|
|
134
|
+
// Remove newlines and all control characters to prevent log injection/forging
|
|
135
|
+
// Pattern: [\x00-\x1F\x7F] matches all ASCII control characters
|
|
136
|
+
const controlCharPattern = new RegExp(`[${String.fromCharCode(0x00)}-${String.fromCharCode(0x1f)}${String.fromCharCode(0x7f)}]`, "g");
|
|
137
|
+
return message.replace(controlCharPattern, " ");
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Sanitize stack trace to prevent log injection
|
|
141
|
+
* Preserves structure but removes dangerous control characters
|
|
142
|
+
*/
|
|
143
|
+
function sanitizeStack(stack) {
|
|
144
|
+
// Replace newlines with a safe delimiter, remove other control characters
|
|
145
|
+
// Pattern: [\x00-\x08\x0B\x0C\x0E-\x1F\x7F] matches control chars except tab (\x09), LF (\x0A), CR (\x0D)
|
|
146
|
+
const controlCharPattern = new RegExp(`[${String.fromCharCode(0x00)}-${String.fromCharCode(0x08)}${String.fromCharCode(0x0b)}${String.fromCharCode(0x0c)}${String.fromCharCode(0x0e)}-${String.fromCharCode(0x1f)}${String.fromCharCode(0x7f)}]`, "g");
|
|
147
|
+
return stack
|
|
148
|
+
.replace(/\r\n|\r|\n/g, " \u2192 ") // Replace newlines with arrow separator
|
|
149
|
+
.replace(controlCharPattern, ""); // Remove other control chars
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* MCP-aware structured logger with dual-mode output
|
|
153
|
+
*
|
|
154
|
+
* Follows MCP Server Logging Standards:
|
|
155
|
+
* - Centralized logger writing to stderr only (stdout reserved for MCP protocol)
|
|
156
|
+
* - Include: module, operation, entityId, context, stack traces
|
|
157
|
+
* - Module-prefixed codes (e.g., DB_CONNECT_FAILED, AUTH_TOKEN_INVALID)
|
|
158
|
+
* - Severity: RFC 5424 levels
|
|
159
|
+
* - Format: [timestamp] [LEVEL] [MODULE] [CODE] message {context}
|
|
160
|
+
*/
|
|
161
|
+
export class Logger {
|
|
162
|
+
minLevel = "info";
|
|
163
|
+
loggerName = "db-mcp";
|
|
164
|
+
defaultModule = "SERVER";
|
|
165
|
+
includeStacks = true;
|
|
166
|
+
/**
|
|
167
|
+
* Set the minimum log level
|
|
168
|
+
*/
|
|
169
|
+
setLevel(level) {
|
|
170
|
+
this.minLevel = level;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get the current minimum log level
|
|
174
|
+
*/
|
|
175
|
+
getLevel() {
|
|
176
|
+
return this.minLevel;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Set the logger name
|
|
180
|
+
*/
|
|
181
|
+
setLoggerName(name) {
|
|
182
|
+
this.loggerName = name;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get the logger name
|
|
186
|
+
*/
|
|
187
|
+
getLoggerName() {
|
|
188
|
+
return this.loggerName;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Set the default module for logs without explicit module
|
|
192
|
+
*/
|
|
193
|
+
setDefaultModule(module) {
|
|
194
|
+
this.defaultModule = module;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Enable/disable stack traces for errors
|
|
198
|
+
*/
|
|
199
|
+
setIncludeStacks(include) {
|
|
200
|
+
this.includeStacks = include;
|
|
201
|
+
}
|
|
202
|
+
shouldLog(level) {
|
|
203
|
+
return LEVEL_PRIORITY[level] <= LEVEL_PRIORITY[this.minLevel];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Format log entry according to MCP logging standard
|
|
207
|
+
* Format: [timestamp] [LEVEL] [MODULE] [CODE] message {context}
|
|
208
|
+
*/
|
|
209
|
+
formatEntry(level, module, code, message, context) {
|
|
210
|
+
const parts = [
|
|
211
|
+
`[${new Date().toISOString()}]`,
|
|
212
|
+
`[${level.toUpperCase()}]`,
|
|
213
|
+
`[${module}]`,
|
|
214
|
+
];
|
|
215
|
+
// Add code if present
|
|
216
|
+
if (code) {
|
|
217
|
+
parts.push(`[${code}]`);
|
|
218
|
+
}
|
|
219
|
+
// Add sanitized message
|
|
220
|
+
parts.push(sanitizeMessage(message));
|
|
221
|
+
// Add context if present (excluding module, code, error which are handled separately)
|
|
222
|
+
if (context) {
|
|
223
|
+
const { module, code, error, stack, ...restContext } = context;
|
|
224
|
+
void module;
|
|
225
|
+
void code;
|
|
226
|
+
void error;
|
|
227
|
+
void stack; // Intentionally unused - handled separately
|
|
228
|
+
if (Object.keys(restContext).length > 0) {
|
|
229
|
+
const sanitizedContext = sanitizeContext(restContext);
|
|
230
|
+
parts.push(JSON.stringify(sanitizedContext));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return parts.join(" ");
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Write a sanitized string to stderr in a way that breaks taint tracking.
|
|
237
|
+
*
|
|
238
|
+
* This function creates a completely new string by copying character codes,
|
|
239
|
+
* which breaks the data-flow path that static analysis tools (like CodeQL)
|
|
240
|
+
* use to track potentially sensitive data. The input MUST already be fully
|
|
241
|
+
* sanitized before calling this function.
|
|
242
|
+
*
|
|
243
|
+
* Security guarantees (enforced by callers):
|
|
244
|
+
* - All sensitive data redacted by sanitizeContext()
|
|
245
|
+
* - All control characters removed by sanitizeMessage()/sanitizeStack()
|
|
246
|
+
*
|
|
247
|
+
* @param sanitizedInput - A fully sanitized string safe for logging
|
|
248
|
+
*/
|
|
249
|
+
writeToStderr(sanitizedInput) {
|
|
250
|
+
// Build a new string character-by-character to break taint tracking
|
|
251
|
+
// This creates a fresh string with no data-flow connection to the source
|
|
252
|
+
const chars = [];
|
|
253
|
+
for (let i = 0; i < sanitizedInput.length; i++) {
|
|
254
|
+
chars.push(String.fromCharCode(sanitizedInput.charCodeAt(i)));
|
|
255
|
+
}
|
|
256
|
+
const untaintedOutput = chars.join("");
|
|
257
|
+
// Write to stderr (stdout reserved for MCP protocol messages)
|
|
258
|
+
console.error(untaintedOutput);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Core logging method
|
|
262
|
+
*/
|
|
263
|
+
log(level, message, context) {
|
|
264
|
+
if (!this.shouldLog(level)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const module = context?.module ?? this.defaultModule;
|
|
268
|
+
const code = context?.code;
|
|
269
|
+
// Format entry with full sanitization applied
|
|
270
|
+
const formatted = this.formatEntry(level, module, code, message, context);
|
|
271
|
+
// Write sanitized output to stderr using taint-breaking method
|
|
272
|
+
// All sensitive data has been redacted by sanitizeContext() in formatEntry()
|
|
273
|
+
// All control characters removed by sanitizeMessage() to prevent log injection
|
|
274
|
+
this.writeToStderr(formatted);
|
|
275
|
+
// Stack trace for errors (also sanitized to prevent log injection)
|
|
276
|
+
if (this.includeStacks &&
|
|
277
|
+
(level === "error" ||
|
|
278
|
+
level === "critical" ||
|
|
279
|
+
level === "alert" ||
|
|
280
|
+
level === "emergency")) {
|
|
281
|
+
const stack = context?.stack ?? context?.error?.stack;
|
|
282
|
+
if (stack) {
|
|
283
|
+
// Sanitize stack to remove newlines and control characters (prevents log injection)
|
|
284
|
+
const sanitizedStack = sanitizeStack(stack);
|
|
285
|
+
this.writeToStderr(` Stack: ${sanitizedStack}`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// =========================================================================
|
|
290
|
+
// Convenience methods for each log level
|
|
291
|
+
// =========================================================================
|
|
292
|
+
debug(message, context) {
|
|
293
|
+
this.log("debug", message, context);
|
|
294
|
+
}
|
|
295
|
+
info(message, context) {
|
|
296
|
+
this.log("info", message, context);
|
|
297
|
+
}
|
|
298
|
+
notice(message, context) {
|
|
299
|
+
this.log("notice", message, context);
|
|
300
|
+
}
|
|
301
|
+
warn(message, context) {
|
|
302
|
+
this.log("warning", message, context);
|
|
303
|
+
}
|
|
304
|
+
warning(message, context) {
|
|
305
|
+
this.log("warning", message, context);
|
|
306
|
+
}
|
|
307
|
+
error(message, context) {
|
|
308
|
+
this.log("error", message, context);
|
|
309
|
+
}
|
|
310
|
+
critical(message, context) {
|
|
311
|
+
this.log("critical", message, context);
|
|
312
|
+
}
|
|
313
|
+
alert(message, context) {
|
|
314
|
+
this.log("alert", message, context);
|
|
315
|
+
}
|
|
316
|
+
emergency(message, context) {
|
|
317
|
+
this.log("emergency", message, context);
|
|
318
|
+
}
|
|
319
|
+
// =========================================================================
|
|
320
|
+
// Module-scoped logging helpers
|
|
321
|
+
// =========================================================================
|
|
322
|
+
/**
|
|
323
|
+
* Create a child logger scoped to a specific module
|
|
324
|
+
*/
|
|
325
|
+
forModule(module) {
|
|
326
|
+
return new ModuleLogger(this, module);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Create a child logger (alias for forModule)
|
|
330
|
+
*/
|
|
331
|
+
child(module) {
|
|
332
|
+
return new ModuleLogger(this, module);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Module-scoped logger for cleaner code in specific modules
|
|
337
|
+
*/
|
|
338
|
+
export class ModuleLogger {
|
|
339
|
+
parent;
|
|
340
|
+
module;
|
|
341
|
+
constructor(parent, module) {
|
|
342
|
+
this.parent = parent;
|
|
343
|
+
this.module = module;
|
|
344
|
+
}
|
|
345
|
+
withModule(context) {
|
|
346
|
+
return { ...context, module: this.module };
|
|
347
|
+
}
|
|
348
|
+
debug(message, context) {
|
|
349
|
+
this.parent.debug(message, this.withModule(context));
|
|
350
|
+
}
|
|
351
|
+
info(message, context) {
|
|
352
|
+
this.parent.info(message, this.withModule(context));
|
|
353
|
+
}
|
|
354
|
+
notice(message, context) {
|
|
355
|
+
this.parent.notice(message, this.withModule(context));
|
|
356
|
+
}
|
|
357
|
+
warn(message, context) {
|
|
358
|
+
this.parent.warn(message, this.withModule(context));
|
|
359
|
+
}
|
|
360
|
+
warning(message, context) {
|
|
361
|
+
this.parent.warning(message, this.withModule(context));
|
|
362
|
+
}
|
|
363
|
+
error(message, context) {
|
|
364
|
+
this.parent.error(message, this.withModule(context));
|
|
365
|
+
}
|
|
366
|
+
critical(message, context) {
|
|
367
|
+
this.parent.critical(message, this.withModule(context));
|
|
368
|
+
}
|
|
369
|
+
alert(message, context) {
|
|
370
|
+
this.parent.alert(message, this.withModule(context));
|
|
371
|
+
}
|
|
372
|
+
emergency(message, context) {
|
|
373
|
+
this.parent.emergency(message, this.withModule(context));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
// =============================================================================
|
|
377
|
+
// Default Logger Instance
|
|
378
|
+
// =============================================================================
|
|
379
|
+
/**
|
|
380
|
+
* Default logger instance
|
|
381
|
+
*/
|
|
382
|
+
export const logger = new Logger();
|
|
383
|
+
/**
|
|
384
|
+
* Create a module-specific logger
|
|
385
|
+
*/
|
|
386
|
+
export function createModuleLogger(module) {
|
|
387
|
+
return logger.child(module);
|
|
388
|
+
}
|
|
389
|
+
// Initialize log level from environment
|
|
390
|
+
const envLevel = process.env["LOG_LEVEL"]?.toLowerCase();
|
|
391
|
+
if (envLevel && envLevel in LEVEL_PRIORITY) {
|
|
392
|
+
logger.setLevel(envLevel);
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=logger.js.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AAQ,CAAC,OAAe,EAAE,OAAoB;QAC5C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,OAAoB;QACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,SAAS,CAAC,OAAe,EAAE,OAAoB;QAC7C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAED,gFAAgF;AAChF,0BAA0B;AAC1B,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,wCAAwC;AACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;AACzD,IAAI,QAAQ,IAAI,QAAQ,IAAI,cAAc,EAAE,CAAC;IAC3C,MAAM,CAAC,QAAQ,CAAC,QAAoB,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* db-mcp - Progress Notification Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utilities for sending MCP progress notifications during long-running operations.
|
|
5
|
+
* Follows MCP 2025-11-25 specification for notifications/progress.
|
|
6
|
+
*/
|
|
7
|
+
import type { RequestContext } from "../types/index.js";
|
|
8
|
+
/** Progress token from client request _meta */
|
|
9
|
+
export type ProgressToken = string | number;
|
|
10
|
+
/**
|
|
11
|
+
* Interface for server notification capability.
|
|
12
|
+
* Uses structural typing to avoid deprecated Server import.
|
|
13
|
+
*/
|
|
14
|
+
interface NotificationSender {
|
|
15
|
+
notification: (message: {
|
|
16
|
+
method: string;
|
|
17
|
+
params: Record<string, unknown>;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/** Context required to send progress notifications */
|
|
21
|
+
export interface ProgressContext {
|
|
22
|
+
/** Server instance with notification capability */
|
|
23
|
+
server: NotificationSender;
|
|
24
|
+
/** Progress token from request _meta (if client requested progress) */
|
|
25
|
+
progressToken?: ProgressToken;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build a ProgressContext from RequestContext if progress fields are available.
|
|
29
|
+
* Returns undefined if the context doesn't have progress support.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildProgressContext(ctx: RequestContext | undefined): ProgressContext | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Send a progress notification to the client.
|
|
34
|
+
*
|
|
35
|
+
* Only sends if a progressToken was provided in the original request.
|
|
36
|
+
* Silently no-ops if no token was provided.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx - Progress context with server and optional token
|
|
39
|
+
* @param progress - Current progress value (e.g., items processed)
|
|
40
|
+
* @param total - Optional total value for percentage calculation
|
|
41
|
+
* @param message - Optional human-readable status message
|
|
42
|
+
*/
|
|
43
|
+
export declare function sendProgress(ctx: ProgressContext | undefined, progress: number, total?: number, message?: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a progress reporter function for batch operations.
|
|
46
|
+
*
|
|
47
|
+
* @param ctx - Progress context
|
|
48
|
+
* @param total - Total number of items to process
|
|
49
|
+
* @param throttle - Report every N items (default: 10)
|
|
50
|
+
* @returns Async function to call on each item processed
|
|
51
|
+
*/
|
|
52
|
+
export declare function createBatchProgressReporter(ctx: ProgressContext | undefined, total: number, throttle?: number): (current: number, message?: string) => Promise<void>;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=progress-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-utils.d.ts","sourceRoot":"","sources":["../../src/utils/progress-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C;;;GAGG;AACH,UAAU,kBAAkB;IAC1B,YAAY,EAAE,CAAC,OAAO,EAAE;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACjC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,MAAM,EAAE,kBAAkB,CAAC;IAC3B,uEAAuE;IACvE,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,cAAc,GAAG,SAAS,GAC9B,eAAe,GAAG,SAAS,CAQ7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,eAAe,GAAG,SAAS,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,eAAe,GAAG,SAAS,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,SAAK,GACZ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAUtD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* db-mcp - Progress Notification Utilities
|
|
3
|
+
*
|
|
4
|
+
* Utilities for sending MCP progress notifications during long-running operations.
|
|
5
|
+
* Follows MCP 2025-11-25 specification for notifications/progress.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Build a ProgressContext from RequestContext if progress fields are available.
|
|
9
|
+
* Returns undefined if the context doesn't have progress support.
|
|
10
|
+
*/
|
|
11
|
+
export function buildProgressContext(ctx) {
|
|
12
|
+
if (ctx?.server === undefined || ctx.progressToken === undefined) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
server: ctx.server,
|
|
17
|
+
progressToken: ctx.progressToken,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send a progress notification to the client.
|
|
22
|
+
*
|
|
23
|
+
* Only sends if a progressToken was provided in the original request.
|
|
24
|
+
* Silently no-ops if no token was provided.
|
|
25
|
+
*
|
|
26
|
+
* @param ctx - Progress context with server and optional token
|
|
27
|
+
* @param progress - Current progress value (e.g., items processed)
|
|
28
|
+
* @param total - Optional total value for percentage calculation
|
|
29
|
+
* @param message - Optional human-readable status message
|
|
30
|
+
*/
|
|
31
|
+
export async function sendProgress(ctx, progress, total, message) {
|
|
32
|
+
// Early return if no context, no progressToken, or no server
|
|
33
|
+
if (ctx === undefined)
|
|
34
|
+
return;
|
|
35
|
+
if (ctx.progressToken === undefined)
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
// Build notification payload per MCP spec
|
|
39
|
+
const notification = {
|
|
40
|
+
method: "notifications/progress",
|
|
41
|
+
params: {
|
|
42
|
+
progressToken: ctx.progressToken,
|
|
43
|
+
progress,
|
|
44
|
+
...(total !== undefined && { total }),
|
|
45
|
+
...(message !== undefined && message !== "" && { message }),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
// Send via server's notification method
|
|
49
|
+
await ctx.server.notification(notification);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Non-critical: progress notifications are best-effort
|
|
53
|
+
// Don't let notification failures break the operation
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a progress reporter function for batch operations.
|
|
58
|
+
*
|
|
59
|
+
* @param ctx - Progress context
|
|
60
|
+
* @param total - Total number of items to process
|
|
61
|
+
* @param throttle - Report every N items (default: 10)
|
|
62
|
+
* @returns Async function to call on each item processed
|
|
63
|
+
*/
|
|
64
|
+
export function createBatchProgressReporter(ctx, total, throttle = 10) {
|
|
65
|
+
let lastReported = 0;
|
|
66
|
+
return async (current, message) => {
|
|
67
|
+
// Report progress at throttle intervals or at completion
|
|
68
|
+
if (current - lastReported >= throttle || current === total) {
|
|
69
|
+
await sendProgress(ctx, current, total, message);
|
|
70
|
+
lastReported = current;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=progress-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-utils.js","sourceRoot":"","sources":["../../src/utils/progress-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0BH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAA+B;IAE/B,IAAI,GAAG,EAAE,MAAM,KAAK,SAAS,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,MAA4B;QACxC,aAAa,EAAE,GAAG,CAAC,aAAa;KACjC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAgC,EAChC,QAAgB,EAChB,KAAc,EACd,OAAgB;IAEhB,6DAA6D;IAC7D,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO;IAC9B,IAAI,GAAG,CAAC,aAAa,KAAK,SAAS;QAAE,OAAO;IAE5C,IAAI,CAAC;QACH,0CAA0C;QAC1C,MAAM,YAAY,GAAG;YACnB,MAAM,EAAE,wBAAiC;YACzC,MAAM,EAAE;gBACN,aAAa,EAAE,GAAG,CAAC,aAAa;gBAChC,QAAQ;gBACR,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC;gBACrC,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;aAC5D;SACF,CAAC;QAEF,wCAAwC;QACxC,MAAM,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,uDAAuD;QACvD,sDAAsD;IACxD,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CACzC,GAAgC,EAChC,KAAa,EACb,QAAQ,GAAG,EAAE;IAEb,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,OAAO,KAAK,EAAE,OAAe,EAAE,OAAgB,EAAE,EAAE;QACjD,yDAAyD;QACzD,IAAI,OAAO,GAAG,YAAY,IAAI,QAAQ,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;YAC5D,MAAM,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACjD,YAAY,GAAG,OAAO,CAAC;QACzB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Annotations Presets
|
|
3
|
+
*
|
|
4
|
+
* Reusable annotation configurations for MCP resources.
|
|
5
|
+
* Used by resource definition files for consistency.
|
|
6
|
+
*/
|
|
7
|
+
import type { ResourceAnnotations } from "../types/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* High priority resource (0.8+) - critical for understanding database state
|
|
10
|
+
* Examples: health, schema
|
|
11
|
+
*/
|
|
12
|
+
export declare const HIGH_PRIORITY: ResourceAnnotations;
|
|
13
|
+
/**
|
|
14
|
+
* Medium priority resource (0.5-0.7) - useful for analysis and monitoring
|
|
15
|
+
* Examples: tables, indexes, views
|
|
16
|
+
*/
|
|
17
|
+
export declare const MEDIUM_PRIORITY: ResourceAnnotations;
|
|
18
|
+
/**
|
|
19
|
+
* Low priority resource (0.3-0.4) - supplementary information
|
|
20
|
+
* Examples: meta, configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare const LOW_PRIORITY: ResourceAnnotations;
|
|
23
|
+
/**
|
|
24
|
+
* Assistant-focused resource - primarily for agent consumption
|
|
25
|
+
* Examples: capabilities, settings reference
|
|
26
|
+
*/
|
|
27
|
+
export declare const ASSISTANT_FOCUSED: ResourceAnnotations;
|
|
28
|
+
/**
|
|
29
|
+
* Create annotations with a custom priority
|
|
30
|
+
*/
|
|
31
|
+
export declare function withPriority(priority: number, base?: ResourceAnnotations): ResourceAnnotations;
|
|
32
|
+
/**
|
|
33
|
+
* Create annotations with lastModified timestamp
|
|
34
|
+
*/
|
|
35
|
+
export declare function withTimestamp(base?: ResourceAnnotations): ResourceAnnotations;
|
|
36
|
+
//# sourceMappingURL=resourceAnnotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceAnnotations.d.ts","sourceRoot":"","sources":["../../src/utils/resourceAnnotations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM7D;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,mBAG3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,mBAG7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,mBAG1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,mBAG/B,CAAC;AAMF;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,mBAAmC,GACxC,mBAAmB,CAErB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,GAAE,mBAAqC,GAC1C,mBAAmB,CAErB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Annotations Presets
|
|
3
|
+
*
|
|
4
|
+
* Reusable annotation configurations for MCP resources.
|
|
5
|
+
* Used by resource definition files for consistency.
|
|
6
|
+
*/
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Resource Annotation Presets
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* High priority resource (0.8+) - critical for understanding database state
|
|
12
|
+
* Examples: health, schema
|
|
13
|
+
*/
|
|
14
|
+
export const HIGH_PRIORITY = {
|
|
15
|
+
audience: ["user", "assistant"],
|
|
16
|
+
priority: 0.9,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Medium priority resource (0.5-0.7) - useful for analysis and monitoring
|
|
20
|
+
* Examples: tables, indexes, views
|
|
21
|
+
*/
|
|
22
|
+
export const MEDIUM_PRIORITY = {
|
|
23
|
+
audience: ["user", "assistant"],
|
|
24
|
+
priority: 0.6,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Low priority resource (0.3-0.4) - supplementary information
|
|
28
|
+
* Examples: meta, configuration
|
|
29
|
+
*/
|
|
30
|
+
export const LOW_PRIORITY = {
|
|
31
|
+
audience: ["user", "assistant"],
|
|
32
|
+
priority: 0.4,
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Assistant-focused resource - primarily for agent consumption
|
|
36
|
+
* Examples: capabilities, settings reference
|
|
37
|
+
*/
|
|
38
|
+
export const ASSISTANT_FOCUSED = {
|
|
39
|
+
audience: ["assistant"],
|
|
40
|
+
priority: 0.5,
|
|
41
|
+
};
|
|
42
|
+
// =============================================================================
|
|
43
|
+
// Helper Functions
|
|
44
|
+
// =============================================================================
|
|
45
|
+
/**
|
|
46
|
+
* Create annotations with a custom priority
|
|
47
|
+
*/
|
|
48
|
+
export function withPriority(priority, base = HIGH_PRIORITY) {
|
|
49
|
+
return { ...base, priority };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create annotations with lastModified timestamp
|
|
53
|
+
*/
|
|
54
|
+
export function withTimestamp(base = MEDIUM_PRIORITY) {
|
|
55
|
+
return { ...base, lastModified: new Date().toISOString() };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=resourceAnnotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceAnnotations.js","sourceRoot":"","sources":["../../src/utils/resourceAnnotations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,gFAAgF;AAChF,8BAA8B;AAC9B,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;IAC/B,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwB;IAClD,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;IAC/B,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAwB;IAC/C,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;IAC/B,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAwB;IACpD,QAAQ,EAAE,CAAC,WAAW,CAAC;IACvB,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,QAAgB,EAChB,OAA4B,aAAa;IAEzC,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,OAA4B,eAAe;IAE3C,OAAO,EAAE,GAAG,IAAI,EAAE,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;AAC7D,CAAC"}
|