drafted 1.17.4 → 1.17.6

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.
Files changed (2) hide show
  1. package/mcp/server.mjs +45 -3
  2. package/package.json +3 -3
package/mcp/server.mjs CHANGED
@@ -943,9 +943,22 @@ function enrichFetchError(error, url) {
943
943
  e.cause = error;
944
944
  return e;
945
945
  }
946
- async function serverFetch(url, opts) {
947
- try { return await fetch(url, opts); }
948
- catch (e) { throw enrichFetchError(e, url); }
946
+ // No fetch may hang the agent's process forever: undici has no default request
947
+ // timeout, so a wedged/black-holed server freezes an MCP tool call for minutes
948
+ // (real incident: an agent's session stuck 27 minutes on a single drafted-mcp
949
+ // call). Cap every request; generous default so large uploads aren't cut.
950
+ const FETCH_TIMEOUT_MS = 120_000;
951
+
952
+ async function serverFetch(url, opts = {}) {
953
+ const { timeout = FETCH_TIMEOUT_MS, ...rest } = opts;
954
+ try {
955
+ return await fetch(url, { ...rest, signal: AbortSignal.timeout(timeout) });
956
+ } catch (e) {
957
+ if (e?.name === 'TimeoutError' || e?.cause?.name === 'TimeoutError') {
958
+ throw new Error(`Request to ${url} timed out after ${timeout}ms`);
959
+ }
960
+ throw enrichFetchError(e, url);
961
+ }
949
962
  }
950
963
 
951
964
  // The org this session is actually working in: an explicit switch, else the org of the
@@ -3149,7 +3162,36 @@ export const mcpServer = createMcpServer();
3149
3162
 
3150
3163
  const args = process.argv.slice(2);
3151
3164
 
3165
+ const USAGE = `Drafted MCP Server v${PACKAGE_VERSION}
3166
+
3167
+ Stdio MCP server exposing Drafted surface tools (fs, whoami, session, ...) to AI agents.
3168
+ Normally launched with NO arguments by an MCP client (Claude Desktop, Cursor, ...).
3169
+
3170
+ Usage:
3171
+ drafted-mcp Run the stdio MCP server (default)
3172
+ drafted-mcp --http Run a standalone HTTP MCP server on MCP_HTTP_PORT (default 3100)
3173
+ drafted-mcp --version Print the installed version
3174
+ drafted-mcp --help Show this help
3175
+ `;
3176
+
3152
3177
  async function main() {
3178
+ if (args.includes('--help') || args.includes('-h')) {
3179
+ console.log(USAGE);
3180
+ process.exit(0);
3181
+ }
3182
+ if (args.includes('--version') || args.includes('-v')) {
3183
+ console.log(PACKAGE_VERSION);
3184
+ process.exit(0);
3185
+ }
3186
+ // Fail fast on unknown flags instead of silently starting the stdio server and
3187
+ // blocking on stdin forever (a human running `drafted-mcp --help` used to hang
3188
+ // indefinitely — the process never exited). MCP clients launch with no args.
3189
+ const unknown = args.filter((a) => a !== '--http');
3190
+ if (unknown.length > 0) {
3191
+ console.error(`drafted-mcp: unknown option${unknown.length > 1 ? 's' : ''}: ${unknown.join(' ')}`);
3192
+ console.error(USAGE);
3193
+ process.exit(2);
3194
+ }
3153
3195
  if (args.includes('--http')) {
3154
3196
  const { createServer } = await import('node:http');
3155
3197
  const { StreamableHTTPServerTransport } = await import('@modelcontextprotocol/sdk/server/streamableHttp.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.17.4",
3
+ "version": "1.17.6",
4
4
  "description": "Drafted — visual thinking surface for humans and AI agents. Renders HTML, markdown, images, and code as frames on a zoomable canvas, with MCP tools for AI agents and real-time sync for humans.",
5
5
  "type": "module",
6
6
  "files": [
@@ -72,6 +72,7 @@
72
72
  "react-dom": "^18.3.1",
73
73
  "sharp": "^0.34.5",
74
74
  "ws": "^8.16.0",
75
+ "yaml": "^2.8.3",
75
76
  "zod": "^4.3.6"
76
77
  },
77
78
  "keywords": [
@@ -95,7 +96,6 @@
95
96
  "drizzle-kit": "^0.31.9",
96
97
  "tsx": "^4.19.0",
97
98
  "typescript": "^5.9.3",
98
- "vitest": "^3.2.4",
99
- "yaml": "^2.8.3"
99
+ "vitest": "^3.2.4"
100
100
  }
101
101
  }