@mylasertools/kerfscript-mcp 0.0.0-stage → 0.1.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/OFL.txt ADDED
@@ -0,0 +1,92 @@
1
+ Copyright 2020 Braille Institute of America, Inc.
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+ -----------------------------------------------------------
8
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9
+ -----------------------------------------------------------
10
+
11
+ PREAMBLE
12
+ The goals of the Open Font License (OFL) are to stimulate worldwide
13
+ development of collaborative font projects, to support the font creation
14
+ efforts of academic and linguistic communities, and to provide a free and
15
+ open framework in which fonts may be shared and improved in partnership
16
+ with others.
17
+
18
+ The OFL allows the licensed fonts to be used, studied, modified and
19
+ redistributed freely as long as they are not sold by themselves. The
20
+ fonts, including any derivative works, can be bundled, embedded,
21
+ redistributed and/or sold with any software provided that any reserved
22
+ names are not used by derivative works. The fonts and derivatives,
23
+ however, cannot be released under any other type of license. The
24
+ requirement for fonts to remain under this license does not apply
25
+ to any document created using the fonts or their derivatives.
26
+
27
+ DEFINITIONS
28
+ "Font Software" refers to the set of files released by the Copyright
29
+ Holder(s) under this license and clearly marked as such. This may
30
+ include source files, build scripts and documentation.
31
+
32
+ "Reserved Font Name" refers to any names specified as such after the
33
+ copyright statement(s).
34
+
35
+ "Original Version" refers to the collection of Font Software components as
36
+ distributed by the Copyright Holder(s).
37
+
38
+ "Modified Version" refers to any derivative made by adding to, deleting,
39
+ or substituting -- in part or in whole -- any of the components of the
40
+ Original Version, by changing formats or by porting the Font Software to a
41
+ new environment.
42
+
43
+ "Author" refers to any designer, engineer, programmer, technical
44
+ writer or other person who contributed to the Font Software.
45
+
46
+ PERMISSION & CONDITIONS
47
+ Permission is hereby granted, free of charge, to any person obtaining
48
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
49
+ redistribute, and sell modified and unmodified copies of the Font
50
+ Software, subject to the following conditions:
51
+
52
+ 1) Neither the Font Software nor any of its individual components,
53
+ in Original or Modified Versions, may be sold by itself.
54
+
55
+ 2) Original or Modified Versions of the Font Software may be bundled,
56
+ redistributed and/or sold with any software, provided that each copy
57
+ contains the above copyright notice and this license. These can be
58
+ included either as stand-alone text files, human-readable headers or
59
+ in the appropriate machine-readable metadata fields within text or
60
+ binary files as long as those fields can be easily viewed by the user.
61
+
62
+ 3) No Modified Version of the Font Software may use the Reserved Font
63
+ Name(s) unless explicit written permission is granted by the corresponding
64
+ Copyright Holder. This restriction only applies to the primary font name as
65
+ presented to the users.
66
+
67
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68
+ Software shall not be used to promote, endorse or advertise any
69
+ Modified Version, except to acknowledge the contribution(s) of the
70
+ Copyright Holder(s) and the Author(s) or with their explicit written
71
+ permission.
72
+
73
+ 5) The Font Software, modified or unmodified, in part or in whole,
74
+ must be distributed entirely under this license, and must not be
75
+ distributed under any other license. The requirement for fonts to
76
+ remain under this license does not apply to any document created
77
+ using the Font Software.
78
+
79
+ TERMINATION
80
+ This license becomes null and void if any of the above conditions are
81
+ not met.
82
+
83
+ DISCLAIMER
84
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92
+ OTHER DEALINGS IN THE FONT SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,97 @@
1
- # Temporary Holding Version
1
+ # KerfScript MCP
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An MCP server that lets AI assistants write and check
4
+ [KerfScript](https://kerfscript.mylasertools.com) laser-cutting designs. The
5
+ assistant can read the KerfScript docs and examples, find a design's settings
6
+ and render it to SVG or DXF, so it can test its code before giving it to you.
7
+
8
+ ## Connect
9
+
10
+ The hosted server needs no account or key:
11
+
12
+ ```text
13
+ https://mcp.mylasertools.com/mcp
14
+ ```
15
+
16
+ **Claude Code**
17
+
18
+ ```sh
19
+ claude mcp add --transport http kerfscript https://mcp.mylasertools.com/mcp
20
+ ```
21
+
22
+ **Claude** (desktop and web): Settings → Connectors → Add custom connector, and
23
+ enter the address above.
24
+
25
+ **Cursor**: add it to `.cursor/mcp.json`:
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "kerfscript": { "url": "https://mcp.mylasertools.com/mcp" }
31
+ }
32
+ }
33
+ ```
34
+
35
+ **VS Code**: add it to `.vscode/mcp.json`:
36
+
37
+ ```json
38
+ {
39
+ "servers": {
40
+ "kerfscript": { "type": "http", "url": "https://mcp.mylasertools.com/mcp" }
41
+ }
42
+ }
43
+ ```
44
+
45
+ ## Run it locally
46
+
47
+ With Node.js 20 or newer, the same server runs on your computer and designs
48
+ never leave it:
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "kerfscript": { "command": "npx", "args": ["-y", "@mylasertools/kerfscript-mcp"] }
54
+ }
55
+ }
56
+ ```
57
+
58
+ In Claude Code:
59
+
60
+ ```sh
61
+ claude mcp add kerfscript -- npx -y @mylasertools/kerfscript-mcp
62
+ ```
63
+
64
+ ## Tools
65
+
66
+ | Tool | What it does |
67
+ | ----------------------- | ------------------------------------------------------------------------------ |
68
+ | `kerfscript_docs` | Reads the guides and the language reference |
69
+ | `kerfscript_examples` | Finds examples by title or tag and returns their source |
70
+ | `kerfscript_parameters` | Lists a design's settings with their ranges and choices |
71
+ | `kerfscript_render` | Renders a design to SVG or DXF, with its parts, sizes, layers and any warnings |
72
+
73
+ Sizes are in millimetres. Text uses the bundled Atkinson Hyperlegible font.
74
+
75
+ ## Limits
76
+
77
+ A design may be up to 64,000 characters, with up to 20 libraries of its own
78
+ passed alongside it. It cannot read files or fetch anything from the network.
79
+ Each render stops at 100,000 steps, 100 parts and 10 sheets. For bigger designs
80
+ or other fonts, use the [KerfScript package](https://www.npmjs.com/package/@mylasertools/kerfscript)
81
+ or its command line.
82
+
83
+ The hosted server allows each client about 60 requests a minute and 1,000 a
84
+ day. It does not store or log the designs you send.
85
+
86
+ A render that succeeds does not mean the parts fit. Cut a test piece in your
87
+ material before cutting a new design.
88
+
89
+ ## More
90
+
91
+ - [AI assistants guide](https://kerfscript.mylasertools.com/docs/mcp/)
92
+ - [KerfScript documentation](https://kerfscript.mylasertools.com/docs/)
93
+ - [Issues](https://github.com/mylasertools/kerfscript/issues)
94
+
95
+ Licensed under the [GNU AGPL 3.0](https://github.com/mylasertools/kerfscript/blob/main/LICENSE),
96
+ or the free [commercial licence](https://github.com/mylasertools/kerfscript/blob/main/COMMERCIAL-LICENSE.md#free-commercial-licence)
97
+ for closed-source use.
@@ -0,0 +1,133 @@
1
+ # Third-party notices
2
+
3
+ KerfScript bundles the following software in `dist/`. Their licences apply to
4
+ those parts only.
5
+
6
+ ## Clipper2 / clipper2-ts 2.0.1-18 (bundled)
7
+
8
+ Original Clipper2: Copyright Angus Johnson 2010–2025.
9
+ TypeScript port by Jeremy Tribby (countertype).
10
+ Source: https://github.com/countertype/clipper2-ts
11
+
12
+ ```text
13
+ Boost Software License - Version 1.0 - August 17th, 2003
14
+
15
+ Permission is hereby granted, free of charge, to any person or organization
16
+ obtaining a copy of the software and accompanying documentation covered by
17
+ this license (the "Software") to use, reproduce, display, distribute,
18
+ execute, and transmit the Software, and to prepare derivative works of the
19
+ Software, and to permit third-parties to whom the Software is furnished to
20
+ do so, all subject to the following:
21
+
22
+ The copyright notices in the Software and this entire statement, including
23
+ the above license grant, this restriction and the following disclaimer,
24
+ must be included in all copies of the Software, in whole or in part, and
25
+ all derivative works of the Software, unless such copies or derivative
26
+ works are solely in the form of machine-executable object code generated by
27
+ a source language processor.
28
+
29
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
+ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
+ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
+ DEALINGS IN THE SOFTWARE.
36
+ ```
37
+
38
+ ## opentype.js 1.3.4 (bundled)
39
+
40
+ Source: https://github.com/opentypejs/opentype.js
41
+
42
+ ```text
43
+ The MIT License (MIT)
44
+
45
+ Copyright (c) 2020 Frederik De Bleser
46
+
47
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
48
+ this software and associated documentation files (the "Software"), to deal in
49
+ the Software without restriction, including without limitation the rights to
50
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
51
+ the Software, and to permit persons to whom the Software is furnished to do so,
52
+ subject to the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be included in all
55
+ copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
59
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
60
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
61
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
62
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63
+ ```
64
+
65
+ ## tiny-inflate 1.0.3 (bundled, part of opentype.js)
66
+
67
+ Source: https://github.com/foliojs/tiny-inflate
68
+
69
+ ```text
70
+ MIT License
71
+
72
+ Copyright (c) 2015-present Devon Govett
73
+
74
+ Permission is hereby granted, free of charge, to any person obtaining a copy
75
+ of this software and associated documentation files (the "Software"), to deal
76
+ in the Software without restriction, including without limitation the rights
77
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
78
+ copies of the Software, and to permit persons to whom the Software is
79
+ furnished to do so, subject to the following conditions:
80
+
81
+ The above copyright notice and this permission notice shall be included in all
82
+ copies or substantial portions of the Software.
83
+
84
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
90
+ SOFTWARE.
91
+ ```
92
+
93
+ ## string.prototype.codepointat 0.2.1 (bundled, part of opentype.js)
94
+
95
+ Source: https://github.com/mathiasbynens/String.prototype.codePointAt
96
+
97
+ ```text
98
+ Copyright Mathias Bynens <https://mathiasbynens.be/>
99
+
100
+ Permission is hereby granted, free of charge, to any person obtaining
101
+ a copy of this software and associated documentation files (the
102
+ "Software"), to deal in the Software without restriction, including
103
+ without limitation the rights to use, copy, modify, merge, publish,
104
+ distribute, sublicense, and/or sell copies of the Software, and to
105
+ permit persons to whom the Software is furnished to do so, subject to
106
+ the following conditions:
107
+
108
+ The above copyright notice and this permission notice shall be
109
+ included in all copies or substantial portions of the Software.
110
+
111
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
112
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
114
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
115
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
116
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
117
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
118
+ ```
119
+
120
+ ## Desktop app
121
+
122
+ The desktop app is also built from Rust crates (Tauri and its dependencies)
123
+ under MIT, Apache-2.0, MPL-2.0, BSD, ISC, Zlib, Unicode and similar licences.
124
+ `desktop/THIRD-PARTY-LICENSES.md` lists each one with its licence text, and
125
+ the installers place it next to the app.
126
+
127
+ ## Atkinson Hyperlegible (built into the command line and kerfscript.wasm)
128
+
129
+ `fonts/AtkinsonHyperlegible-Regular.ttf`, Copyright 2020 Braille Institute
130
+ of America, Inc., licensed under the SIL Open Font License 1.1. See
131
+ `fonts/OFL.txt`. It is embedded unmodified in `dist/cli.js` and
132
+ `kerfscript.wasm`, and the playground serves it; `dist/index.js` does not
133
+ include it.
package/dist/budget.js ADDED
@@ -0,0 +1,9 @@
1
+ import {
2
+ secondsToMidnight,
3
+ spend
4
+ } from "./chunk-O5LBJLFO.js";
5
+ import "./chunk-IY7POWTF.js";
6
+ export {
7
+ secondsToMidnight,
8
+ spend
9
+ };
@@ -0,0 +1,131 @@
1
+ import {
2
+ secondsToMidnight
3
+ } from "./chunk-O5LBJLFO.js";
4
+ import {
5
+ createKerfScriptServer,
6
+ version
7
+ } from "./chunk-JUDNQ5QA.js";
8
+ import {
9
+ execute
10
+ } from "./chunk-6NSCAH6P.js";
11
+
12
+ // src/worker.ts
13
+ import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
14
+ import { readRequestBody } from "@modelcontextprotocol/sdk/server/requestBody.js";
15
+ var MAX_BODY = 256e3;
16
+ var jsonRpcError = (status, code, message, headers) => {
17
+ headers.set("Content-Type", "application/json");
18
+ return new Response(JSON.stringify({ jsonrpc: "2.0", error: { code, message }, id: null }), {
19
+ status,
20
+ headers
21
+ });
22
+ };
23
+ function clientAddress(ip) {
24
+ if (!ip.includes(":")) return ip;
25
+ const ipv4 = ip.match(/:(\d+\.\d+\.\d+\.\d+)$/);
26
+ if (ipv4) return ipv4[1];
27
+ const [head = "", tail] = ip.toLowerCase().split("::");
28
+ const groups = (s = "") => s ? s.split(":") : [];
29
+ const front = groups(head);
30
+ const full = tail === void 0 ? front : [...front, ...Array(8 - front.length - groups(tail).length).fill("0"), ...groups(tail)];
31
+ return `${full.slice(0, 4).map((g) => parseInt(g, 16).toString(16)).join(":")}::/64`;
32
+ }
33
+ async function charge(env, pool, client) {
34
+ try {
35
+ return await env.DAILY_BUDGET.get(env.DAILY_BUDGET.idFromName(pool)).spend(pool, client);
36
+ } catch {
37
+ return "total";
38
+ }
39
+ }
40
+ async function handleRequest(request, env, caller) {
41
+ const url = new URL(request.url);
42
+ if (url.pathname === "/health") return Response.json({ name: "kerfscript-mcp", version });
43
+ if (url.pathname !== "/mcp") return new Response("Not found", { status: 404 });
44
+ const origin = request.headers.get("Origin");
45
+ const allowed = env.ALLOWED_ORIGINS.split(",").map((s) => s.trim());
46
+ if (origin && !allowed.includes(origin))
47
+ return new Response("Origin not allowed", { status: 403 });
48
+ const headers = new Headers({
49
+ "Cache-Control": "no-store",
50
+ "X-Content-Type-Options": "nosniff",
51
+ Vary: "Origin"
52
+ });
53
+ if (origin) headers.set("Access-Control-Allow-Origin", origin);
54
+ if (request.method === "OPTIONS") {
55
+ headers.set("Access-Control-Allow-Methods", "POST, OPTIONS");
56
+ headers.set(
57
+ "Access-Control-Allow-Headers",
58
+ "Content-Type, Accept, MCP-Protocol-Version, MCP-Session-Id"
59
+ );
60
+ return new Response(null, { status: 204, headers });
61
+ }
62
+ if (request.method !== "POST") {
63
+ headers.set("Allow", "POST, OPTIONS");
64
+ return new Response("This stateless endpoint accepts POST requests.", {
65
+ status: 405,
66
+ headers
67
+ });
68
+ }
69
+ const ip = request.headers.get("CF-Connecting-IP");
70
+ if (caller !== void 0 && (!caller.trim() || caller.length > 200))
71
+ return new Response("A stable caller identity is required.", { status: 400 });
72
+ if (caller === void 0 && !ip)
73
+ return new Response("Missing client IP. Service bindings must use fetchForCaller.", {
74
+ status: 400
75
+ });
76
+ const key = caller !== void 0 ? `caller:${caller}` : `ip:${clientAddress(ip)}`;
77
+ if (!(await env.REQUEST_LIMIT.limit({ key })).success) {
78
+ headers.set("Retry-After", "60");
79
+ return new Response("Rate limit exceeded. Retry in one minute.", { status: 429, headers });
80
+ }
81
+ const body = await readRequestBody(request, MAX_BODY);
82
+ if (body.tooLarge)
83
+ return jsonRpcError(413, -32e3, `Request body must not exceed ${MAX_BODY} bytes.`, headers);
84
+ let message;
85
+ try {
86
+ message = JSON.parse(body.text);
87
+ } catch {
88
+ return jsonRpcError(400, -32700, "Parse error: Invalid JSON", headers);
89
+ }
90
+ if (Array.isArray(message))
91
+ return jsonRpcError(
92
+ 400,
93
+ -32600,
94
+ "Batches are not supported. Send one message per request.",
95
+ headers
96
+ );
97
+ const spent = await charge(env, caller !== void 0 ? "service" : "public", key);
98
+ if (spent !== "ok") {
99
+ headers.set("Retry-After", String(secondsToMidnight()));
100
+ return spent === "client" ? new Response("Daily limit for this client reached. Retry after midnight UTC.", {
101
+ status: 429,
102
+ headers
103
+ }) : new Response("The service has reached its daily limit. Retry after midnight UTC.", {
104
+ status: 503,
105
+ headers
106
+ });
107
+ }
108
+ const server = createKerfScriptServer(async (job) => execute(job));
109
+ const transport = new WebStandardStreamableHTTPServerTransport({
110
+ sessionIdGenerator: void 0,
111
+ enableJsonResponse: true,
112
+ maxRequestBodySize: MAX_BODY
113
+ });
114
+ try {
115
+ await server.connect(transport);
116
+ const response = await transport.handleRequest(request, { parsedBody: message });
117
+ for (const [key2, value] of headers) response.headers.set(key2, value);
118
+ return response;
119
+ } finally {
120
+ await server.close();
121
+ }
122
+ }
123
+ var worker_default = {
124
+ fetch: (request, env) => handleRequest(request, env)
125
+ };
126
+
127
+ export {
128
+ clientAddress,
129
+ handleRequest,
130
+ worker_default
131
+ };