typeset-mcp 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,3 @@
1
+ """typeset-mcp: Markdown to PDF typesetting MCP server (Typst engine, CJK-first)."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,87 @@
1
+ """Console entry point for the typeset MCP server."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import os
7
+ from pathlib import Path
8
+
9
+ from . import __version__
10
+ from .workspace import configure
11
+
12
+
13
+ def parser() -> argparse.ArgumentParser:
14
+ root = argparse.ArgumentParser(
15
+ prog="typeset-mcp",
16
+ description="MCP server that typesets Markdown documents to PDF (Typst engine).",
17
+ )
18
+ root.add_argument(
19
+ "--transport",
20
+ choices=("stdio", "http"),
21
+ default="stdio",
22
+ help="stdio is the default local transport; http serves Streamable HTTP on 127.0.0.1.",
23
+ )
24
+ root.add_argument("--host", default="127.0.0.1", help="HTTP bind address; keep the loopback default.")
25
+ root.add_argument("--port", type=int, default=8766, help="HTTP port.")
26
+ root.add_argument(
27
+ "--root",
28
+ action="append",
29
+ default=[],
30
+ metavar="PATH",
31
+ help="Workspace root for relative paths. Repeatable.",
32
+ )
33
+ root.add_argument(
34
+ "--restrict-paths",
35
+ action="store_true",
36
+ help="Reject paths outside the workspace roots. Always enabled for HTTP.",
37
+ )
38
+ root.add_argument(
39
+ "--cache-dir",
40
+ metavar="PATH",
41
+ default=None,
42
+ help="Typst package cache (default: <first root>/.typeset-cache).",
43
+ )
44
+ root.add_argument(
45
+ "--allow-private-images",
46
+ action="store_true",
47
+ help="Let image localization fetch private/link-local addresses (trusted intranet). Blocked by default.",
48
+ )
49
+ root.add_argument("--version", action="version", version=f"typeset-mcp {__version__}")
50
+ return root
51
+
52
+
53
+ def main(argv: list[str] | None = None) -> int:
54
+ arguments = parser().parse_args(argv)
55
+ roots = tuple(
56
+ Path(value).expanduser()
57
+ for value in (
58
+ arguments.root
59
+ or [os.environ.get("CLAUDE_PROJECT_DIR") or Path.cwd()]
60
+ )
61
+ )
62
+ configure(roots, restrict=arguments.restrict_paths or arguments.transport == "http")
63
+
64
+ from .engine import set_cache_dir
65
+
66
+ cache = (
67
+ Path(arguments.cache_dir).expanduser()
68
+ if arguments.cache_dir
69
+ else roots[0] / ".typeset-cache"
70
+ )
71
+ set_cache_dir(cache)
72
+
73
+ from .imagefetch import configure_fetch
74
+
75
+ configure_fetch(arguments.allow_private_images)
76
+
77
+ from .server import mcp
78
+
79
+ if arguments.transport == "http":
80
+ mcp.run(transport="streamable-http", host=arguments.host, port=arguments.port)
81
+ else:
82
+ mcp.run()
83
+ return 0
84
+
85
+
86
+ if __name__ == "__main__":
87
+ raise SystemExit(main())