# JointTex Developers — Full Reference Source: https://developers.jointtex.com/ Languages: English (inline below) and Simplified Chinese (/zh/...). --- # Getting Started URL: https://developers.jointtex.com/getting-started/ JointTex exposes four public integration surfaces so tutorials, third-party apps, AI agents, and local toolchains can interoperate with collaborative LaTeX and Typst projects without scraping or brittle workarounds. ## Choose an integration | Goal | Surface | Auth required | Best for | | --- | --- | --- | --- | | Let readers open code snippets in JointTex | [`POST /open`](/open/overview/) | None on sender site | Tutorials, blogs, course sites, `runlatex.js` | | Link a full template from a GitHub README | [Template Gallery + Official Badges](/open/badges/) | None on sender site | Thesis, journal, CV, and slide templates with images or `.cls` files | | Let users sign into your own app with JointTex | [Sign in with JointTex (OIDC)](/oidc/overview/) | OIDC client (self-serve) | Companion web apps, research portals, desktop tools | | Let an AI agent read, edit, compile, and organize projects | [Remote MCP Server (`/mcp`)](/mcp/overview/) | OAuth 2.1 or MCP Bearer token | Claude, ChatGPT, Codex, Cursor, VS Code, custom agents | | Pull and push project files from CLI or CI | [Git Bridge (`/git/`)](/sync/git-bridge/) | Personal Git access token | Local editors, Makefiles, automated checks | ## Production endpoints | Surface | Endpoint | | --- | --- | | Web application | `https://jointtex.com` | | Open in JointTex form action | `https://jointtex.com/open` | | Template Gallery | `https://jointtex.com/templates/` | | OIDC Issuer | `https://jointtex.com/oidc` | | OIDC Discovery | `https://jointtex.com/oidc/.well-known/openid-configuration` | | Remote MCP Server | `https://jointtex.com/mcp` | | MCP Protected Resource Metadata | `https://jointtex.com/.well-known/oauth-protected-resource/mcp` | | Git Bridge | `https://jointtex.com/git/` | | Hosted SVG badges | `https://developers.jointtex.com/badges/` | ## Using these docs with AI coding agents Every page on this site is exported as plain-text Markdown at build time so coding agents can read exact field names, scopes, and endpoints without HTML noise: - **Index**: [`https://developers.jointtex.com/llms.txt`](/llms.txt) - **Full documentation bundle**: [`https://developers.jointtex.com/llms-full.txt`](/llms-full.txt) ## Next steps - Adding an **Open in JointTex** button? Try the [interactive generator](/open/generator/) or read the [`/open` reference](/open/overview/). - Adding **Sign in with JointTex** to an app? Start with [OIDC Overview](/oidc/overview/). - Connecting an **AI agent**? See [Connecting AI Clients](/mcp/connect/). --- # Open in JointTex (/open) URL: https://developers.jointtex.com/open/overview/ Any website, blog, course portal, or documentation page can place an **Open in JointTex** button next to a LaTeX or Typst example. The button is a plain HTML `
` that `POST`s the code to `https://jointtex.com/open` — no JavaScript SDK, API key, or JointTex account is required on your site. The form field names match Overleaf's `/docs` endpoint, so existing Overleaf snippet forms work by changing only the `action` URL. JointTex also adds first-class support for **Typst**. ## Quick example ### Single LaTeX file ```html
``` > Inside a ``). If your site generates the form from JavaScript, populate an `` with `encodeURIComponent(code)` instead. ### Multiple files Repeat `snip[]` (or `encoded_snip[]`) for each file and provide matching relative paths in `snip_name[]` in the same order: ```html
``` ### Typst example Set `engine` to `typst` (or name the root file `*.typ`): ```html
``` ## Endpoint and content types - **URL**: `POST https://jointtex.com/open` - **Accepted encodings**: `application/x-www-form-urlencoded` or `multipart/form-data` (text fields only; file uploads are rejected). - **HTTP method**: `POST` only. Visiting `GET https://jointtex.com/open` directly displays an informational page with a link to the integration guide. ## Form fields reference | Field | Repeatable | Description | | --- | --- | --- | | `snip` / `snip[]` | Yes | Raw UTF-8 text of a file. Browser CRLF line endings are normalized to LF. | | `encoded_snip` / `encoded_snip[]` | Yes | Percent-encoded UTF-8 text (`encodeURIComponent`). If decoding fails (for example, unencoded LaTeX `%` comments sent by `runlatex.js`), the value is accepted as raw text. | | `snip_name` / `snip_name[]` | Yes | Relative file path for each snippet in the same order (subfolders such as `chapters/intro.tex` are allowed). Unnamed first file defaults to `main.tex` (`main.typ` when `engine=typst`); subsequent unnamed files default to `snippet-2.tex`, `snippet-3.tex`, and so on. | | `main_document` | No | Exact relative path of the root `.tex` or `.typ` file to compile. Must match one of the submitted files. | | `engine` | No | Compiler engine: `pdflatex`, `xelatex`, `lualatex`, `latex` (Overleaf's `latex_dvipdf` alias is mapped to `latex`), or `typst`. Unknown engines or language mismatches (for example `typst` with a `.tex` root) are rejected. | ## Automatic root, engine, and fragment detection When optional fields are omitted, JointTex resolves the build configuration deterministically: 1. **Root file selection**: If `main_document` is omitted, JointTex searches files matching the explicit `engine`'s language (or `.tex` files first, then `.typ` files when no engine is given). It picks the only matching file, otherwise `main.tex` / `main.typ` if it is a complete document, otherwise the first complete document, otherwise the first matching file. A `.tex` file is considered complete if it contains `\documentclass`; any `.typ` file is complete. 2. **Engine detection**: For a `.typ` root, the engine is always `typst`. For a `.tex` root without an explicit `engine`, JointTex checks the first 20 lines for a `% !TEX program = ` (or `TS-program`) magic comment; failing that, it selects `xelatex` if the root contains CJK characters, otherwise `pdflatex`. 3. **Single-file fragment wrapping**: If a submission contains exactly one `.tex` file and it has no `\documentclass`, JointTex wraps it in a minimal `\documentclass{article}` document (`ctexart` when CJK text is present and the engine is not `pdflatex` or `latex`) so it compiles immediately. Typst code is never wrapped. ## Reader experience and security model JointTex keeps the `/open` flow stateless on the server until the reader confirms creation: 1. `POST /open` does **not** require cookies, does **not** read the reader's session, and writes **nothing** to the server database. 2. The server validates the payload and returns the JointTex web shell (`Cache-Control: no-store`) with the parsed files embedded as inert JSON. 3. The browser stores the draft locally under a random 128-bit ID in `localStorage` (up to the 5 newest drafts, 1.5M characters total, retained for 7 days; private windows keep the draft in tab memory) and replaces the URL with `/open/?visit=` so reloads never resubmit the form. 4. On `/open/`, the reader inspects every file, the target engine, and your site's origin. Signed-out readers sign up or sign in and return to the same draft and `visit`. 5. Clicking **Create project** submits the draft to the same-origin authenticated endpoint `POST /api/snippets/project`, proposing a name from `\title{...}` when present. The new project is private to the reader, and the `visit` UUID guarantees idempotency so double-clicks, reloads, or Back navigation never create duplicate projects. ## Limits and error codes | Constraint | Limit | | --- | --- | | Total raw POST body size | 3 MiB | | Maximum file count | 20 files | | Maximum single file size (UTF-8) | 256 KiB | | Maximum combined files size (UTF-8) | 512 KiB | | Maximum relative path length (UTF-8) | 255 bytes | | Binary attachments / remote fetches | Refused (`snip_uri`, `zip_uri`, and multipart file uploads are not accepted) | Path validation also enforces safe relative paths, blocks NUL bytes, blocks the reserved `.jointtex/` directory, blocks case-insensitive path collisions, and verifies the root file name is compilable. When a submission is refused, JointTex responds with `303 See Other` to `/open?error=` so the reader lands on a readable explanation page: | `error` value | Meaning | | --- | --- | | `invalid` | Missing snippet text, more `snip_name[]` values than files, invalid path or root file, invalid `engine`, or engine/file language mismatch. | | `too-large` | Request body exceeded 3 MiB, a single file exceeded 256 KiB, or total file bytes exceeded 512 KiB. | | `too-many` | More than 20 files submitted. | | `unsupported` | `snip_uri`, `zip_uri`, or a multipart file attachment was sent. | ## Attribution and privacy JointTex reads only the scheme and host of the browser's `Origin` header (falling back to `Referer` origin) to show the reader where the code came from and to aggregate anonymous project-creation counts per referring site. Individual page URLs and reader identities are not recorded in referral counts. > Need to distribute a full template with figures, fonts, or `.cls` files from a GitHub README? Publish the template to the JointTex Template Gallery and link it with an [official Open in JointTex badge](/open/badges/). --- # Button & Badge Generator URL: https://developers.jointtex.com/open/generator/ Use the generator below to create copy-and-paste markup for your website, course notes, blog posts, or GitHub repository READMEs. In form modes, click the preview button to test your submission directly against `https://jointtex.com/open`. > Interactive generator available on the web page. ## Tips - **Blogs & documentation sites**: Use **Single-file form** or **Multi-file form** — no JavaScript is needed on your page. - **GitHub READMEs**: GitHub strips `
` tags from Markdown, so use **Template badge (GitHub README)** linked to your published JointTex template (`https://jointtex.com/templates/`). - **Overleaf migration**: Already have forms pointing to `https://www.overleaf.com/docs`? See the [Overleaf migration guide](/open/migrate-overleaf/). --- # Official Badges & GitHub READMEs URL: https://developers.jointtex.com/open/badges/ GitHub Markdown sanitizes `` elements, so repository READMEs cannot submit a `POST` form directly to `/open`. For complete LaTeX or Typst templates — especially thesis, journal, and presentation templates containing `.cls`, `.bst`, images, or fonts — publish your template to the [JointTex Template Gallery](https://jointtex.com/templates) and add an **Open in JointTex** badge linking directly to `https://jointtex.com/templates/`. Readers can inspect the rendered preview and source files on the public template page before signing in to create their own private copy. ## Official hosted SVG badges All official badges are served from `https://developers.jointtex.com/badges/` with `Access-Control-Allow-Origin: *` and edge caching. ## Markdown (GitHub README) ```markdown [![Open in JointTex](https://developers.jointtex.com/badges/open-in-jointtex.svg)](https://jointtex.com/templates/) ``` For inline badge rows beside CI, license, or version shields, use the 20px compact variant: ```markdown [![Open in JointTex](https://developers.jointtex.com/badges/open-in-jointtex-compact.svg)](https://jointtex.com/templates/) ``` ## HTML (Websites & Docs) ```html Open in JointTex ``` ## Adaptive light & dark README badge GitHub supports `` media queries in Markdown so the badge matches the reader's GitHub theme automatically: ```html Open in JointTex ``` > Want to customize a badge link interactively? Open the [Button & Badge Generator](/open/generator/) and switch to the **Template badge** tab. --- # Migrating from Overleaf /docs URL: https://developers.jointtex.com/open/migrate-overleaf/ JointTex's `POST /open` endpoint intentionally implements Overleaf's inline snippet form fields so tutorials and educational platforms can support JointTex with minimal changes. ## Field-by-field compatibility | Overleaf field | JointTex `/open` support | Notes | | --- | --- | --- | | `snip`, `snip[]` | Supported | Raw UTF-8 text; CRLF is normalized to LF. | | `encoded_snip`, `encoded_snip[]` | Supported | Decoded with `decodeURIComponent`; falls back to raw text if invalid percent escapes appear. | | `snip_name`, `snip_name[]` | Supported | Relative file paths in matching order. | | `main_document` | Supported | Designates the root `.tex` or `.typ` file to compile. | | `engine` | Supported + `typst` | Accepts `pdflatex`, `xelatex`, `lualatex`, `latex`, `latex_dvipdf` (aliased to `latex`), and `typst`. | | `snip_uri`, `zip_uri` | Not supported (`error=unsupported`) | JointTex refuses server-side URL fetching on `/open` to avoid open-proxy abuse. See alternatives below. | | `splash` | Ignored | JointTex always shows a lightweight confirmation view before creating a project in the reader's account. | ## Migrating an HTML snippet form Change only the `action` URL and button text: ```diff - + - + ``` You can also offer **both** buttons side by side on your site by keeping your existing form and adding a second form pointing to `https://jointtex.com/open`. ## Migrating `runlatex.js` (`learnlatex.org` sites) Pages built with `runlatex.js` already submit `encoded_snip[]` and `snip_name[]` in the exact format JointTex expects (including unencoded LaTeX `%` comments). Point `runlatex.overleafURI` to JointTex and update the button label: ```js runlatex.overleafURI = "https://jointtex.com/open"; runlatex.texts["Open in Overleaf"] = "Open in JointTex"; ``` ## Replacing `snip_uri` or `zip_uri` links Because `POST /open` does not fetch arbitrary remote URLs: 1. **For text-only examples** (up to 20 files, 512 KiB total): Embed the files directly in `snip[]` or `encoded_snip[]` fields in a `
`. 2. **For complete templates with images, `.cls`, or `.bst` files**: Publish the template once to the [JointTex Template Gallery](https://jointtex.com/templates) (you can republish updates directly from your JointTex project or via MCP) and link to `https://jointtex.com/templates/` using an [official badge](/open/badges/). --- # Sign in with JointTex (OIDC) URL: https://developers.jointtex.com/oidc/overview/ JointTex acts as an OpenID Connect (OIDC) identity provider for independent applications. Any active JointTex account — including a free account — can register applications self-serve under **Account settings → Developer settings** (`https://jointtex.com/user/settings?tab=developer`), with no administrator approval required. JointTex implements the standard [OIDC Authorization Code flow](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth) with **mandatory PKCE S256**. Implicit grants, hybrid grants, request objects, dynamic client registration, and encrypted ID tokens are not used. ## Issuer and endpoints Configure your OIDC library with the **path-bearing issuer URL**, not the site root or the MCP OAuth issuer: | Item | Value | | --- | --- | | Issuer (`iss`) | `https://jointtex.com/oidc` | | Discovery document | `https://jointtex.com/oidc/.well-known/openid-configuration` | | Authorization endpoint | `https://jointtex.com/oidc/authorize` | | Token endpoint | `https://jointtex.com/oidc/token` | | JWKS endpoint | `https://jointtex.com/oidc/jwks` | | UserInfo endpoint | `https://jointtex.com/oidc/userinfo` | | Revocation endpoint | `https://jointtex.com/oidc/revoke` | ## Registering an application Open **Account settings → Developer settings** on JointTex and create an application with: - **Application name**: Displayed on the user consent screen alongside your exact callback URI. - **Redirect URIs** (up to 5): HTTPS callbacks must match **exactly**, including scheme, host, path, query string, and trailing slash. Local development callbacks may use `http://localhost:/...`, `http://127.0.0.1:/...`, or IPv6 loopback with an exact port match. Non-loopback HTTP, custom URL schemes, embedded credentials, and `#fragments` are refused. - **Allowed scopes**: Choose from `openid` (required), `profile`, and `email`. - **Client authentication method**: - **Confidential server app (`client_secret_basic`)**: Receives a client secret shown once. Authenticate at `/oidc/token` and `/oidc/revoke` using HTTP Basic authentication (URL-form-encode client ID and secret before Base64 encoding). `client_secret_post` is refused. - **Public browser / native app (`none`)**: Receives no client secret and submits `client_id` in the token form body. PKCE S256 is required for both client types. Each account may own up to **20 applications**. Saving an edit to an application rotates its credentials and invalidates all pending consents, authorization codes, and active access tokens for that application. Register separate applications for development and production. ## Scopes and identity contract | Scope | Claims returned | | --- | --- | | `openid` (required) | Stable opaque `sub` (random UUID persisted per account, never derived from email or name). | | `profile` | `name` | | `email` | `email`, `email_verified` (reflects actual email verification status) | Important rules for relying parties: - **Key your user table by `(iss, sub)` — never by email.** Email changes, display-name updates, signing-key rotations, and application recreations do not change a user's `sub`. Do not auto-merge accounts solely because emails match. - **Identity only, not JointTex privileges.** OIDC tokens never grant access to JointTex projects, MCP endpoints, billing plans, administrator roles, or GitHub/WebDAV credentials. Your application owns its own user roles, sessions, and records. - **Account deletion.** Deleting a JointTex account removes its `sub` mapping; a newly registered account receives a new `sub`. --- # Authorization Code + PKCE Flow URL: https://developers.jointtex.com/oidc/client-flow/ Use a well-maintained OpenID Connect client library (such as `openid-client` for Node.js or `authlib` for Python) rather than assembling JWT verification by hand. ## Protocol walkthrough ### 1. Discover and redirect to `/oidc/authorize` Fetch `https://jointtex.com/oidc/.well-known/openid-configuration`, generate fresh unpredictable `state`, `nonce`, and a PKCE `code_verifier` (43–128 unreserved characters), and store them in a short-lived, browser-bound session on your server. Redirect the user to: ```text https://jointtex.com/oidc/authorize ?response_type=code &client_id= &redirect_uri=https://app.example.com/auth/jointtex/callback &scope=openid%20profile%20email &state= &nonce= &code_challenge= &code_challenge_method=S256 ``` Optional standard parameters supported: - `prompt=login` or `max_age=` — require fresh authentication; verify `auth_time` in the returned ID token. - `prompt=none` — returns `login_required` or `consent_required` when user interaction is needed. ### 2. User consent and callback JointTex signs the user in (if needed) and shows an explicit consent screen displaying your application name, requested scopes, and exact callback URI. - If the user approves, JointTex redirects to your `redirect_uri` with `code`, `state`, and `iss=https://jointtex.com/oidc`. - If the user cancels, JointTex redirects with `error=access_denied` and your original `state`. On your callback route, **first** verify that `state` matches the browser's stored session value and that `iss` equals `https://jointtex.com/oidc`. ### 3. Exchange the authorization code Send a form `POST` to `https://jointtex.com/oidc/token`: ```sh curl -X POST https://jointtex.com/oidc/token \ -u ":" \ -H "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "grant_type=authorization_code" \ --data-urlencode "code=" \ --data-urlencode "redirect_uri=https://app.example.com/auth/jointtex/callback" \ --data-urlencode "code_verifier=" ``` For public clients (`token_endpoint_auth_method: "none"`), omit HTTP Basic auth and include `client_id=` in the form body. Authorization codes live **5 minutes**, are bound to client, callback, PKCE challenge, browser session, and application revision, and are atomically consumed once. ### 4. Validate the ID token Verify the returned `id_token` using the public keys from `https://jointtex.com/oidc/jwks`: - Require `RS256` and a trusted `kid` from JWKS (refetch JWKS if an unknown `kid` appears during key rotation). - Require exact `iss` (`https://jointtex.com/oidc`), exact `aud` (your `client_id`), valid `exp` / `iat`, matching `nonce`, and a non-empty `sub`. - Check `auth_time` if you passed `max_age` or `prompt=login`. - Never trust a decoded JWT payload without cryptographic signature verification. ### 5. Fetch UserInfo Call `GET https://jointtex.com/oidc/userinfo` with `Authorization: Bearer ` and assert that the returned `sub` matches the ID token's `sub`: ```sh curl https://jointtex.com/oidc/userinfo \ -H "Authorization: Bearer " ``` ```json { "sub": "9a7d0f4e-3c1b-4c4b-9e6a-1f2e3d4c5b6a", "name": "Ada Lovelace", "email": "ada@example.edu", "email_verified": true } ``` ## Node.js example (`openid-client` v6) ```ts import * as client from "openid-client"; const config = await client.discovery( new URL("https://jointtex.com/oidc"), process.env.JOINTTEX_CLIENT_ID!, process.env.JOINTTEX_CLIENT_SECRET!, client.ClientSecretBasic(process.env.JOINTTEX_CLIENT_SECRET!), ); // 1. Build the authorization URL (store verifier, state, nonce in the browser session) const codeVerifier = client.randomPKCECodeVerifier(); const codeChallenge = await client.calculatePKCECodeChallenge(codeVerifier); const state = client.randomState(); const nonce = client.randomNonce(); const authUrl = client.buildAuthorizationUrl(config, { redirect_uri: "https://app.example.com/auth/jointtex/callback", scope: "openid profile email", code_challenge: codeChallenge, code_challenge_method: "S256", state, nonce, }); // 2. Inside the callback handler const tokens = await client.authorizationCodeGrant(config, currentCallbackUrl, { pkceCodeVerifier: session.codeVerifier, expectedState: session.state, expectedNonce: session.nonce, }); const claims = tokens.claims()!; const userInfo = await client.fetchUserInfo(config, tokens.access_token, claims.sub); // Persist user keyed by (claims.iss, claims.sub) ``` --- # Status Checks, Outages & Logout URL: https://developers.jointtex.com/oidc/sessions-and-security/ Because JointTex OIDC is designed for short-lived, high-assurance identity assertions without shared cross-app cookies, relying parties must follow the session validation and logout contract below. ## Token lifetimes - **ID tokens (`id_token`)**: Valid for **300 seconds** (5 minutes), signed with `RS256`. - **Opaque access tokens (`access_token`)**: Valid for **300 seconds**, accepted **only** at `GET /oidc/userinfo` (they cannot access JointTex project APIs or `/mcp`). ## Mandatory UserInfo status checks Relying parties must call `GET /oidc/userinfo` **at least every 60 seconds and before sensitive actions**, without caching a successful check longer than 60 seconds. On every UserInfo call, JointTex validates: 1. Access-token expiry and the application's current revision and owner standing. 2. Whether the user's account is active (not suspended or deleted). 3. Whether the underlying browser session is still active and verified. If any check fails — due to sign-out, all-device session revocation, account suspension/deletion, rotated client credentials, or token revocation — UserInfo returns `401` with `invalid_token`. When an access token expires or returns `401`, require a fresh browser authorization flow before continuing authenticated work. ## Handling transient outages (`503`) If the identity backend is temporarily unreachable, `/oidc/userinfo` returns: ```http HTTP/1.1 503 Service Unavailable Retry-After: 2 Content-Type: application/json {"error":"temporarily_unavailable"} ``` When you receive `503`: - **Do not** treat it as a revoked token or sign the user out of your app. - Retry with backoff respecting `Retry-After`. - If your last successful check is older than 60 seconds, pause authenticated/sensitive actions and show a retryable service-unavailable notice while keeping the user's local draft state intact. ## Single-application logout and revocation To log a user out of your application: 1. Clear your application's own session cookie or store. 2. Optionally revoke the JointTex access token with a form `POST` to `/oidc/revoke` using your application's authentication method (`client_secret_basic` for server apps, or `client_id` in the body for public apps): ```sh curl -X POST https://jointtex.com/oidc/revoke \ -u ":" \ -H "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "token=" ``` Revocation is idempotent (always returns `200`, even for unknown tokens) and only revokes tokens belonging to your application. It does not log the user out of JointTex or any other application. Conversely, signing out of JointTex revokes that browser session so OIDC access tokens tied to it fail their next UserInfo check. ## JWKS signing key rotation - JointTex signs ID tokens with RSA-2048 keys (`RS256`) rotated on a 30-day UTC cycle. - Previous period public keys remain published at `https://jointtex.com/oidc/jwks` for at least 30 days after rotation — far longer than any ID token's 300-second lifetime. - Configure your OIDC client to cache JWKS responsibly and refresh it automatically whenever an ID token carries an unseen `kid`. --- # MCP Server Overview URL: https://developers.jointtex.com/mcp/overview/ JointTex runs a remote **Model Context Protocol (MCP)** server over Streamable HTTP so external AI agents — including Claude, Claude Code, ChatGPT, Codex, Cursor, VS Code, Gemini CLI, and custom agent frameworks — can read, search, edit, compile, review, and organize your LaTeX and Typst projects with fine-grained permissions. ## Endpoint and transport | Property | Value | | --- | --- | | MCP endpoint | `https://jointtex.com/mcp` | | Transport | Streamable HTTP | | Protected Resource Metadata (RFC 9728) | `https://jointtex.com/.well-known/oauth-protected-resource/mcp` | | Authorization Server Metadata (RFC 8414) | `https://jointtex.com/.well-known/oauth-authorization-server` | | Plan availability | JointTex Education, Plus, and Pro | One MCP server URL serves every project your account can reach. Which projects and capabilities an agent may access are chosen per connection during authorization. ## Two ways to authenticate ### 1. OAuth 2.1 sign-in (recommended) Clients that support the MCP authorization specification (RFC 9728, RFC 8414, OAuth 2.1 Authorization Code + PKCE S256, RFC 7591 dynamic client registration, and rotating refresh tokens) connect using the URL `https://jointtex.com/mcp` alone: 1. The client discovers JointTex's OAuth metadata automatically and opens your browser. 2. You sign in, inspect the client's callback URL, pick exact **scopes** and **projects** (or **All projects**), and click **Allow**. 3. You can adjust scopes, change accessible projects, or disconnect the app anytime under **Account settings → Access tokens → Connected apps**. Changes apply on the next tool call without reconnecting. An account can keep up to **20 OAuth-connected apps** (unused connections expire after 30 days of inactivity). ### 2. Personal MCP token (`Authorization: Bearer`) For clients that do not yet implement MCP OAuth discovery (or for headless scripts): 1. Open **Account settings → Access tokens** on JointTex and expand **Use an MCP token**. 2. Name the token, select the minimum scopes and projects required, and create it. 3. Copy the full token (shown once) and send it as `Authorization: Bearer ` to `https://jointtex.com/mcp`. An account can hold up to **10 MCP tokens**. MCP tokens are separate from Git Bridge tokens and remain active until revoked. ## Safety model: tracked changes and least privilege - **Every file edit is a tracked change**: Edits made by an external MCP agent (`write_file`, `write_files`, `edit_file`, `multi_edit`, `create_file`, `upload_file`, `copy_path`, `move_path`, `rename_file`, `delete_path`) land immediately in the project as pending tracked changes (`review_state: "pending_review"`). Collaborators can inspect and accept or reject them in the editor, and every edit is recorded in project history. - **Role ceiling**: A connection never exceeds the user's own project role (for example, a viewer cannot write even if the token includes `files:write`). - **Separate credentials**: Use one token or OAuth connection per tool so revoking one never disrupts other agents. - **Account-scoped tools**: Help guides (`search_help`, `read_help`) are readable with any valid connection; Personal Notes, Agent Memory, References, and Collections are account-level and do not require selecting a project. --- # Connecting AI Clients URL: https://developers.jointtex.com/mcp/connect/ All clients connect to the single remote Streamable HTTP endpoint: ```text https://jointtex.com/mcp ``` ## OAuth 2.1 clients (no token needed) ### Claude (Web & Desktop) 1. Open **Customize → Connectors → Add custom connector**. 2. Enter `https://jointtex.com/mcp`. 3. Sign in to JointTex in the browser popup and choose your scopes and projects. > You can also download the official JointTex Claude plugin bundle from **Account settings → Access tokens** on JointTex and upload it under **Plugins**. It configures the same OAuth connection together with JointTex workflow instructions. ### Claude Code ```sh claude mcp add --transport http --scope user jointtex https://jointtex.com/mcp ``` Then run `/mcp` inside Claude Code to finish browser sign-in. ### ChatGPT 1. Open **Plugins → Add custom MCP server**. 2. Enter `https://jointtex.com/mcp` and complete browser OAuth sign-in. ### OpenAI Codex ```sh codex mcp add jointtex --url https://jointtex.com/mcp ``` Codex initiates the OAuth browser flow automatically. ### Cursor Add to `~/.cursor/mcp.json`: ```json { "mcpServers": { "jointtex": { "url": "https://jointtex.com/mcp" } } } ``` ### Visual Studio Code Add to `.vscode/mcp.json` (note the top-level `servers` key): ```json { "servers": { "jointtex": { "type": "http", "url": "https://jointtex.com/mcp" } } } ``` ### Gemini CLI ```sh gemini mcp add --transport http jointtex https://jointtex.com/mcp ``` Then run `/mcp auth jointtex` to sign in. ### Cline & Cherry Studio Import or paste into your MCP servers configuration: ```json { "mcpServers": { "jointtex": { "type": "streamableHttp", "url": "https://jointtex.com/mcp" } } } ``` ### CodeBuddy CLI, Hermes & OpenClaw ```sh # CodeBuddy CLI (then run /mcp) codebuddy mcp add --scope user --transport http jointtex https://jointtex.com/mcp # OpenClaw openclaw mcp set jointtex '{"url":"https://jointtex.com/mcp","transport":"streamable-http","auth":"oauth"}' openclaw mcp login jointtex ``` For Hermes (`~/.hermes/config.yaml`), then run `hermes mcp login jointtex`: ```yaml mcp_servers: jointtex: url: "https://jointtex.com/mcp" auth: oauth ``` ## Bearer token clients Create a personal MCP token under **Account settings → Access tokens → Use an MCP token** on JointTex, then replace `` below. ### WorkBuddy Add to `~/.workbuddy/mcp.json`: ```json { "mcpServers": { "jointtex": { "type": "streamableHttp", "url": "https://jointtex.com/mcp", "headers": { "Authorization": "Bearer " } } } } ``` ### Trae or generic Streamable HTTP clients ```json { "mcpServers": { "jointtex": { "url": "https://jointtex.com/mcp", "headers": { "Authorization": "Bearer " } } } } ``` ## Verifying the connection After connecting, ask your agent to call `get_capabilities`. It returns the server version, catalog revision, registered tools, granted scopes, and accessible projects for that connection. --- # Scopes, Tools & Resources URL: https://developers.jointtex.com/mcp/scopes-and-tools/ Every JointTex MCP connection carries an explicit list of **scopes** and (for project-level scopes) an explicit list of **authorized projects**. Always start with read-only scopes and expand access later via **Edit access** in Account settings. ## Scopes reference Write scopes automatically bring their matching read dependency (`compile:run` also brings `files:read` because compile logs and Typst introspection can expose project contents). | Scope | Auto-includes | Purpose | | --- | --- | --- | | `projects:read` | — | List projects, inspect project context, search and read public templates. | | `projects:create` | `projects:read` | Create blank/template projects and request whole-ZIP import links. | | `projects:organize` | `projects:read`, `collections:read` | File selected projects into personal collections. | | `projects:archive` | `projects:read` | Archive or unarchive projects in your personal archive. | | `projects:trash` | `projects:read` | Move owned projects to the recycle bin or restore them (affects all collaborators). | | `collections:read` | — | List your personal collection tree (account-level). | | `collections:write` | `collections:read` | Create, update, or delete collections (account-level; deleting a collection keeps its projects). | | `members:invite` | `projects:read` | Invite collaborators by email to projects you own. | | `files:read` | — | List, search, read files, read PDFs/images/draw.io diagrams, list sandbox fonts, download file/PDF/ZIP links, read history and project checks. | | `files:write` | `files:read` | Create, edit, upload, copy, move, delete files (as tracked changes), restore revisions, and update compile settings. | | `review:decide` | `files:read` | Accept or reject pending tracked changes. | | `compile:run` | `files:read` | Run synchronous or background compiles, read compile logs, run `typst_query`/`typst_eval`, and export to Word, Markdown, HTML, or arXiv packages. | | `comments:read` | — | Read review comment threads on a project. | | `comments:write` | `comments:read` | Start anchored comment threads, reply, resolve/reopen, and delete threads started by this connection. | | `templates:publish` | `projects:read` | Publish an owned, compilable project to the public Template Gallery. | | `account:read` | — | Inspect account setup status (plan, connected services, token counts — never secrets). | | `notes:read` | — | List, search, and read private Personal Notes (account-level). | | `notes:write` | `notes:read` | Create, edit, move, and delete Personal Notes directly (account-level, outside tracked review). | | `memory:read` | — | Read account-wide Agent memories. | | `memory:write` | `memory:read` | Save, update, and delete account-wide Agent memories. | | `references:read` | — | Search personal reference library, connected Zotero library, online `bib_lookup`, and (with `files:read`) project `.bib` files. | ## Core tool groups Call `get_capabilities` on any live connection for the exact catalog revision and tool schemas. Key families include: - **Discovery & Projects**: `get_capabilities`, `list_projects`, `get_project_context`, `create_project`, `invite_member`, `search_templates`, `get_template`, `publish_template`, `read_account_setup`, `search_help`, `read_help`. - **Organization**: `list_collections`, `create_collection`, `update_collection`, `delete_collection`, `get_project_collections`, `add_projects_to_collection`, `remove_projects_from_collection`, `move_projects_to_collection`, `set_project_collections`, `archive_project`, `unarchive_project`, `trash_project`, `restore_project`. - **Reading & Navigation**: `list_files`, `read_file`, `grep`, `read_project_index`, `run_project_checks`, `word_count`, `read_image`, `read_drawio`, `list_fonts`, `list_versions`, `diff_version`. - **Editing (Tracked Changes)**: `write_file` (uses `expected_version`), `write_files` (atomic multi-file batch), `edit_file` (anchored by `old_string`), `multi_edit` (atomic multi-edit in one file), `create_file`, `upload_file`, `copy_path`, `move_path`, `rename_file`, `delete_path`, `restore_file`, `read_changes`, `accept_changes`, `reject_changes`. - **Compilation, SyncTeX & Typst**: `compile` (synchronous), `start_compile` / `get_compile_job` / `cancel_compile_job` (long-running background compiles with `request_id`), `read_compile_log`, `update_compile_settings`, `read_pdf` (supports `pages: "1-8"`, `include_image: true`, `contact_sheet: true`), `search_pdf`, `source_to_pdf`, `pdf_to_source`, `typst_query`, `typst_eval`, `export_project`. - **Large Transfers**: `get_project_import_link`, `get_upload_link`, `get_upload_links`, `get_project_archive_link`, `get_file_link`, `get_pdf_link`. - **Comments, Notes, Memory & References**: `read_comments`, `add_comment`, `reply_comment`, `resolve_comment`, `delete_comment`; `list_notes`, `search_notes`, `read_note`, `write_note`, `edit_note`; `list_memories`, `save_memory`, `update_memory`, `delete_memory`; `search_references`, `search_zotero`, `bib_lookup`. ## Resources and built-in prompts - **Resources**: - `jointtex://projects` — list accessible projects as a static MCP resource. - `jointtex://projects/{project_id}/files/{+path}` — read a project file (including nested paths) as an MCP resource. - `jointtex://projects/{project_id}/compile-log` — read the latest compile log. - **Prompts**: `fix_compile_errors`, `review_changes`, `proofread_file`. ## Error contract and idempotency Every failed tool call responds with `isError: true` and a machine-readable `structuredContent.error`: ```json { "error": { "code": "stale_version", "message": "File changed since expected_version", "retry_after_ms": 2000 } } ``` Always branch on `error.code` rather than matching human-readable messages. Key recovery patterns: - `stale_version` / `anchor_not_found`: Re-read the affected line window (check `changed_lines` or `closest` details) and recompute the edit. - `project_not_authorized` / `insufficient_scope`: Direct the user to `settings_url` to update connection grants. - **Idempotency (`request_id`)**: Mutation tools that accept `request_id` (such as `start_compile`) cache receipts under that UUID so retrying after a dropped HTTP response recovers the original outcome instead of duplicating work. --- # Importing Projects & File Transfers URL: https://developers.jointtex.com/mcp/project-import/ To avoid pushing binary payloads or large archives through an LLM's context window, JointTex MCP issues short-lived, single-purpose HTTP transfer links that run directly from the agent's local machine using `curl`. ## Import a whole repository or ZIP as a new project Requires scope: `projects:create`. 1. Package your local directory or repository into a ZIP archive. 2. Call `get_project_import_link`: ```json { "name": "My Paper", "exclude": ["reference/", ".github/", "**/*.pdf"] } ``` The tool returns `{ url, method: "PUT", expires_at, expires_in: 3600, max_bytes: 104857600 }` (60 minutes, up to **100 MiB**). No project is created yet. 3. Upload the archive directly via HTTP `PUT`: ```sh curl --fail-with-body -T project.zip "" ``` On success, JointTex responds with **HTTP 201** and: ```json { "project_id": "0b0f6a52-6d0e-4a5b-9a55-2f1c6a1d7e11", "name": "My Paper", "root_file": "main.tex", "engine": "xelatex", "files": 42, "sha256": "..." } ``` ### Archive rules and idempotency - **Single root stripping**: If the ZIP has a single enclosing folder (such as a GitHub repository archive), it is stripped automatically before `exclude` globs are applied. - **Exclude patterns**: Up to 100 path globs (max 256 chars each), such as `reference/` or `**/*.pdf`. Security checks (symlinks, path traversal, zip-bomb limits, CRC-32 verification) still apply to the entire archive. - **Automatic authorization**: The new project counts against your account's project quota and is automatically added to the calling MCP connection's authorized project list. - **Safe retries**: Retrying the same link with identical bytes returns the original receipt — even after the link expires (receipts are retained for 24 hours past expiry). Sending different bytes returns `409 upload_id_conflict`; a concurrent retry while creation is finishing returns `409 import_in_progress` with `Retry-After`. - **Link capacity**: Up to 20 active import links per connection (`too_many_links` when full). ## Uploading files into an existing project Requires scope: `files:write`. - **Single file**: Call `get_upload_link({ project_id, path })` and `PUT` the file with `curl -T figure.pdf ""`. - **Batch up to 100 files**: Call `get_upload_links({ project_id, paths })`. All paths are validated atomically and share a 60-minute `expires_at` deadline. Each `PUT` returns the uploaded `sha256` and lands as a tracked change; 0-byte files are supported. - **Small inline uploads**: For small payloads without shell access, `upload_file` supports chunked uploads (up to ~760 KiB per part, 50 MiB total) keyed by a stable `upload_id` UUID. ## Downloading archives, files, and compiled PDFs Requires scope: `files:read`. | Tool | Link lifetime | Usage | | --- | --- | --- | | `get_project_archive_link` | 60 minutes | `curl -L -o project.zip ""` — full project ZIP snapshot | | `get_file_link` | 10 minutes | Download any current project file without signing in | | `get_pdf_link` | 10 minutes | Download the latest compiled PDF without signing in | Treat download links as bearer secrets; they are invalidated immediately if you revoke or disconnect the MCP connection. For import, upload, and archive links, expired links return `410 link_expired` and unknown or revoked links return `404 link_unknown`. Single-file (`get_file_link`) and PDF (`get_pdf_link`) download links return `404 link_unknown` for expired, revoked, or unknown tokens alike. --- # Git Bridge URL: https://developers.jointtex.com/sync/git-bridge/ JointTex exposes every project over Smart HTTP Git so you can work in your local editor, run custom build scripts, or integrate local CI checks alongside real-time web collaborators. > Git Bridge is available on **JointTex Education, Plus, and Pro** plans (based on your own account plan). ## Repository URL and authentication 1. Open **Account settings → Access tokens** on JointTex and create a **Git token** (separate from MCP tokens). 2. In your project's Activity Bar, open **External connections → Git** and copy the repository URL: ```text https://jointtex.com/git/ ``` 3. Authenticate over HTTP Basic using **any non-empty username** (for example `x-access-token` or `git`) and your **Git token as the password**: ```sh git clone https://x-access-token:@jointtex.com/git/ ``` For day-to-day work, store the token in your OS credential helper (`git config --global credential.helper ...`) rather than embedding it in `.git/config`. ## Branch and merge semantics JointTex's Git Bridge is designed to cooperate safely with live browser editing: - **`main` is the only branch**: Pushing other branches or attempting to delete `main` is rejected by the server's pre-receive hook. - **Role permissions**: Every project member (including viewers) can `clone` and `pull`; only **owners** and **editors** can `push`. - **Automatic non-overlapping merges**: If web collaborators edited files while your local checkout was behind, pushing changes to **disjoint file paths** is merged automatically on the server. - **Explicit conflict rejection**: If both your push and the live project modified the **same file path**, the push is rejected and the server prints the conflicting paths. Run `git pull`, resolve the conflicts locally, and push again. ```sh # Typical local sync loop git pull --rebase # edit files locally git add . git commit -m "Revise section 3 proofs" git push origin main ``` --- # GitHub Sync & WebDAV URL: https://developers.jointtex.com/sync/webdav-and-github/ Beyond command-line Git, JointTex provides managed two-way synchronization with **GitHub** and **WebDAV**. Both connectors are available when the **project owner** holds a JointTex Education, Plus, or Pro plan. ## GitHub Sync Use GitHub Sync when your team already reviews pull requests, tags releases, or archives paper artifacts in a GitHub repository. ### Setup 1. Open **Account settings → External connections** on JointTex, connect GitHub, and install the **JointTex GitHub App** on the repositories you choose. 2. In a project's **External connections** panel, choose **GitHub**, select the repository and target branch, inspect the initial change preview (up to the first 500 changes), and confirm. 3. You can also start a new project directly from an existing GitHub branch via **Import from GitHub** on the JointTex dashboard — the imported project remains linked automatically. ### Sync behavior and limits - **Always manual**: Remote commits on GitHub are flagged in the project sidebar, but JointTex never overwrites live collaborator work automatically. Click **Review and sync** when ready. - **Excluded paths**: `.github/workflows` and `.compile` are excluded from synchronization. - **Git LFS**: Files stored in Git LFS are supported up to **50 MB per file**. - **Submodules**: Repositories containing Git submodules cannot be synchronized. ## WebDAV Sync Use WebDAV to mirror projects with Nextcloud, ownCloud, university storage, or personal NAS servers. ### Setup 1. Save a reusable WebDAV profile under **Account settings → External connections** (root folder URL, username, and application password), or enter per-project credentials. 2. Select a nested project folder inside your WebDAV root (missing folders are created automatically), click **Test and preview**, and confirm the initial reconciliation. 3. Single files up to **50 MB** are supported. ### Sync behavior - **Pull on demand**: Use **Sync now** to fetch remote-only changes from WebDAV. - **Optional push-on-change**: Automatic WebDAV sync runs only after the JointTex project changes and pauses automatically after three consecutive failures until a manual sync succeeds. - **Mass-deletion safeguard**: If all synchronized files disappear from one side (for example, after renaming a remote folder), sync pauses and asks you to choose file by file instead of wiping the other side. ## Conflict resolution and permissions - **Zero silent overwrites**: Whenever GitHub or WebDAV detects conflicting edits on the same file, no files are changed until you review and submit decisions. - **30-day conflict archives**: Deleted or superseded conflict copies remain downloadable for **30 days** under **Recent conflict archives**, even if you disconnect a project with unresolved conflicts. - **Roles**: Only **owners** can configure or disconnect GitHub/WebDAV; **owners** and **editors** can sync and resolve conflicts; **viewers** can inspect connection status.