@workel/mcp 0.3.0 → 0.4.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.
Files changed (62) hide show
  1. package/README.md +85 -16
  2. package/dist/api/client.d.ts +19 -0
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +41 -6
  5. package/dist/api/client.js.map +1 -1
  6. package/dist/api/mapping.d.ts +13 -1
  7. package/dist/api/mapping.d.ts.map +1 -1
  8. package/dist/api/mapping.js +72 -0
  9. package/dist/api/mapping.js.map +1 -1
  10. package/dist/api/types.d.ts +106 -0
  11. package/dist/api/types.d.ts.map +1 -1
  12. package/dist/server.d.ts +2 -2
  13. package/dist/server.d.ts.map +1 -1
  14. package/dist/server.js +14 -4
  15. package/dist/server.js.map +1 -1
  16. package/dist/tools/createComment.js +1 -1
  17. package/dist/tools/createComment.js.map +1 -1
  18. package/dist/tools/createEvent.js +1 -1
  19. package/dist/tools/createEvent.js.map +1 -1
  20. package/dist/tools/createTask.js +1 -1
  21. package/dist/tools/createTask.js.map +1 -1
  22. package/dist/tools/index.d.ts.map +1 -1
  23. package/dist/tools/index.js +4 -0
  24. package/dist/tools/index.js.map +1 -1
  25. package/dist/tools/logTime.d.ts +28 -0
  26. package/dist/tools/logTime.d.ts.map +1 -0
  27. package/dist/tools/logTime.js +83 -0
  28. package/dist/tools/logTime.js.map +1 -0
  29. package/dist/tools/registration.d.ts +5 -2
  30. package/dist/tools/registration.d.ts.map +1 -1
  31. package/dist/tools/registration.js +9 -2
  32. package/dist/tools/registration.js.map +1 -1
  33. package/dist/tools/updateTask.d.ts +20 -6
  34. package/dist/tools/updateTask.d.ts.map +1 -1
  35. package/dist/tools/updateTask.js +37 -11
  36. package/dist/tools/updateTask.js.map +1 -1
  37. package/dist/tools/uploadAttachment.d.ts +49 -0
  38. package/dist/tools/uploadAttachment.d.ts.map +1 -0
  39. package/dist/tools/uploadAttachment.js +133 -0
  40. package/dist/tools/uploadAttachment.js.map +1 -0
  41. package/dist/tools/workel_projects.js +1 -1
  42. package/dist/tools/workel_projects.js.map +1 -1
  43. package/dist/tools/workel_task_activity.d.ts +27 -0
  44. package/dist/tools/workel_task_activity.d.ts.map +1 -0
  45. package/dist/tools/workel_task_activity.js +67 -0
  46. package/dist/tools/workel_task_activity.js.map +1 -0
  47. package/dist/tools/workel_tasks.d.ts.map +1 -1
  48. package/dist/tools/workel_tasks.js +10 -4
  49. package/dist/tools/workel_tasks.js.map +1 -1
  50. package/dist/tools/workel_time_entries.d.ts +25 -0
  51. package/dist/tools/workel_time_entries.d.ts.map +1 -0
  52. package/dist/tools/workel_time_entries.js +74 -0
  53. package/dist/tools/workel_time_entries.js.map +1 -0
  54. package/dist/version.d.ts +16 -0
  55. package/dist/version.d.ts.map +1 -1
  56. package/dist/version.js +17 -1
  57. package/dist/version.js.map +1 -1
  58. package/dist/worker.d.ts +41 -0
  59. package/dist/worker.d.ts.map +1 -0
  60. package/dist/worker.js +113 -0
  61. package/dist/worker.js.map +1 -0
  62. package/package.json +10 -4
package/dist/version.js CHANGED
@@ -24,5 +24,21 @@ function readPackageVersion() {
24
24
  }
25
25
  throw new Error('Unable to resolve package.json to determine the server version.');
26
26
  }
