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.
- typeset_mcp/__init__.py +3 -0
- typeset_mcp/__main__.py +87 -0
- typeset_mcp/audit.py +697 -0
- typeset_mcp/convertfigs.py +80 -0
- typeset_mcp/data/guides/authoring.md +119 -0
- typeset_mcp/data/guides/workflow.md +51 -0
- typeset_mcp/engine.py +140 -0
- typeset_mcp/errors.py +16 -0
- typeset_mcp/guides.py +35 -0
- typeset_mcp/imagefetch.py +157 -0
- typeset_mcp/imageinfo.py +79 -0
- typeset_mcp/imageresize.py +97 -0
- typeset_mcp/jsonio.py +13 -0
- typeset_mcp/layout.py +21 -0
- typeset_mcp/mdconvert.py +524 -0
- typeset_mcp/mdlint.py +548 -0
- typeset_mcp/measure.py +296 -0
- typeset_mcp/netguard.py +144 -0
- typeset_mcp/project.py +119 -0
- typeset_mcp/projectconfig.py +60 -0
- typeset_mcp/publish.py +61 -0
- typeset_mcp/render.py +77 -0
- typeset_mcp/server.py +233 -0
- typeset_mcp/template.py +106 -0
- typeset_mcp/workspace.py +39 -0
- typeset_mcp-0.1.0.dist-info/METADATA +160 -0
- typeset_mcp-0.1.0.dist-info/RECORD +30 -0
- typeset_mcp-0.1.0.dist-info/WHEEL +4 -0
- typeset_mcp-0.1.0.dist-info/entry_points.txt +2 -0
- typeset_mcp-0.1.0.dist-info/licenses/LICENSE +21 -0
typeset_mcp/__init__.py
ADDED
typeset_mcp/__main__.py
ADDED
|
@@ -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())
|