icode-mcp-adapter 1.0.6 → 1.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icode-mcp-adapter",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Dynamic MCP server adapter — auto-generates CRUD tools from schema configs. Plugs into icode-server via Fastify or runs standalone.",
5
5
  "type": "module",
6
6
  "main": "src/engine/McpEngine.js",
@@ -192,11 +192,12 @@ function regAdd(server, db, table, display, owner) {
192
192
  const insertVals = [];
193
193
  const placeholders = [];
194
194
 
195
- // Auto-set columns (_created)
195
+ // Auto-set _created — epoch ms for a bigint column, a Date for a datetime column
196
+ // (mysql2 serializes a Date to the column's expected 'YYYY-MM-DD HH:MM:SS').
196
197
  for (const c of table.columns) {
197
198
  if (c.autoSet === 'created_at') {
198
199
  insertCols.push(q(c.name));
199
- insertVals.push(Date.now());
200
+ insertVals.push(c.type === 'timestamp' ? Date.now() : new Date());
200
201
  placeholders.push('?');
201
202
  }
202
203
  }
@@ -49,11 +49,13 @@ function readBearer(req) {
49
49
  return /^bearer$/i.test(scheme) && token ? token.trim() : null;
50
50
  }
51
51
 
52
- /** MCP-spec 401 — points the client at the protected-resource metadata (Login with icode). */
52
+ /** MCP-spec 401 — points the client at the PER-RESOURCE metadata (RFC 9728), keeping the
53
+ * MCP path in the URL so the auth server knows which app/env is being authorized. */
53
54
  function unauthorized(req, reply) {
54
55
  const proto = req.headers['x-forwarded-proto'] || req.protocol || 'https';
55
56
  const host = req.headers['x-forwarded-host'] || req.headers.host;
56
- reply.header('WWW-Authenticate', `Bearer resource_metadata="${proto}://${host}/.well-known/oauth-protected-resource"`);
57
+ const path = (req.url || '').split('?')[0]; // e.g. /v1/mcp/paaal4--dev
58
+ reply.header('WWW-Authenticate', `Bearer resource_metadata="${proto}://${host}/.well-known/oauth-protected-resource${path}"`);
57
59
  return reply.code(401).send({
58
60
  jsonrpc: '2.0',
59
61
  error: { code: -32001, message: 'Authentication required' },