27
- exports.VERSION = readPackageVersion();
27
+ /**
28
+ * Node reads package.json from disk; Workers cannot — it has no filesystem and
29
+ * no `__dirname`, so the read below throws at MODULE LOAD and the whole Worker
30
+ * fails to boot, not just the version lookup.
31
+ *
32
+ * The bundle-time constant is therefore checked first. This is not a fallback
33
+ * for a failed read: on Workers the read must never be attempted at all.
34
+ *
35
+ * The obvious alternative — `import pkg from '../package.json'` — was rejected
36
+ * because package.json sits outside `rootDir`, so enabling resolveJsonModule
37
+ * drags it into the emitted dist tree and changes the published layout.
38
+ *
39
+ * Drift between the injected value and package.json is prevented by a test
40
+ * (see server.redaction.test.ts), matching how RELEASING.md already pins the
41
+ * version across package.json / manifest.json / server.json.
42
+ */
43
+ exports.VERSION = typeof WORKEL_MCP_VERSION !== 'undefined' ? WORKEL_MCP_VERSION : readPackageVersion();
28
44
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,+BAA4B;AAE5B;;;;GAIG;AACH,SAAS,kBAAkB;IACzB,MAAM,UAAU,GAAG,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAE/F,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAA,iBAAY,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;YACpD,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACpC,OAAO,GAAG,CAAC,OAAO,CAAC;YACrB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;QAC3B,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;AACrF,CAAC;AAEY,QAAA,OAAO,GAAW,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,+BAA4B;AAE5B;;;;GAIG;AACH,SAAS,kBAAkB;IACzB,MAAM,UAAU,GAAG,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAE/F,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAA,iBAAY,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;YACpD,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACpC,OAAO,GAAG,CAAC,OAAO,CAAC;YACrB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;QAC3B,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;AACrF,CAAC;AASD;;;;;;;;;;;;;;;GAeG;AACU,QAAA,OAAO,GAClB,OAAO,kBAAkB,KAAK,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The Cloudflare Workers entry — a third transport shell around the SAME
3
+ * `createRemoteHandler` the Node server uses (`./remote.ts`). This module
4
+ * adapts Fetch's `Request`/`Response` to the small Node-shaped request/response
5
+ * interfaces that handler expects, and does nothing else: no auth decisions, no
6
+ * routing, no tool logic. Everything security-relevant stays in one place.
7
+ *
8
+ * Why Workers rather than a container: the frontend already deploys here, so
9
+ * `mcp.workel.com` is a DNS record and a route on infrastructure that exists,
10
+ * instead of a new App Service, a container registry push, and a Terraform
11
+ * apply. The handler is transport-agnostic by design, which is what makes this
12
+ * a ~100-line adapter rather than a port.
13
+ *
14
+ * Config comes from `env` bindings, never `process.env` — Workers has no
15
+ * process. The names match the container's variables exactly so one runbook
16
+ * covers both.
17
+ *
18
+ * One honest difference from the Node deployment: `remote.ts`'s front throttle
19
+ * is a module-level Map, which on Workers is per-ISOLATE rather than
20
+ * per-process. Isolates are many and short-lived, so that ceiling is softer
21
+ * here. It is defense-in-depth either way — the authoritative per-key and
22
+ * per-workspace limits live on the Public API and are reported live by
23
+ * `/me`, so no amount of edge concurrency bypasses them. If this front
24
+ * throttle ever needs to be authoritative, that is a Durable Object or the
25
+ * Workers Rate Limiting API, not a bigger Map.
26
+ */
27
+ export interface WorkerEnv {
28
+ /** Public API v1 base URL. The PUBLIC surface only — never internal, never the database. */
29
+ WORKEL_API_BASE_URL?: string;
30
+ /** Presence switches on OAuth mode; see RemoteHandlerDeps.protectedResourceMetadataUrl. */
31
+ WORKEL_OAUTH_RESOURCE_METADATA_URL?: string;
32
+ /** Comma-separated. Empty means: refuse any PRESENT Origin, still allow an absent one. */
33
+ WORKEL_ALLOWED_ORIGINS?: string;
34
+ /** "true" enables the write tools. Read-only by default, matching the stdio server. */
35
+ WORKEL_ENABLE_WRITES?: string;
36
+ }
37
+ declare const _default: {
38
+ fetch(request: Request, env: WorkerEnv): Promise<Response>;
39
+ };
40
+ export default _default;
41
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,MAAM,WAAW,SAAS;IACxB,4FAA4F;IAC5F,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,2FAA2F;IAC3F,kCAAkC,CAAC,EAAE,MAAM,CAAC;IAC5C,0FAA0F;IAC1F,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uFAAuF;IACvF,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;;mBA0DsB,OAAO,OAAO,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;;AADlE,wBAqCE"}
package/dist/worker.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /**
3
+ * The Cloudflare Workers entry — a third transport shell around the SAME
4
+ * `createRemoteHandler` the Node server uses (`./remote.ts`). This module
5
+ * adapts Fetch's `Request`/`Response` to the small Node-shaped request/response
6
+ * interfaces that handler expects, and does nothing else: no auth decisions, no
7
+ * routing, no tool logic. Everything security-relevant stays in one place.
8
+ *
9
+ * Why Workers rather than a container: the frontend already deploys here, so
10
+ * `mcp.workel.com` is a DNS record and a route on infrastructure that exists,
11
+ * instead of a new App Service, a container registry push, and a Terraform
12
+ * apply. The handler is transport-agnostic by design, which is what makes this
13
+ * a ~100-line adapter rather than a port.
14
+ *
15
+ * Config comes from `env` bindings, never `process.env` — Workers has no
16
+ * process. The names match the container's variables exactly so one runbook
17
+ * covers both.
18
+ *
19
+ * One honest difference from the Node deployment: `remote.ts`'s front throttle
20
+ * is a module-level Map, which on Workers is per-ISOLATE rather than
21
+ * per-process. Isolates are many and short-lived, so that ceiling is softer
22
+ * here. It is defense-in-depth either way — the authoritative per-key and
23
+ * per-workspace limits live on the Public API and are reported live by
24
+ * `/me`, so no amount of edge concurrency bypasses them. If this front
25
+ * throttle ever needs to be authoritative, that is a Durable Object or the
26
+ * Workers Rate Limiting API, not a bigger Map.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const remote_1 = require("./remote");
30
+ /**
31
+ * Adapt a Fetch `Request` to the handler's request shape.
32
+ *
33
+ * The body is read once, up front, and yielded as a single chunk. The handler's
34
+ * own `MAX_REQUEST_BODY_BYTES` guard still applies — it checks a running total
35
+ * while iterating, so one large chunk trips it exactly as many small ones
36
+ * would.
37
+ */
38
+ function toRemoteRequest(request, body) {
39
+ const headers = {};
40
+ request.headers.forEach((value, key) => {
41
+ headers[key.toLowerCase()] = value;
42
+ });
43
+ return {
44
+ method: request.method,
45
+ headers,
46
+ url: new URL(request.url).pathname,
47
+ async *[Symbol.asyncIterator]() {
48
+ if (body.byteLength > 0) {
49
+ yield Buffer.from(body);
50
+ }
51
+ },
52
+ };
53
+ }
54
+ /**
55
+ * Collect what the handler writes into a real `Response`.
56
+ *
57
+ * The handler calls writeHead/end exactly once per request (it guards on a
58
+ * `responded` flag), so a promise resolved by `end` is a faithful translation
59
+ * rather than a race.
60
+ */
61
+ function createCollector() {
62
+ let resolve;
63
+ const response = new Promise((r) => {
64
+ resolve = r;
65
+ });
66
+ let status = 500;
67
+ let headers = {};
68
+ const res = {
69
+ writeHead(s, h) {
70
+ status = s;
71
+ headers = h ?? {};
72
+ },
73
+ end(chunk) {
74
+ resolve(new Response(chunk ?? null, { status, headers }));
75
+ },
76
+ };
77
+ return { res, response };
78
+ }
79
+ exports.default = {
80
+ async fetch(request, env) {
81
+ const handler = (0, remote_1.createRemoteHandler)({
82
+ // FetchLike is `typeof fetch`, so the runtime's own global satisfies it
83
+ // directly — no wrapper, and nothing here can accidentally alter a
84
+ // request on its way upstream.
85
+ fetch,
86
+ logger: {
87
+ // console in Workers goes to the observability log stream. Kept to the
88
+ // same three levels the Node logger uses so log shape does not depend
89
+ // on where the server happens to run.
90
+ info: (message, meta) => console.log(message, meta ?? {}),
91
+ warn: (message, meta) => console.warn(message, meta ?? {}),
92
+ error: (message, meta) => console.error(message, meta ?? {}),
93
+ },
94
+ now: () => Date.now(),
95
+ baseUrl: env.WORKEL_API_BASE_URL ?? 'https://api.workel.com/api/public/v1',
96
+ writesEnabled: env.WORKEL_ENABLE_WRITES === 'true',
97
+ protectedResourceMetadataUrl: env.WORKEL_OAUTH_RESOURCE_METADATA_URL,
98
+ allowedOrigins: (env.WORKEL_ALLOWED_ORIGINS ?? '')
99
+ .split(',')
100
+ .map((o) => o.trim())
101
+ .filter(Boolean),
102
+ });
103
+ // Read the body before handing over: Workers gives a stream, the handler
104
+ // wants async-iterable chunks, and a GET/HEAD has no body to read at all.
105
+ const raw = request.method === 'GET' || request.method === 'HEAD'
106
+ ? new Uint8Array(0)
107
+ : new Uint8Array(await request.arrayBuffer());
108
+ const { res, response } = createCollector();
109
+ await handler(toRemoteRequest(request, raw), res);
110
+ return response;
111
+ },
112
+ };
113
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;AAEH,qCAAwF;AAaxF;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,OAAgB,EAAE,IAAgB;IACzD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QAAQ,EAAE,GAAG,eAAe,EAAE,CAAC;QAC5C,MAAM,OAAO,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;QAElD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@workel/mcp",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "description": "Official Model Context Protocol server for Workel — a thin client of the Workel Public API v1",
7
+ "description": "Official Model Context Protocol server for Workel \u2014 a thin client of the Workel Public API v1",
8
8
  "main": "dist/index.js",
9
9
  "bin": {
10
10
  "workel-mcp": "dist/index.js"
11
11
  },
12
12
  "files": [
13
13
  "dist",
14
+ "!dist/remote.*",
14
15
  "LICENSE"
15
16
  ],
16
17
  "engines": {
@@ -33,7 +34,11 @@
33
34
  ],
34
35
  "author": "Workel",
35
36
  "license": "MIT",
36
- "homepage": "https://developer.workel.com",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/WorkelCEO/workel-mcp.git"
40
+ },
41
+ "homepage": "https://developer.workel.com/#mcp",
37
42
  "bugs": {
38
43
  "url": "https://developer.workel.com"
39
44
  },
@@ -46,6 +51,7 @@
46
51
  "@types/node": "^20.10.6",
47
52
  "jest": "^29.7.0",
48
53
  "ts-jest": "^29.4.9",
49
- "typescript": "^5.3.3"
54
+ "typescript": "^5.3.3",
55
+ "wrangler": "^4.126.0"
50
56
  }
51
57
  }