@reneturcios/printcraft 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +83 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +79 -0
- package/dist/cli.js.map +1 -0
- package/dist/forward.d.ts +87 -0
- package/dist/forward.js +422 -0
- package/dist/forward.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +33 -0
- package/dist/mcp.js +58 -0
- package/dist/mcp.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -6
- package/server.json +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rene Turcios
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# printcraft
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ask a one-person 3D printing studio what it makes, what it charges and where your order is — from inside your tool list. printcraft is a local forwarding client for the hosted DrMaker3D MCP service: it answers `tools/list` locally from the captured tool definitions and forwards every call to the studio's server, returning the answers exactly as the service sends them back.
|
|
4
|
+
|
|
5
|
+
The six tools cover the studio's information core: what the studio offers and how ordering works, the shop catalogue with titles and starting prices, real price examples for reference parts, the materials/colours/options catalogue behind the instant quote, an exact instant-quote price computed from a model file you supply, and order-status tracking by order number and email. Nothing is priced, searched or stored locally — the package is a pipe to the studio's service, not the service itself.
|
|
6
|
+
|
|
7
|
+
This is a labelled subset of the upstream surface: the captured server also offers `create_checkout` (creates a Stripe Checkout link for a purchase) and `request_quote` (sends a person's name, email and project description to the studio for a reply). Both are omitted from this rebuild and are not registered, listed or callable at any level.
|
|
8
|
+
|
|
9
|
+
## The tools
|
|
10
|
+
|
|
11
|
+
- **`about_drmaker3d`** — What the studio offers and how it works: custom printing, design from a photo or sketch, figures, cookie cutters, lake maps, materials, turnaround, shipping and ordering. An optional `topic` narrows the answer to one area.
|
|
12
|
+
- **`search_products`** — Search the shop and its service pages by words. Returns titles, starting prices in U.S. dollars where there is one, and links. An empty query lists the shop.
|
|
13
|
+
- **`print_price_examples`** — Real instant-quote prices for three reference parts in each material, plus the upfront prices for photo figures, cake toppers, name keychains and photo lithophanes. An optional `material` narrows the list.
|
|
14
|
+
- **`print_options`** — The materials, colours, print qualities, infill and copy limits, largest one-piece size and accepted file formats of the instant quote, and how to upload a model file for `quote_custom_print`. No parameters.
|
|
15
|
+
- **`quote_custom_print`** — The exact instant-quote price for printing a 3D model file, from the same engine as the studio's quote page. Pass the attached file or an upload `file_key`; `material` and `color` are required. It computes a price only — it creates no order and charges nothing.
|
|
16
|
+
- **`track_order`** — The stage of an order (received, printing, finishing, shipped, delivered), its ship-by day and arrival window, and tracking when shipped. `order_number` and the `email` the order was placed with are required; only that order is returned.
|
|
17
|
+
|
|
18
|
+
## Install and run
|
|
19
|
+
|
|
20
|
+
As an MCP server via npm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx -y @reneturcios/printcraft mcp
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
MCP client configuration:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"printcraft": {
|
|
32
|
+
"command": "npx",
|
|
33
|
+
"args": ["-y", "@reneturcios/printcraft", "mcp"]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
As a container:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
docker run -i ghcr.io/cloudcorprecords/printcraft
|
|
43
|
+
docker run --rm ghcr.io/cloudcorprecords/printcraft print_options '{}'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## CLI
|
|
47
|
+
|
|
48
|
+
One binary serves both the command line and the MCP server. Each tool is a subcommand taking a single JSON string with that tool's arguments:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
printcraft print_options '{}'
|
|
52
|
+
printcraft search_products '{"query":"ribbed pendant","limit":5}'
|
|
53
|
+
printcraft track_order '{"order_number":"DM1015","email":"you@example.com"}'
|
|
54
|
+
printcraft --version
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Exit codes: `0` when the forwarded call succeeds, `1` when the upstream result is an error, and `2` for usage problems such as an unknown subcommand or a malformed JSON argument.
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
- `DRMAKER3D_MCP_URL` — Overrides the upstream endpoint. The default is the pinned hosted endpoint, `https://drmaker3d.com/mcp`. (The override variable is a reconstruction added by this rebuild.)
|
|
62
|
+
|
|
63
|
+
The upstream registry record declares no headers, so no authentication header is ever sent; the tool surface was captured keyless. The email passed to `track_order` is a lookup key for your own order and is forwarded only as that call's argument; `quote_custom_print`'s optional email is likewise caller-supplied and forwarded verbatim — this package originates nothing.
|
|
64
|
+
|
|
65
|
+
Upstream failures — a JSON-RPC error from the service, a non-2xx response, an unreadable body, or a request that fails outright — are reported to the caller as an error result whose text starts with `printcraft error:`.
|
|
66
|
+
|
|
67
|
+
## How forwarding works
|
|
68
|
+
|
|
69
|
+
The first forwarded call opens a session: an `initialize` request (protocol version `2025-03-26`), followed by a `notifications/initialized` notification, then the `tools/call` itself. If the service answers the initialize request with an `Mcp-Session-Id` header, that value is carried on every later request, and the open session is reused for the rest of the process. Replies are accepted either as plain JSON or as server-sent events. Successful results pass through verbatim, including any `isError` flag and any extra fields the service includes.
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install
|
|
75
|
+
npm run build # tsc -> dist/ (dist/cli.js is the bin)
|
|
76
|
+
npm test # tsx --test test/*.test.ts — stubbed upstream, no network
|
|
77
|
+
npm run dev # run the CLI from source
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The test suite checks the served tool list against the captured surface (all 6 tools, deep-equal, in order, with no `required` key added to the four tools that carry none), asserts that the two omitted tools are absent at registry, MCP and CLI level, exercises the session handshake and its reuse, verifies that no `Authorization` header is ever sent under any environment, and verifies that arguments go upstream untouched and results come back untouched.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT — see `LICENSE`. Copyright (c) 2026 Rene Turcios.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* printcraft CLI.
|
|
4
|
+
*
|
|
5
|
+
* printcraft <tool> '<json-args>'
|
|
6
|
+
* printcraft mcp
|
|
7
|
+
* printcraft --version
|
|
8
|
+
*
|
|
9
|
+
* <tool> is one of the 6 captured forwarded tools. Each
|
|
10
|
+
* tool subcommand takes a single JSON argument string
|
|
11
|
+
* holding that tool's arguments, forwards the call the
|
|
12
|
+
* same way the MCP path does, and prints the forwarded
|
|
13
|
+
* result content. Exit codes: 0 success, 1 on an
|
|
14
|
+
* isError result, 2 usage error.
|
|
15
|
+
*/
|
|
16
|
+
import { callTool, TOOL_NAMES, VERSION } from "./forward.js";
|
|
17
|
+
function usage() {
|
|
18
|
+
console.error(`Usage:
|
|
19
|
+
printcraft <tool> '<json-args>' one of: ${TOOL_NAMES.join(", ")}
|
|
20
|
+
printcraft mcp
|
|
21
|
+
printcraft --version`);
|
|
22
|
+
process.exit(2);
|
|
23
|
+
}
|
|
24
|
+
function firstText(result) {
|
|
25
|
+
const content = result.content;
|
|
26
|
+
if (Array.isArray(content)) {
|
|
27
|
+
for (const item of content) {
|
|
28
|
+
if (item !== null &&
|
|
29
|
+
typeof item === "object" &&
|
|
30
|
+
item.type === "text" &&
|
|
31
|
+
typeof item.text === "string") {
|
|
32
|
+
return item.text;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return typeof content === "string" ? content : JSON.stringify(content);
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
40
|
+
if (cmd === "--version" || cmd === "-v") {
|
|
41
|
+
console.log(VERSION);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (cmd === "mcp") {
|
|
45
|
+
if (rest.length !== 0)
|
|
46
|
+
usage();
|
|
47
|
+
const { startMcpServer } = await import("./mcp.js");
|
|
48
|
+
await startMcpServer();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!TOOL_NAMES.includes(cmd ?? ""))
|
|
52
|
+
usage();
|
|
53
|
+
if (rest.length > 1)
|
|
54
|
+
usage();
|
|
55
|
+
let args = {};
|
|
56
|
+
if (rest.length === 1) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(rest[0]);
|
|
59
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
60
|
+
usage();
|
|
61
|
+
}
|
|
62
|
+
args = parsed;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
console.error("error: argument must be a JSON object string");
|
|
66
|
+
process.exit(2);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const result = await callTool(cmd, args);
|
|
70
|
+
if (result.isError) {
|
|
71
|
+
console.error(`error: ${firstText(result)}`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
console.log(typeof result.content === "string"
|
|
75
|
+
? result.content
|
|
76
|
+
: JSON.stringify(result.content, null, 2));
|
|
77
|
+
}
|
|
78
|
+
void main();
|
|
79
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG7D,SAAS,KAAK;IACZ,OAAO,CAAC,KAAK,CAAC;gDACgC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;uBAE9C,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAAC,MAAkB;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC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,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3E,KAAK,EAAE,CAAC;YACV,CAAC;YACD,IAAI,GAAG,MAAiC,CAAC;QAC3C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,GAAG,CACT,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO;QAChB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* printcraft core: a forwarding client for the hosted
|
|
3
|
+
* DrMaker3D MCP server.
|
|
4
|
+
*
|
|
5
|
+
* No shop data lives on this machine. tools/list is
|
|
6
|
+
* answered from the literal definitions below, which
|
|
7
|
+
* reproduce a live capture of the upstream server word
|
|
8
|
+
* for word (name, title, description and inputSchema
|
|
9
|
+
* exactly as captured; four tools — about_drmaker3d,
|
|
10
|
+
* search_products, print_price_examples, print_options
|
|
11
|
+
* — carry no `required` key, so none is served for
|
|
12
|
+
* them). A tools/call travels upstream over a
|
|
13
|
+
* streamable-HTTP JSON-RPC session: an initialize POST,
|
|
14
|
+
* a notifications/initialized POST, then the tools/call
|
|
15
|
+
* POST, carrying the Mcp-Session-Id response header on
|
|
16
|
+
* later requests when the upstream issues one. The
|
|
17
|
+
* session opens lazily on the first forwarded call and
|
|
18
|
+
* is reused for the client's lifetime.
|
|
19
|
+
*
|
|
20
|
+
* Labelled subset: the capture enumerates 8 tools. Two
|
|
21
|
+
* are omitted from this rebuild and are never
|
|
22
|
+
* registered, listed or callable: `create_checkout`
|
|
23
|
+
* (creates a Stripe Checkout link for a purchase — the
|
|
24
|
+
* checkout-funnel shape) and `request_quote` (sends a
|
|
25
|
+
* person's name, email and project description to the
|
|
26
|
+
* vendor for a reply — the PII lead-routing shape). The
|
|
27
|
+
* six tools below are the studio's information core.
|
|
28
|
+
*
|
|
29
|
+
* The endpoint is pinned to https://drmaker3d.com/mcp
|
|
30
|
+
* and may be replaced with the DRMAKER3D_MCP_URL
|
|
31
|
+
* environment variable (that override is a labelled
|
|
32
|
+
* reconstruction). The registry record declares NO
|
|
33
|
+
* headers on the upstream remote, so no auth header is
|
|
34
|
+
* ever sent, under any environment.
|
|
35
|
+
*
|
|
36
|
+
* A successful upstream result is returned exactly as
|
|
37
|
+
* received, isError flag and extra fields included.
|
|
38
|
+
* Failures — an upstream JSON-RPC error, a non-2xx
|
|
39
|
+
* status, a body that cannot be parsed, or a fetch
|
|
40
|
+
* that throws or times out — become an isError result
|
|
41
|
+
* whose text begins with `printcraft error:` (that
|
|
42
|
+
* rendering is a labelled reconstruction). Replies may
|
|
43
|
+
* be plain JSON or SSE (`data:` lines); the JSON-RPC
|
|
44
|
+
* message whose id matches the request wins.
|
|
45
|
+
*/
|
|
46
|
+
import type { ForwardDeps, ToolArgs, ToolDef, ToolResult } from "./types.js";
|
|
47
|
+
export declare const VERSION = "0.1.0";
|
|
48
|
+
export declare const DEFAULT_ENDPOINT_URL = "https://drmaker3d.com/mcp";
|
|
49
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
50
|
+
export declare const PROTOCOL_VERSION = "2025-03-26";
|
|
51
|
+
export declare const TOOL_DEFS: ToolDef[];
|
|
52
|
+
export declare const TOOL_NAMES: string[];
|
|
53
|
+
/** Whether `name` belongs to the captured built surface. */
|
|
54
|
+
export declare function isKnownTool(name: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Read a JSON-RPC response body, tolerating SSE framing.
|
|
57
|
+
* Returns the message whose id matches `expectedId` when
|
|
58
|
+
* present, otherwise the last parseable message, otherwise
|
|
59
|
+
* null when nothing in the body parses.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseRpcBody(text: string, expectedId?: number): Record<string, unknown> | null;
|
|
62
|
+
/**
|
|
63
|
+
* A forwarding client holding a single upstream session,
|
|
64
|
+
* opened lazily on first use and reused from then on
|
|
65
|
+
* (for the process lifetime in the MCP server, or for a
|
|
66
|
+
* single invocation in the CLI).
|
|
67
|
+
*/
|
|
68
|
+
export declare class PrintcraftClient {
|
|
69
|
+
private readonly deps;
|
|
70
|
+
private sessionId;
|
|
71
|
+
private ready;
|
|
72
|
+
private sessionPromise;
|
|
73
|
+
private idCounter;
|
|
74
|
+
constructor(deps?: ForwardDeps);
|
|
75
|
+
private fetchFn;
|
|
76
|
+
private endpointUrl;
|
|
77
|
+
private timeoutMs;
|
|
78
|
+
private nextId;
|
|
79
|
+
private post;
|
|
80
|
+
private ensureSession;
|
|
81
|
+
/** Forward one tool call; upstream failures come back as isError results. */
|
|
82
|
+
callTool(name: string, args: ToolArgs): Promise<ToolResult>;
|
|
83
|
+
}
|
|
84
|
+
/** Build a forwarding client; tests inject a fake fetch and env through deps. */
|
|
85
|
+
export declare function createClient(deps?: ForwardDeps): PrintcraftClient;
|
|
86
|
+
/** One-shot helper: a fresh client for a single call (the CLI path). */
|
|
87
|
+
export declare function callTool(name: string, args: ToolArgs, deps?: ForwardDeps): Promise<ToolResult>;
|
package/dist/forward.js
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
export const VERSION = "0.1.0";
|
|
2
|
+
export const DEFAULT_ENDPOINT_URL = "https://drmaker3d.com/mcp";
|
|
3
|
+
export const DEFAULT_TIMEOUT_MS = 30000;
|
|
4
|
+
export const PROTOCOL_VERSION = "2025-03-26";
|
|
5
|
+
/* ------------------------------------------------------------------ */
|
|
6
|
+
/* Tool definitions (tools/list literals, verbatim from the live */
|
|
7
|
+
/* capture in harness/fixtures/drmaker3d-tools-original.json; */
|
|
8
|
+
/* generated programmatically by parsing and re-serialising the */
|
|
9
|
+
/* fixture JSON, never retyped) */
|
|
10
|
+
/* ------------------------------------------------------------------ */
|
|
11
|
+
export const TOOL_DEFS = [
|
|
12
|
+
{
|
|
13
|
+
"name": "about_drmaker3d",
|
|
14
|
+
"title": "About DrMaker3D",
|
|
15
|
+
"description": "What DrMaker3D (drmaker3d.com) offers and how it works: a one-person 3D printing and 3D modeling studio in Burlington, Connecticut that ships across the U.S. Custom 3D printing with an instant online quote for STL, OBJ, 3MF and STEP files, design from a photo, sketch or idea, upfront-priced figures made from a photo or AI picture (one or two on a base, pets, wedding cake toppers), printing models from Printables, Thingiverse or MakerWorld links, CookieMaker3D custom cookie cutters, cake toppers, Bakery Manager software in private pilot, gifts with a gift finder, 3D printed lake maps, paying by invoice or tax exempt for schools and businesses, nine materials, made-to-order pendant lights, turnaround, shipping and how to order. Use it to answer questions about the studio: what it makes, from what, how long it takes and how ordering works.",
|
|
16
|
+
"inputSchema": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"topic": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": [
|
|
22
|
+
"all",
|
|
23
|
+
"custom-printing",
|
|
24
|
+
"cookie-cutters",
|
|
25
|
+
"bakery-manager",
|
|
26
|
+
"gifts",
|
|
27
|
+
"lake-maps",
|
|
28
|
+
"materials",
|
|
29
|
+
"pendant-lights",
|
|
30
|
+
"ordering",
|
|
31
|
+
"contact"
|
|
32
|
+
],
|
|
33
|
+
"description": "Which part to return; \"all\" for everything."
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"additionalProperties": false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "search_products",
|
|
41
|
+
"title": "Search DrMaker3D products",
|
|
42
|
+
"description": "Search the DrMaker3D shop (pendant lights, sets, gifts, gift cards and other made-to-order products) and its service pages (a figure from a photo, a pet figure, a wedding cake topper figure, the cake topper and cookie cutter makers, Bakery Manager software in private pilot, lake maps, the gift finder, paying by invoice) by words. Returns titles, starting prices in U.S. dollars where there is one, and links. A custom print from a file has no product: use about_drmaker3d, print_price_examples or request_quote for those.",
|
|
43
|
+
"inputSchema": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {
|
|
46
|
+
"query": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"description": "Words to match, e.g. \"ribbed pendant\" or \"gift card\". Empty lists the shop."
|
|
49
|
+
},
|
|
50
|
+
"limit": {
|
|
51
|
+
"type": "integer",
|
|
52
|
+
"minimum": 1,
|
|
53
|
+
"maximum": 25,
|
|
54
|
+
"description": "Most results to return (default 10)."
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"additionalProperties": false
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "print_price_examples",
|
|
62
|
+
"title": "Custom 3D print price examples",
|
|
63
|
+
"description": "Real prices from the DrMaker3D instant quote for three reference parts (a 2 in clip or knob, a 4 in bracket, a 6 in enclosure) in each material, at Standard quality, 20% infill, one copy, before shipping. Use it to give a person a ballpark; the exact price comes from uploading their file at the instant quote page, or from a quote request. Also lists the upfront prices for a figure made from a person's photo or AI picture (4, 6 or 8 in tall, one color or full color, one figure or two on one base, keychains, sets; free shipping in the contiguous U.S. included; standing figures a range, keychains fixed; full color is up to 6 colors, extra colors cost more), ordered on its own page, and the prices of cake toppers, name keychains and photo lithophanes, each designed on its own page.",
|
|
64
|
+
"inputSchema": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"properties": {
|
|
67
|
+
"material": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"description": "Optional material name, e.g. PLA, PETG, TPU, ABS, ASA, PC, PA-CF, PETG-CF, \"Nylon (PA)\". Omit for all."
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"additionalProperties": false
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "print_options",
|
|
77
|
+
"title": "Custom print options",
|
|
78
|
+
"description": "The materials, colors (in stock or special order), print qualities, infill and copy limits, largest one-piece size and accepted file formats of the DrMaker3D instant quote, and how to upload a model file for quote_custom_print. Call it before quote_custom_print so the material and color named are real ones.",
|
|
79
|
+
"inputSchema": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"properties": {},
|
|
82
|
+
"additionalProperties": false
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "quote_custom_print",
|
|
87
|
+
"title": "Instant price for a 3D model file",
|
|
88
|
+
"description": "The exact DrMaker3D instant-quote price for printing a person's 3D model file, from the same engine and the same measurements as the instant quote page. Pass the file the person attached (as file), or upload it first: POST https://drmaker3d.com/api/upload as multipart/form-data with fields file (STL, OBJ, 3MF, GLB, glTF or PLY, up to 25 MB) and kind=printiq, and pass the \"key\" it returns as file_key. The file is kept privately by the studio for the quote. Returns the price, size, turnaround and a checkout_item to pass to create_checkout. Painted multicolor files, STEP files, parts too big for one piece and model links (Printables, Thingiverse, MakerWorld) are quoted by hand: it says so, and request_quote sends them to Rich.",
|
|
89
|
+
"inputSchema": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"properties": {
|
|
92
|
+
"file_key": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"description": "The key POST /api/upload returned (starts with \"printiq/\"). Give this or file."
|
|
95
|
+
},
|
|
96
|
+
"file": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"description": "The person's model file as ChatGPT passes an attached file (a link on files.oaiusercontent.com or OpenAI’s own file storage). Give this or file_key.",
|
|
99
|
+
"properties": {
|
|
100
|
+
"download_url": {
|
|
101
|
+
"type": "string"
|
|
102
|
+
},
|
|
103
|
+
"file_id": {
|
|
104
|
+
"type": "string"
|
|
105
|
+
},
|
|
106
|
+
"mime_type": {
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
"file_name": {
|
|
110
|
+
"type": "string"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"required": [
|
|
114
|
+
"download_url",
|
|
115
|
+
"file_id"
|
|
116
|
+
],
|
|
117
|
+
"additionalProperties": true
|
|
118
|
+
},
|
|
119
|
+
"material": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"description": "A material from print_options, e.g. PLA, PETG, \"TPU (flexible)\", ABS, ASA, \"Nylon (PA)\", PC, PA-CF, PETG-CF."
|
|
122
|
+
},
|
|
123
|
+
"color": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"description": "A color of that material from print_options, e.g. \"Black\" or \"Matte Charcoal\"."
|
|
126
|
+
},
|
|
127
|
+
"finish": {
|
|
128
|
+
"type": "string",
|
|
129
|
+
"description": "Optional color family, e.g. \"PLA Matte\", when a color name is in two families."
|
|
130
|
+
},
|
|
131
|
+
"quality": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"enum": [
|
|
134
|
+
"draft",
|
|
135
|
+
"fast",
|
|
136
|
+
"standard",
|
|
137
|
+
"high"
|
|
138
|
+
],
|
|
139
|
+
"description": "Default standard. Draft only for parts 100 mm or more across."
|
|
140
|
+
},
|
|
141
|
+
"infill": {
|
|
142
|
+
"type": "integer",
|
|
143
|
+
"minimum": 10,
|
|
144
|
+
"maximum": 100,
|
|
145
|
+
"description": "Percent, default 20. 50 and up for functional parts."
|
|
146
|
+
},
|
|
147
|
+
"copies": {
|
|
148
|
+
"type": "integer",
|
|
149
|
+
"minimum": 1,
|
|
150
|
+
"maximum": 100,
|
|
151
|
+
"description": "How many of the model, default 1."
|
|
152
|
+
},
|
|
153
|
+
"units": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"enum": [
|
|
156
|
+
"mm",
|
|
157
|
+
"inches"
|
|
158
|
+
],
|
|
159
|
+
"description": "Default mm. \"inches\" for an STL or OBJ drawn in inches."
|
|
160
|
+
},
|
|
161
|
+
"email": {
|
|
162
|
+
"type": "string",
|
|
163
|
+
"description": "Optional: the person's email. Needed only when the site asks for one before showing exact prices."
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"required": [
|
|
167
|
+
"material",
|
|
168
|
+
"color"
|
|
169
|
+
],
|
|
170
|
+
"additionalProperties": false
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "track_order",
|
|
175
|
+
"title": "Track a DrMaker3D order",
|
|
176
|
+
"description": "The stage of a DrMaker3D order (received, printing, finishing, shipped, delivered), its ship-by day and arrival window, and tracking when shipped. Needs the order number (like DM1015) and the email the order was placed with; only that order is ever returned.",
|
|
177
|
+
"inputSchema": {
|
|
178
|
+
"type": "object",
|
|
179
|
+
"properties": {
|
|
180
|
+
"order_number": {
|
|
181
|
+
"type": "string",
|
|
182
|
+
"description": "For example DM1015."
|
|
183
|
+
},
|
|
184
|
+
"email": {
|
|
185
|
+
"type": "string",
|
|
186
|
+
"description": "The email used at checkout."
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"required": [
|
|
190
|
+
"order_number",
|
|
191
|
+
"email"
|
|
192
|
+
],
|
|
193
|
+
"additionalProperties": false
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
export const TOOL_NAMES = TOOL_DEFS.map((t) => t.name);
|
|
198
|
+
/** Whether `name` belongs to the captured built surface. */
|
|
199
|
+
export function isKnownTool(name) {
|
|
200
|
+
return TOOL_NAMES.includes(name);
|
|
201
|
+
}
|
|
202
|
+
/* ------------------------------------------------------------------ */
|
|
203
|
+
/* Forwarding client */
|
|
204
|
+
/* ------------------------------------------------------------------ */
|
|
205
|
+
function errorResult(detail) {
|
|
206
|
+
return {
|
|
207
|
+
content: [{ type: "text", text: `printcraft error: ${detail}` }],
|
|
208
|
+
isError: true,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function rpcErrorMessage(error) {
|
|
212
|
+
if (error !== null && typeof error === "object") {
|
|
213
|
+
const message = error.message;
|
|
214
|
+
if (typeof message === "string" && message !== "")
|
|
215
|
+
return message;
|
|
216
|
+
return JSON.stringify(error);
|
|
217
|
+
}
|
|
218
|
+
return String(error);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Read a JSON-RPC response body, tolerating SSE framing.
|
|
222
|
+
* Returns the message whose id matches `expectedId` when
|
|
223
|
+
* present, otherwise the last parseable message, otherwise
|
|
224
|
+
* null when nothing in the body parses.
|
|
225
|
+
*/
|
|
226
|
+
export function parseRpcBody(text, expectedId) {
|
|
227
|
+
const trimmed = text.trim();
|
|
228
|
+
if (trimmed === "")
|
|
229
|
+
return null;
|
|
230
|
+
const candidates = [];
|
|
231
|
+
const tryPush = (payload) => {
|
|
232
|
+
try {
|
|
233
|
+
const parsed = JSON.parse(payload);
|
|
234
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
235
|
+
candidates.push(parsed);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
// Not a JSON payload; skip this candidate.
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
if (trimmed.includes("data:")) {
|
|
243
|
+
for (const line of trimmed.split("\n")) {
|
|
244
|
+
const t = line.trim();
|
|
245
|
+
if (!t.startsWith("data:"))
|
|
246
|
+
continue;
|
|
247
|
+
const payload = t.slice("data:".length).trim();
|
|
248
|
+
if (payload !== "" && payload !== "[DONE]")
|
|
249
|
+
tryPush(payload);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
tryPush(trimmed);
|
|
254
|
+
}
|
|
255
|
+
if (candidates.length === 0)
|
|
256
|
+
return null;
|
|
257
|
+
if (expectedId !== undefined) {
|
|
258
|
+
const match = candidates.find((c) => c.id === expectedId);
|
|
259
|
+
if (match !== undefined)
|
|
260
|
+
return match;
|
|
261
|
+
}
|
|
262
|
+
return candidates[candidates.length - 1];
|
|
263
|
+
}
|
|
264
|
+
async function defaultFetch(url, init) {
|
|
265
|
+
return fetch(url, init);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* A forwarding client holding a single upstream session,
|
|
269
|
+
* opened lazily on first use and reused from then on
|
|
270
|
+
* (for the process lifetime in the MCP server, or for a
|
|
271
|
+
* single invocation in the CLI).
|
|
272
|
+
*/
|
|
273
|
+
export class PrintcraftClient {
|
|
274
|
+
deps;
|
|
275
|
+
sessionId = null;
|
|
276
|
+
ready = false;
|
|
277
|
+
sessionPromise = null;
|
|
278
|
+
idCounter = 0;
|
|
279
|
+
constructor(deps = {}) {
|
|
280
|
+
this.deps = deps;
|
|
281
|
+
}
|
|
282
|
+
fetchFn() {
|
|
283
|
+
return this.deps.fetchFn ?? defaultFetch;
|
|
284
|
+
}
|
|
285
|
+
endpointUrl() {
|
|
286
|
+
if (this.deps.url && this.deps.url.trim() !== "")
|
|
287
|
+
return this.deps.url.trim();
|
|
288
|
+
const raw = (this.deps.env ?? process.env).DRMAKER3D_MCP_URL;
|
|
289
|
+
if (raw && raw.trim() !== "")
|
|
290
|
+
return raw.trim();
|
|
291
|
+
return DEFAULT_ENDPOINT_URL;
|
|
292
|
+
}
|
|
293
|
+
timeoutMs() {
|
|
294
|
+
if (typeof this.deps.timeoutMs === "number" && this.deps.timeoutMs > 0) {
|
|
295
|
+
return this.deps.timeoutMs;
|
|
296
|
+
}
|
|
297
|
+
return DEFAULT_TIMEOUT_MS;
|
|
298
|
+
}
|
|
299
|
+
nextId() {
|
|
300
|
+
this.idCounter += 1;
|
|
301
|
+
return this.idCounter;
|
|
302
|
+
}
|
|
303
|
+
async post(body, withSession) {
|
|
304
|
+
// The registry record declares NO headers on the upstream
|
|
305
|
+
// remote: no Authorization header is ever sent.
|
|
306
|
+
const headers = {
|
|
307
|
+
"Content-Type": "application/json",
|
|
308
|
+
Accept: "application/json, text/event-stream",
|
|
309
|
+
};
|
|
310
|
+
if (withSession && this.sessionId !== null) {
|
|
311
|
+
headers["Mcp-Session-Id"] = this.sessionId;
|
|
312
|
+
}
|
|
313
|
+
const controller = new AbortController();
|
|
314
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs());
|
|
315
|
+
try {
|
|
316
|
+
return await this.fetchFn()(this.endpointUrl(), {
|
|
317
|
+
method: "POST",
|
|
318
|
+
headers,
|
|
319
|
+
body: JSON.stringify(body),
|
|
320
|
+
signal: controller.signal,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
finally {
|
|
324
|
+
clearTimeout(timer);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
async ensureSession() {
|
|
328
|
+
if (this.ready)
|
|
329
|
+
return;
|
|
330
|
+
if (this.sessionPromise === null) {
|
|
331
|
+
this.sessionPromise = (async () => {
|
|
332
|
+
const initId = this.nextId();
|
|
333
|
+
const initRes = await this.post({
|
|
334
|
+
jsonrpc: "2.0",
|
|
335
|
+
id: initId,
|
|
336
|
+
method: "initialize",
|
|
337
|
+
params: {
|
|
338
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
339
|
+
capabilities: {},
|
|
340
|
+
clientInfo: { name: "printcraft", version: VERSION },
|
|
341
|
+
},
|
|
342
|
+
}, false);
|
|
343
|
+
const sessionId = initRes.headers.get("mcp-session-id");
|
|
344
|
+
if (sessionId)
|
|
345
|
+
this.sessionId = sessionId;
|
|
346
|
+
const initText = await initRes.text();
|
|
347
|
+
const initParsed = parseRpcBody(initText, initId);
|
|
348
|
+
if (initParsed !== null && initParsed.error) {
|
|
349
|
+
throw new Error(rpcErrorMessage(initParsed.error));
|
|
350
|
+
}
|
|
351
|
+
if (initRes.status < 200 || initRes.status >= 300) {
|
|
352
|
+
throw new Error(`HTTP ${initRes.status}`);
|
|
353
|
+
}
|
|
354
|
+
if (initParsed === null && initText.trim() !== "") {
|
|
355
|
+
throw new Error("malformed response");
|
|
356
|
+
}
|
|
357
|
+
const initializedRes = await this.post({ jsonrpc: "2.0", method: "notifications/initialized" }, true);
|
|
358
|
+
try {
|
|
359
|
+
await initializedRes.text();
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
// Nothing needed from the notification response body.
|
|
363
|
+
}
|
|
364
|
+
this.ready = true;
|
|
365
|
+
})();
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
await this.sessionPromise;
|
|
369
|
+
}
|
|
370
|
+
catch (err) {
|
|
371
|
+
this.sessionPromise = null;
|
|
372
|
+
this.sessionId = null;
|
|
373
|
+
throw err;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/** Forward one tool call; upstream failures come back as isError results. */
|
|
377
|
+
async callTool(name, args) {
|
|
378
|
+
try {
|
|
379
|
+
await this.ensureSession();
|
|
380
|
+
}
|
|
381
|
+
catch (err) {
|
|
382
|
+
return errorResult(err instanceof Error ? err.message : String(err));
|
|
383
|
+
}
|
|
384
|
+
const callId = this.nextId();
|
|
385
|
+
let callRes;
|
|
386
|
+
try {
|
|
387
|
+
callRes = await this.post({
|
|
388
|
+
jsonrpc: "2.0",
|
|
389
|
+
id: callId,
|
|
390
|
+
method: "tools/call",
|
|
391
|
+
params: { name, arguments: args ?? {} },
|
|
392
|
+
}, true);
|
|
393
|
+
}
|
|
394
|
+
catch (err) {
|
|
395
|
+
return errorResult(`request failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
396
|
+
}
|
|
397
|
+
const parsed = parseRpcBody(await callRes.text(), callId);
|
|
398
|
+
if (parsed !== null && parsed.error) {
|
|
399
|
+
return errorResult(rpcErrorMessage(parsed.error));
|
|
400
|
+
}
|
|
401
|
+
if (callRes.status < 200 || callRes.status >= 300) {
|
|
402
|
+
return errorResult(`HTTP ${callRes.status}`);
|
|
403
|
+
}
|
|
404
|
+
if (parsed === null)
|
|
405
|
+
return errorResult("malformed response");
|
|
406
|
+
const result = parsed.result;
|
|
407
|
+
if (result === undefined || result === null || typeof result !== "object") {
|
|
408
|
+
return errorResult("malformed response");
|
|
409
|
+
}
|
|
410
|
+
// Hand the upstream result back exactly as received.
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/** Build a forwarding client; tests inject a fake fetch and env through deps. */
|
|
415
|
+
export function createClient(deps = {}) {
|
|
416
|
+
return new PrintcraftClient(deps);
|
|
417
|
+
}
|
|
418
|
+
/** One-shot helper: a fresh client for a single call (the CLI path). */
|
|
419
|
+
export async function callTool(name, args, deps = {}) {
|
|
420
|
+
return new PrintcraftClient(deps).callTool(name, args);
|
|
421
|
+
}
|
|
422
|
+
//# sourceMappingURL=forward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward.js","sourceRoot":"","sources":["../src/forward.ts"],"names":[],"mappings":"AAsDA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAE7C,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AAExE,MAAM,CAAC,MAAM,SAAS,GAAc;IAClC;QACE,MAAM,EAAE,iBAAiB;QACzB,OAAO,EAAE,iBAAiB;QAC1B,aAAa,EAAE,k1BAAk1B;QACj2B,aAAa,EAAE;YACb,MAAM,EAAE,QAAQ;YAChB,YAAY,EAAE;gBACZ,OAAO,EAAE;oBACP,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE;wBACN,KAAK;wBACL,iBAAiB;wBACjB,gBAAgB;wBAChB,gBA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AC,CAAC;AACzD,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* printcraft MCP server. Tools: the 6 captured DrMaker3D
|
|
3
|
+
* tools (see forward.ts).
|
|
4
|
+
*
|
|
5
|
+
* This file uses the low-level Server API rather than
|
|
6
|
+
* McpServer: the high-level helper rebuilds schemas from
|
|
7
|
+
* zod and rewrites what is served, which would break
|
|
8
|
+
* exact parity with the captured tools/list. Here
|
|
9
|
+
* tools/list is answered locally from the core's literal
|
|
10
|
+
* definitions — the verbatim objects from the upstream
|
|
11
|
+
* capture — and every tools/call is forwarded upstream.
|
|
12
|
+
*
|
|
13
|
+
* A forwarded result returns unchanged, upstream isError
|
|
14
|
+
* flag and extra fields included. An upstream failure
|
|
15
|
+
* arrives as an isError result carrying a
|
|
16
|
+
* `printcraft error:` text, built by the forwarding
|
|
17
|
+
* client. Unknown tool names are rejected with McpError
|
|
18
|
+
* MethodNotFound, and non-object arguments with McpError
|
|
19
|
+
* InvalidParams, before any network hop is made.
|
|
20
|
+
*/
|
|
21
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
22
|
+
import { type PrintcraftClient } from "./forward.js";
|
|
23
|
+
import type { ForwardDeps, ToolResult } from "./types.js";
|
|
24
|
+
/**
|
|
25
|
+
* Validate and forward a single tools/call through
|
|
26
|
+
* `client`. Exported so this layer can be tested directly
|
|
27
|
+
* without a stdio transport.
|
|
28
|
+
*/
|
|
29
|
+
export declare function handleCallTool(client: PrintcraftClient, name: string, args: unknown): Promise<ToolResult>;
|
|
30
|
+
/** Build the stdio MCP server (transport not yet connected). */
|
|
31
|
+
export declare function createServer(deps?: ForwardDeps): Server;
|
|
32
|
+
/** Connect the MCP server over stdio. */
|
|
33
|
+
export declare function startMcpServer(deps?: ForwardDeps): Promise<void>;
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* printcraft MCP server. Tools: the 6 captured DrMaker3D
|
|
3
|
+
* tools (see forward.ts).
|
|
4
|
+
*
|
|
5
|
+
* This file uses the low-level Server API rather than
|
|
6
|
+
* McpServer: the high-level helper rebuilds schemas from
|
|
7
|
+
* zod and rewrites what is served, which would break
|
|
8
|
+
* exact parity with the captured tools/list. Here
|
|
9
|
+
* tools/list is answered locally from the core's literal
|
|
10
|
+
* definitions — the verbatim objects from the upstream
|
|
11
|
+
* capture — and every tools/call is forwarded upstream.
|
|
12
|
+
*
|
|
13
|
+
* A forwarded result returns unchanged, upstream isError
|
|
14
|
+
* flag and extra fields included. An upstream failure
|
|
15
|
+
* arrives as an isError result carrying a
|
|
16
|
+
* `printcraft error:` text, built by the forwarding
|
|
17
|
+
* client. Unknown tool names are rejected with McpError
|
|
18
|
+
* MethodNotFound, and non-object arguments with McpError
|
|
19
|
+
* InvalidParams, before any network hop is made.
|
|
20
|
+
*/
|
|
21
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
22
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
23
|
+
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from "@modelcontextprotocol/sdk/types.js";
|
|
24
|
+
import { createClient, isKnownTool, TOOL_DEFS, VERSION, } from "./forward.js";
|
|
25
|
+
/**
|
|
26
|
+
* Validate and forward a single tools/call through
|
|
27
|
+
* `client`. Exported so this layer can be tested directly
|
|
28
|
+
* without a stdio transport.
|
|
29
|
+
*/
|
|
30
|
+
export async function handleCallTool(client, name, args) {
|
|
31
|
+
if (!isKnownTool(name)) {
|
|
32
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
33
|
+
}
|
|
34
|
+
if (args !== undefined &&
|
|
35
|
+
(typeof args !== "object" || args === null || Array.isArray(args))) {
|
|
36
|
+
throw new McpError(ErrorCode.InvalidParams, `Arguments for tool ${name} must be a JSON object`);
|
|
37
|
+
}
|
|
38
|
+
return client.callTool(name, (args ?? {}));
|
|
39
|
+
}
|
|
40
|
+
/** Build the stdio MCP server (transport not yet connected). */
|
|
41
|
+
export function createServer(deps = {}) {
|
|
42
|
+
const client = createClient(deps);
|
|
43
|
+
const server = new Server({ name: "printcraft", version: VERSION }, { capabilities: { tools: {} } });
|
|
44
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
45
|
+
tools: TOOL_DEFS,
|
|
46
|
+
}));
|
|
47
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
48
|
+
const { name, arguments: args } = request.params;
|
|
49
|
+
const result = await handleCallTool(client, name, args);
|
|
50
|
+
return result;
|
|
51
|
+
});
|
|
52
|
+
return server;
|
|
53
|
+
}
|
|
54
|
+
/** Connect the MCP server over stdio. */
|
|
55
|
+
export async function startMcpServer(deps = {}) {
|
|
56
|
+
await createServer(deps).connect(new StdioServerTransport());
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EACtB,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAO,GAER,MAAM,cAAc,CAAC;AAGtB;;;;GAIG;AAC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xD,OAAO,MAAe,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,yCAAyC;AACzC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAoB,EAAE;IACzD,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* printcraft types.
|
|
3
|
+
*
|
|
4
|
+
* This package holds no shop data of its own. It is a
|
|
5
|
+
* forwarding client: the captured DrMaker3D tool surface
|
|
6
|
+
* is kept as plain data (ToolDef entries served verbatim
|
|
7
|
+
* for tools/list) and each tools/call is sent to the
|
|
8
|
+
* hosted DrMaker3D MCP endpoint through an injectable
|
|
9
|
+
* fetch, so the whole test suite can run against a
|
|
10
|
+
* stubbed upstream with no live network.
|
|
11
|
+
*/
|
|
12
|
+
/** One captured tool definition, served exactly as captured for tools/list. */
|
|
13
|
+
export interface ToolDef {
|
|
14
|
+
name: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: Record<string, unknown>;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** Arguments for a tool call, as decoded JSON. */
|
|
21
|
+
export type ToolArgs = Record<string, unknown>;
|
|
22
|
+
/** A tools/call result: upstream payloads pass through verbatim; local failures use this shape too. */
|
|
23
|
+
export interface ToolResult {
|
|
24
|
+
content?: unknown;
|
|
25
|
+
isError?: boolean;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** The narrow slice of a fetch Response the forwarding client relies on. */
|
|
29
|
+
export interface FetchResponseLike {
|
|
30
|
+
ok: boolean;
|
|
31
|
+
status: number;
|
|
32
|
+
headers: {
|
|
33
|
+
get(name: string): string | null;
|
|
34
|
+
};
|
|
35
|
+
text(): Promise<string>;
|
|
36
|
+
}
|
|
37
|
+
/** Injectable fetch function, so tests never reach the live network. */
|
|
38
|
+
export type FetchFn = (url: string, init?: {
|
|
39
|
+
method?: string;
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
body?: string;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}) => Promise<FetchResponseLike>;
|
|
44
|
+
/** Injectable runtime dependencies for the forwarding client. */
|
|
45
|
+
export interface ForwardDeps {
|
|
46
|
+
/** Fetch implementation. Defaults to the global fetch. */
|
|
47
|
+
fetchFn?: FetchFn;
|
|
48
|
+
/** Environment (DRMAKER3D_MCP_URL). Defaults to process.env. */
|
|
49
|
+
env?: Record<string, string | undefined>;
|
|
50
|
+
/** Endpoint URL override. Defaults to env DRMAKER3D_MCP_URL or the pinned default. */
|
|
51
|
+
url?: string;
|
|
52
|
+
/** Per-request timeout in milliseconds. Defaults to 30000. */
|
|
53
|
+
timeoutMs?: number;
|
|
54
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* printcraft types.
|
|
3
|
+
*
|
|
4
|
+
* This package holds no shop data of its own. It is a
|
|
5
|
+
* forwarding client: the captured DrMaker3D tool surface
|
|
6
|
+
* is kept as plain data (ToolDef entries served verbatim
|
|
7
|
+
* for tools/list) and each tools/call is sent to the
|
|
8
|
+
* hosted DrMaker3D MCP endpoint through an injectable
|
|
9
|
+
* fetch, so the whole test suite can run against a
|
|
10
|
+
* stubbed upstream with no live network.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@reneturcios/printcraft",
|
|
3
|
-
"version": "0.0.0-stage",
|
|
4
|
-
"stub": true,
|
|
5
|
-
"description": "Temporary package placeholder for staged publishing"
|
|
6
|
-
}
|
|
1
|
+
{"bin":{"printcraft":"dist/cli.js"},"dependencies":{"@modelcontextprotocol/sdk":"^1","zod":"^4"},"description":"DrMaker3D studio reads, forwarded from the hosted shop service: studio information, shop search, print price examples, materials and options, instant print quotes and order tracking. One bin serves a small CLI and the MCP server.","devDependencies":{"@types/node":"^20","tsx":"^4","typescript":"^5"},"engines":{"node":">=20"},"files":["dist","server.json"],"homepage":"https://github.com/CloudCorpRecords/printcraft#readme","license":"MIT","mcpName":"io.github.CloudCorpRecords/printcraft","name":"@reneturcios/printcraft","private":false,"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/CloudCorpRecords/printcraft.git"},"scripts":{"build":"tsc","dev":"tsx src/cli.ts","test":"tsx --test test/*.test.ts"},"type":"module","version":"0.1.0"}
|
package/server.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"$schema":"https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json","description":"DrMaker3D studio reads: shop search, print prices, options, instant print quotes and order tracking.","name":"io.github.CloudCorpRecords/printcraft","packages":[{"identifier":"@reneturcios/printcraft","packageArguments":[{"type":"positional","value":"mcp"}],"registryBaseUrl":"https://registry.npmjs.org","registryType":"npm","runtimeHint":"npx","transport":{"type":"stdio"},"version":"0.1.0"},{"identifier":"ghcr.io/cloudcorprecords/printcraft:0.1.0","packageArguments":[{"type":"positional","value":"mcp"}],"registryType":"oci","runtimeArguments":[{"name":"--rm","type":"named"},{"name":"-i","type":"named"}],"runtimeHint":"docker","transport":{"type":"stdio"}}],"repository":{"source":"github","url":"https://github.com/CloudCorpRecords/printcraft"},"version":"0.1.0"}
|